X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fcommon%2Fsessiond-comm%2Funix.c;h=2f79f3a280a123bd85a861ff039f72e5e4c6064c;hp=9ef04ee0df1943ce41b4ca886ee2913d27d21619;hb=907b42de38da8455f22f2b4e03fbc8e75ecbd38a;hpb=32dd26fbc3c69fe677a7917535e10ace066e674c 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; +}