From af5e22f20180ac52ad30a6c3af1c97d88ef32f6a Mon Sep 17 00:00:00 2001 From: David Goulet Date: Fri, 11 Oct 2013 14:59:45 -0400 Subject: [PATCH] Fix: set app socket timeout just after accept() This is to make sure the socket has a timeout *before* doing any I/O operations on it. Signed-off-by: David Goulet Conflicts: src/bin/lttng-sessiond/main.c --- src/bin/lttng-sessiond/main.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index 093a2fb31..a70ecda4c 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -1292,12 +1292,6 @@ static void *thread_manage_apps(void *data) goto error; } - /* Set socket timeout for both receiving and ending */ - (void) lttcomm_setsockopt_rcv_timeout(sock, - app_socket_timeout); - (void) lttcomm_setsockopt_snd_timeout(sock, - app_socket_timeout); - DBG("Apps with sock %d added to poll set", sock); health_code_update(); @@ -1800,6 +1794,18 @@ static void *thread_registration_apps(void *data) goto error; } + /* + * Set socket timeout for both receiving and ending. + * app_socket_timeout is in seconds, whereas + * lttcomm_setsockopt_rcv_timeout and + * lttcomm_setsockopt_snd_timeout expect msec as + * parameter. + */ + (void) lttcomm_setsockopt_rcv_timeout(sock, + app_socket_timeout * 1000); + (void) lttcomm_setsockopt_snd_timeout(sock, + app_socket_timeout * 1000); + /* * Set the CLOEXEC flag. Return code is useless because * either way, the show must go on. -- 2.34.1