From: Mathieu Desnoyers Date: Thu, 28 Feb 2013 18:03:44 +0000 (-0500) Subject: Fix: ustctl: return -EPIPE to sessiond if connection is closed X-Git-Tag: v2.2.0-rc1~69 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=b869b5ae63308b47d929a7859623054e685c6332;p=lttng-ust.git Fix: ustctl: return -EPIPE to sessiond if connection is closed Signed-off-by: Mathieu Desnoyers --- diff --git a/liblttng-ust-comm/lttng-ust-comm.c b/liblttng-ust-comm/lttng-ust-comm.c index cc0eebe2..5d7a049b 100644 --- a/liblttng-ust-comm/lttng-ust-comm.c +++ b/liblttng-ust-comm/lttng-ust-comm.c @@ -155,8 +155,11 @@ int ustcomm_accept_unix_sock(int sock) /* Blocking call */ new_fd = accept(sock, (struct sockaddr *) &sun, &len); if (new_fd < 0) { - PERROR("accept"); - return -errno; + if (errno != ECONNABORTED) + PERROR("accept"); + new_fd = -errno; + if (new_fd == -ECONNABORTED) + new_fd = -EPIPE; } return new_fd; } @@ -275,6 +278,8 @@ ssize_t ustcomm_recv_unix_sock(int sock, void *buf, size_t len) if (errno != EPIPE && errno != ECONNRESET) PERROR("recvmsg"); ret = -errno; + if (ret == -ECONNRESET) + ret = -EPIPE; shutret = shutdown(sock, SHUT_RDWR); if (shutret) @@ -320,6 +325,8 @@ ssize_t ustcomm_send_unix_sock(int sock, const void *buf, size_t len) if (errno != EPIPE && errno != ECONNRESET) PERROR("sendmsg"); ret = -errno; + if (ret == -ECONNRESET) + ret = -EPIPE; shutret = shutdown(sock, SHUT_RDWR); if (shutret) @@ -376,6 +383,9 @@ ssize_t ustcomm_send_fds_unix_sock(int sock, int *fds, size_t nb_fd) if (errno != EPIPE && errno != ECONNRESET) { PERROR("sendmsg"); } + ret = -errno; + if (ret == -ECONNRESET) + ret = -EPIPE; } return ret; } @@ -418,6 +428,8 @@ ssize_t ustcomm_recv_fds_unix_sock(int sock, int *fds, size_t nb_fd) } if (errno == EPIPE || errno == ECONNRESET) ret = -errno; + if (ret == -ECONNRESET) + ret = -EPIPE; goto end; } if (ret == 0) { diff --git a/liblttng-ust-ctl/ustctl.c b/liblttng-ust-ctl/ustctl.c index ff4a537b..54456c8e 100644 --- a/liblttng-ust-ctl/ustctl.c +++ b/liblttng-ust-ctl/ustctl.c @@ -252,8 +252,6 @@ int ustctl_set_filter(int sock, struct lttng_ust_filter_bytecode *bytecode, ret = ustcomm_send_unix_sock(sock, bytecode->data, bytecode->len); if (ret < 0) { - if (ret == -ECONNRESET) - fprintf(stderr, "remote end closed connection\n"); return ret; } if (ret != bytecode->len) diff --git a/liblttng-ust/lttng-events.c b/liblttng-ust/lttng-events.c index 46ba11d5..ec5d78f5 100644 --- a/liblttng-ust/lttng-events.c +++ b/liblttng-ust/lttng-events.c @@ -237,8 +237,10 @@ int lttng_session_enable(struct lttng_session *session) fields, &chan->id, &chan->header_type); - if (ret) + if (ret) { + DBG("Error (%d) registering channel to sessiond", ret); return ret; + } } CMM_ACCESS_ONCE(session->active) = 1; @@ -384,6 +386,7 @@ int lttng_event_create(const struct lttng_event_desc *desc, uri, &event->id); if (ret < 0) { + DBG("Error (%d) registering event to sessiond", ret); goto sessiond_register_error; } }