Fix: ustctl: return -EPIPE to sessiond if connection is closed
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 28 Feb 2013 18:03:44 +0000 (13:03 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 1 Mar 2013 18:06:48 +0000 (13:06 -0500)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
liblttng-ust-comm/lttng-ust-comm.c
liblttng-ust-ctl/ustctl.c
liblttng-ust/lttng-events.c

index cc0eebe21501062c9b3f141a22422aee7d1d9b71..5d7a049b11568f620bd661c0a2dc73c8567f74d5 100644 (file)
@@ -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) {
index ff4a537b540b71e0b58a97fd24a029bfd8447af3..54456c8e9712dc21ffd64360b602d3fe8c3f49ba 100644 (file)
@@ -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)
index 46ba11d5f12e74935871efcb847c1160d020da96..ec5d78f50527056f1f50adb2e2d4df40da47b630 100644 (file)
@@ -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;
                }
        }
This page took 0.032559 seconds and 4 git commands to generate.