Fix: consumer recv command error path
authorDavid Goulet <dgoulet@efficios.com>
Tue, 11 Sep 2012 19:28:59 +0000 (15:28 -0400)
committerDavid Goulet <dgoulet@efficios.com>
Tue, 11 Sep 2012 19:31:15 +0000 (15:31 -0400)
See bug #332.

The debug output now prints this and does not infinite loop:

DEBUG1: Communication interrupted on command socket [in
lttng_consumer_thread_receive_fds() at consumer.c:1784]
DEBUG1: consumer_thread_receive_fds exiting [in
lttng_consumer_thread_receive_fds() at consumer.c:1794]

Fixes #332

Signed-off-by: David Goulet <dgoulet@efficios.com>
src/common/consumer.c
src/common/kernel-consumer/kernel-consumer.c
src/common/ust-consumer/ust-consumer.c

index 008bf8e54904d71158400216393f0fc6c5786e63..1c919003656be9b81e5c58e8d65f5f02ff57612a 100644 (file)
@@ -1776,8 +1776,12 @@ void *lttng_consumer_thread_receive_fds(void *data)
                        DBG("Received STOP command");
                        goto end;
                }
                        DBG("Received STOP command");
                        goto end;
                }
-               if (ret < 0) {
-                       ERR("Communication interrupted on command socket");
+               if (ret <= 0) {
+                       /*
+                        * This could simply be a session daemon quitting. Don't output
+                        * ERR() here.
+                        */
+                       DBG("Communication interrupted on command socket");
                        goto end;
                }
                if (consumer_quit) {
                        goto end;
                }
                if (consumer_quit) {
index 86e405158098d1bf9c995681985a5c6893ae86cf..47463c6501eddb48c4963d99c15b3d3c510c035c 100644 (file)
@@ -257,7 +257,12 @@ int lttng_kconsumer_recv_cmd(struct lttng_consumer_local_data *ctx,
        } while (ret < 0 && errno == EINTR);
 end_nosignal:
        rcu_read_unlock();
        } while (ret < 0 && errno == EINTR);
 end_nosignal:
        rcu_read_unlock();
-       return 0;
+
+       /*
+        * Return 1 to indicate success since the 0 value can be a socket
+        * shutdown during the recv() or send() call.
+        */
+       return 1;
 }
 
 /*
 }
 
 /*
index 855d07141b6ebe70424ed6ee649babb494e984a4..2b8098835857106a811f03761fcafe7489f1ce1f 100644 (file)
@@ -92,6 +92,11 @@ int lttng_ustconsumer_get_produced_snapshot(
        return ret;
 }
 
        return ret;
 }
 
+/*
+ * Receive command from session daemon and process it.
+ *
+ * Return 1 on success else a negative value or 0.
+ */
 int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx,
                int sock, struct pollfd *consumer_sockpoll)
 {
 int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx,
                int sock, struct pollfd *consumer_sockpoll)
 {
@@ -305,9 +310,13 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx,
                ret = write(ctx->consumer_poll_pipe[1], "", 1);
        } while (ret < 0 && errno == EINTR);
 end_nosignal:
                ret = write(ctx->consumer_poll_pipe[1], "", 1);
        } while (ret < 0 && errno == EINTR);
 end_nosignal:
-       /* XXX: At some point we might want to return something else than zero */
        rcu_read_unlock();
        rcu_read_unlock();
-       return 0;
+
+       /*
+        * Return 1 to indicate success since the 0 value can be a socket
+        * shutdown during the recv() or send() call.
+        */
+       return 1;
 }
 
 int lttng_ustconsumer_allocate_channel(struct lttng_consumer_channel *chan)
 }
 
 int lttng_ustconsumer_allocate_channel(struct lttng_consumer_channel *chan)
This page took 0.030257 seconds and 4 git commands to generate.