diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 02:57:58 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 02:57:58 +0000 |
commit | be1c7e50e1e8809ea56f2c9d472eccd8ffd73a97 (patch) | |
tree | 9754ff1ca740f6346cf8483ec915d4054bc5da2d /web/server/h2o/libh2o/deps/libyrmcds/socket.c | |
parent | Initial commit. (diff) | |
download | netdata-be1c7e50e1e8809ea56f2c9d472eccd8ffd73a97.tar.xz netdata-be1c7e50e1e8809ea56f2c9d472eccd8ffd73a97.zip |
Adding upstream version 1.44.3.upstream/1.44.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'web/server/h2o/libh2o/deps/libyrmcds/socket.c')
-rw-r--r-- | web/server/h2o/libh2o/deps/libyrmcds/socket.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/web/server/h2o/libh2o/deps/libyrmcds/socket.c b/web/server/h2o/libh2o/deps/libyrmcds/socket.c new file mode 100644 index 00000000..6d30ee16 --- /dev/null +++ b/web/server/h2o/libh2o/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; +} |