X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fcommon%2Fsessiond-comm%2Fsessiond-comm.c;fp=src%2Fcommon%2Fsessiond-comm%2Fsessiond-comm.c;h=65952b273eaf49c52a17955ab6bda441bd65f554;hp=58a7ffb509a83fd423bdb418fa354fbdd110ee9f;hb=783a3b9aa609d6805e1463655d25c7ae176c4859;hpb=a655f4cf59f557aef3f0a975988d87bdd3b199fd diff --git a/src/common/sessiond-comm/sessiond-comm.c b/src/common/sessiond-comm/sessiond-comm.c index 58a7ffb50..65952b273 100644 --- a/src/common/sessiond-comm/sessiond-comm.c +++ b/src/common/sessiond-comm/sessiond-comm.c @@ -373,6 +373,46 @@ error: return NULL; } +/* + * Set socket receiving timeout. + */ +LTTNG_HIDDEN +int lttcomm_setsockopt_rcv_timeout(int sock, unsigned int msec) +{ + int ret; + struct timeval tv; + + tv.tv_sec = msec / 1000; + tv.tv_usec = (msec % 1000) * 1000; + + ret = setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)); + if (ret < 0) { + PERROR("setsockopt SO_RCVTIMEO"); + } + + return ret; +} + +/* + * Set socket sending timeout. + */ +LTTNG_HIDDEN +int lttcomm_setsockopt_snd_timeout(int sock, unsigned int msec) +{ + int ret; + struct timeval tv; + + tv.tv_sec = msec / 1000; + tv.tv_usec = (msec % 1000) * 1000; + + ret = setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv)); + if (ret < 0) { + PERROR("setsockopt SO_SNDTIMEO"); + } + + return ret; +} + LTTNG_HIDDEN void lttcomm_init(void) {