X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fcommon%2Fsessiond-comm%2Fsessiond-comm.c;h=336902a60f597d6c7820f34032f29d6a77b8396f;hp=58a7ffb509a83fd423bdb418fa354fbdd110ee9f;hb=2038dd6ce78bc856ece474626b7f039d19860bce;hpb=554831e798d0646f5d8c261b6207527c5f839222 diff --git a/src/common/sessiond-comm/sessiond-comm.c b/src/common/sessiond-comm/sessiond-comm.c index 58a7ffb50..336902a60 100644 --- a/src/common/sessiond-comm/sessiond-comm.c +++ b/src/common/sessiond-comm/sessiond-comm.c @@ -16,7 +16,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#define _GNU_SOURCE +#define _LGPL_SOURCE #include #include #include @@ -32,7 +32,7 @@ #include "sessiond-comm.h" /* For Unix socket */ -#include "unix.h" +#include /* For Inet socket */ #include "inet.h" /* For Inet6 socket */ @@ -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) {