Introduce LTTNG_NETWORK_SOCKET_TIMEOUT env. var
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 7 Aug 2013 09:26:51 +0000 (05:26 -0400)
committerDavid Goulet <dgoulet@efficios.com>
Wed, 7 Aug 2013 09:37:20 +0000 (05:37 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
doc/man/lttng-relayd.8
doc/man/lttng-sessiond.8
src/bin/lttng-consumerd/lttng-consumerd.c
src/bin/lttng-relayd/main.c
src/bin/lttng-sessiond/main.c
src/common/sessiond-comm/sessiond-comm.c
src/common/sessiond-comm/sessiond-comm.h

index 44631b1b2bbb4a171d14f9d620f893dd08c1db61..1d1802a4c291131b1c808423b710f7c50c9b5dc1 100644 (file)
@@ -61,6 +61,15 @@ Output base directory. Must use an absolute path (~/lttng-traces is the default)
 .TP
 .BR "-V, --version"
 Show version number
+.SH "ENVIRONMENT VARIABLES"
+
+.PP
+.IP "LTTNG_NETWORK_SOCKET_TIMEOUT"
+Control timeout of socket connection, receive and send. Takes an integer
+parameter: the timeout value, in milliseconds. A value of 0 or -1 uses
+the timeout of the operating system (this is the default).
+.PP
+
 .SH "SEE ALSO"
 
 .PP
index dfc94185ff6f2722ea8f865c26ca2e69e522063b..347bffcaa3ed980e8fdb920582654945bf45b3c9 100644 (file)
@@ -134,9 +134,14 @@ Debug-mode disabling use of clone/fork. Insecure, but required to allow
 debuggers to work with sessiond on some operating systems.
 .IP "LTTNG_APP_SOCKET_TIMEOUT"
 Control the timeout of application's socket when sending and receiving
-commands. After this period of time, the application is unregistered by the
-session daemon. A value of 0 or -1 means an infinite timeout. Default value is
-5 seconds.
+commands. Takes an integer parameter: the timeout value, in seconds.
+After this period of time, the application is unregistered by the
+session daemon. A value of 0 or -1 means an infinite timeout. Default
+value is 5 seconds.
+.IP "LTTNG_NETWORK_SOCKET_TIMEOUT"
+Control timeout of socket connection, receive and send. Takes an integer
+parameter: the timeout value, in milliseconds. A value of 0 or -1 uses
+the timeout of the operating system (this is the default).
 .SH "SEE ALSO"
 
 .PP
index 8ddd5a372005490bb37f1ef8c01bc8045dabdbde..e05a4b150f1b3b852cec82e5e6292de5a83796c5 100644 (file)
@@ -380,6 +380,9 @@ int main(int argc, char **argv)
        }
        ctx->type = opt_type;
 
+       /* Initialize communication library */
+       lttcomm_init();
+
        /* Create thread to manage channels */
        ret = pthread_create(&channel_thread, NULL, consumer_thread_channel_poll,
                        (void *) ctx);
index 3bef52b43068e8f8b2ac5ce4a5fbe9289b7fb9ca..53f1b49ce14608e41aa1f82d21894358bb8dcfe3 100644 (file)
@@ -2110,6 +2110,9 @@ int main(int argc, char **argv)
        /* Set up max poll set size */
        lttng_poll_set_max_size();
 
+       /* Initialize communication library */
+       lttcomm_init();
+
        /* Setup the dispatcher thread */
        ret = pthread_create(&dispatcher_thread, NULL,
                        relay_thread_dispatcher, (void *) NULL);
index 2929bba0d6f677cfdf813e3c89a5bb8d7bc51921..e05d72bacb0b9f0ec3278c9c427b6295d7af8347 100644 (file)
@@ -4631,6 +4631,9 @@ int main(int argc, char **argv)
 
        write_pidfile();
 
+       /* Initialize communication library */
+       lttcomm_init();
+
        /* Create thread to manage the client socket */
        ret = pthread_create(&ht_cleanup_thread, NULL,
                        thread_ht_cleanup, (void *) NULL);
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;
+}
index ea8ad1ce0f72e04704309d415ef162f966457b72..2450e79ec5bd78379941e9765de694a02df76ed8 100644 (file)
@@ -474,4 +474,8 @@ extern void lttcomm_copy_sock(struct lttcomm_sock *dst,
 extern struct lttcomm_relayd_sock *lttcomm_alloc_relayd_sock(
                struct lttng_uri *uri, uint32_t major, uint32_t minor);
 
+extern void lttcomm_init(void);
+/* Get network timeout, in milliseconds */
+extern unsigned long lttcomm_get_network_timeout(void);
+
 #endif /* _LTTNG_SESSIOND_COMM_H */
This page took 0.03271 seconds and 5 git commands to generate.