X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fcommon%2Fsessiond-comm%2Funix.c;h=2f79f3a280a123bd85a861ff039f72e5e4c6064c;hp=9ef04ee0df1943ce41b4ca886ee2913d27d21619;hb=ae9e45b342636e7b42eafc15cd105bccfbbbe373;hpb=2d90c6c86651b4c9b3818f230508acfcf4fec66f diff --git a/src/common/sessiond-comm/unix.c b/src/common/sessiond-comm/unix.c index 9ef04ee0d..2f79f3a28 100644 --- a/src/common/sessiond-comm/unix.c +++ b/src/common/sessiond-comm/unix.c @@ -523,3 +523,45 @@ int lttcomm_setsockopt_creds_unix_sock(int sock) #else #error "Please implement credential support for your OS." #endif /* __linux__ */ + +/* + * Set socket reciving timeout. + */ +__attribute__((visibility("hidden"))) +int lttcomm_setsockopt_rcv_timeout(int sock, unsigned int sec) +{ + int ret; + struct timeval tv; + + tv.tv_sec = sec; + tv.tv_usec = 0; + + ret = setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)); + if (ret < 0) { + PERROR("setsockopt SO_RCVTIMEO"); + ret = -errno; + } + + return ret; +} + +/* + * Set socket sending timeout. + */ +__attribute__((visibility("hidden"))) +int lttcomm_setsockopt_snd_timeout(int sock, unsigned int sec) +{ + int ret; + struct timeval tv; + + tv.tv_sec = sec; + tv.tv_usec = 0; + + ret = setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv)); + if (ret < 0) { + PERROR("setsockopt SO_SNDTIMEO"); + ret = -errno; + } + + return ret; +}