X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fcommon%2Fsessiond-comm%2Fsessiond-comm.c;h=58a7ffb509a83fd423bdb418fa354fbdd110ee9f;hp=9a13f41488a9ef6deb61323cf403f7ed8688da1a;hb=554831e798d0646f5d8c261b6207527c5f839222;hpb=4a096a5baf467a5c0c1346b759b7c3ac43125ff2 diff --git a/src/common/sessiond-comm/sessiond-comm.c b/src/common/sessiond-comm/sessiond-comm.c index 9a13f4148..58a7ffb50 100644 --- a/src/common/sessiond-comm/sessiond-comm.c +++ b/src/common/sessiond-comm/sessiond-comm.c @@ -38,6 +38,8 @@ /* For Inet6 socket */ #include "inet6.h" +#define NETWORK_TIMEOUT_ENV "LTTNG_NETWORK_SOCKET_TIMEOUT" + static struct lttcomm_net_family net_families[] = { { LTTCOMM_INET, lttcomm_create_inet_sock }, { LTTCOMM_INET6, lttcomm_create_inet6_sock }, @@ -70,6 +72,8 @@ static const char *lttcomm_readable_code[] = { [ LTTCOMM_ERR_INDEX(LTTCOMM_NR) ] = "Unknown error code" }; +static unsigned long network_timeout; + /* * Return ptr to string representing a human readable error code from the * lttcomm_return_code enum. @@ -368,3 +372,30 @@ error_free: error: return NULL; } + +LTTNG_HIDDEN +void lttcomm_init(void) +{ + const char *env; + + env = getenv(NETWORK_TIMEOUT_ENV); + if (env) { + long timeout; + + errno = 0; + timeout = strtol(env, NULL, 0); + if (errno != 0 || timeout < -1L) { + PERROR("Network timeout"); + } else { + if (timeout > 0) { + network_timeout = timeout; + } + } + } +} + +LTTNG_HIDDEN +unsigned long lttcomm_get_network_timeout(void) +{ + return network_timeout; +}