Introduce LTTNG_NETWORK_SOCKET_TIMEOUT env. var
[lttng-tools.git] / src / common / sessiond-comm / sessiond-comm.c
index 9a13f41488a9ef6deb61323cf403f7ed8688da1a..58a7ffb509a83fd423bdb418fa354fbdd110ee9f 100644 (file)
@@ -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;
+}
This page took 0.024015 seconds and 4 git commands to generate.