From 50be2fc41b02ee04860b5199d0ce2d346b1ea7c2 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Mon, 9 Apr 2012 11:02:42 -0400 Subject: [PATCH] Fix: ustctl need to send the second fd upon error of 1st fd Otherwise cause protocol discrepancy between ust and sessiond upon send error. The sessiond will wait for an fd that never arrives. Signed-off-by: Mathieu Desnoyers --- liblttng-ust/lttng-ust-comm.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/liblttng-ust/lttng-ust-comm.c b/liblttng-ust/lttng-ust-comm.c index 099a6c85..0765c9b5 100644 --- a/liblttng-ust/lttng-ust-comm.c +++ b/liblttng-ust/lttng-ust-comm.c @@ -320,14 +320,20 @@ end: || lum->cmd == LTTNG_UST_CHANNEL || lum->cmd == LTTNG_UST_METADATA) && lur.ret_code == USTCOMM_OK) { + int sendret = 0; + /* we also need to send the file descriptors. */ ret = ustcomm_send_fds_unix_sock(sock, &shm_fd, &shm_fd, 1, sizeof(int)); if (ret < 0) { perror("send shm_fd"); - goto error; + sendret = ret; } + /* + * The sessiond expects 2 file descriptors, even upon + * error. + */ ret = ustcomm_send_fds_unix_sock(sock, &wait_fd, &wait_fd, 1, sizeof(int)); @@ -335,6 +341,10 @@ end: perror("send wait_fd"); goto error; } + if (sendret) { + ret = sendret; + goto error; + } } /* * We still have the memory map reference, and the fds have been -- 2.34.1