From: David Goulet Date: Tue, 11 Sep 2012 19:28:59 +0000 (-0400) Subject: Fix: consumer recv command error path X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=commitdiff_plain;h=4cbc1a04e8ac3c1dd4f9a4dc44b56ee8430189f0 Fix: consumer recv command error path 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 --- diff --git a/src/common/consumer.c b/src/common/consumer.c index 008bf8e54..1c9190036 100644 --- a/src/common/consumer.c +++ b/src/common/consumer.c @@ -1776,8 +1776,12 @@ void *lttng_consumer_thread_receive_fds(void *data) 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) { diff --git a/src/common/kernel-consumer/kernel-consumer.c b/src/common/kernel-consumer/kernel-consumer.c index 86e405158..47463c650 100644 --- a/src/common/kernel-consumer/kernel-consumer.c +++ b/src/common/kernel-consumer/kernel-consumer.c @@ -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(); - return 0; + + /* + * Return 1 to indicate success since the 0 value can be a socket + * shutdown during the recv() or send() call. + */ + return 1; } /* diff --git a/src/common/ust-consumer/ust-consumer.c b/src/common/ust-consumer/ust-consumer.c index 855d07141..2b8098835 100644 --- a/src/common/ust-consumer/ust-consumer.c +++ b/src/common/ust-consumer/ust-consumer.c @@ -92,6 +92,11 @@ int lttng_ustconsumer_get_produced_snapshot( 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) { @@ -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: - /* XXX: At some point we might want to return something else than zero */ 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)