diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 21:12:02 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 21:12:02 +0000 |
commit | 77e50caaf2ef81cd91075cf836fed0e75718ffb4 (patch) | |
tree | 53b7b411290b63192fc9e924a3b6b65cdf67e9d0 /debian/vendor-h2o/deps/libyrmcds/socket.c | |
parent | Adding upstream version 1.8.3. (diff) | |
download | dnsdist-77e50caaf2ef81cd91075cf836fed0e75718ffb4.tar.xz dnsdist-77e50caaf2ef81cd91075cf836fed0e75718ffb4.zip |
Adding debian version 1.8.3-2.debian/1.8.3-2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | debian/vendor-h2o/deps/libyrmcds/socket.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/debian/vendor-h2o/deps/libyrmcds/socket.c b/debian/vendor-h2o/deps/libyrmcds/socket.c new file mode 100644 index 0000000..6d30ee1 --- /dev/null +++ b/debian/vendor-h2o/deps/libyrmcds/socket.c @@ -0,0 +1,35 @@ +// (C) 2013 Cybozu et al. + +#include "yrmcds.h" + +#include <sys/socket.h> +#include <sys/types.h> +#include <sys/time.h> + +yrmcds_error yrmcds_shutdown(yrmcds* c) { + if( c == NULL ) + return YRMCDS_BAD_ARGUMENT; + if( shutdown(c->sock, SHUT_RD) == -1 ) { + return YRMCDS_SYSTEM_ERROR; + } + return YRMCDS_OK; +} + +int yrmcds_fileno(yrmcds* c) { + return c->sock; +} + +yrmcds_error yrmcds_set_timeout(yrmcds* c, int timeout) { + if( c == NULL || timeout < 0 ) + return YRMCDS_BAD_ARGUMENT; + + struct timeval tv; + tv.tv_sec = timeout; + tv.tv_usec = 0; + + if( setsockopt(c->sock, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) == -1 ) + return YRMCDS_SYSTEM_ERROR; + if( setsockopt(c->sock, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv)) == -1 ) + return YRMCDS_SYSTEM_ERROR; + return YRMCDS_OK; +} |