Fix: metadata push -EPIPE should be recoverable
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 6 Jul 2015 16:21:06 +0000 (12:21 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 9 Jul 2015 22:11:33 +0000 (18:11 -0400)
This return value can be caused by application terminating concurrently
(when using per-PID buffers), so it should not make the consumer
management thread exit.

CC: Aravind HT <aravind.ht@gmail.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng-sessiond/ust-app.c
src/bin/lttng-sessiond/ust-consumer.c

index c30792c3c785e959968dc9c00434c0e12af1ec73..6f032da112baae7a9a97af061f4388bc621b6d6d 100644 (file)
@@ -431,6 +431,9 @@ void delete_ust_app_channel(int sock, struct ust_app_channel *ua_chan,
  * Must be called with the registry lock held.
  *
  * On success, return the len of metadata pushed or else a negative value.
+ * Returning a -EPIPE return value means we could not send the metadata,
+ * but it can be caused by recoverable errors (e.g. the application has
+ * terminated concurrently).
  */
 ssize_t ust_app_push_metadata(struct ust_registry_session *registry,
                struct consumer_socket *socket, int send_zero_data)
@@ -454,9 +457,10 @@ ssize_t ust_app_push_metadata(struct ust_registry_session *registry,
        /*
         * On a push metadata error either the consumer is dead or the
         * metadata channel has been destroyed because its endpoint
-        * might have died (e.g: relayd). If so, the metadata closed
-        * flag is set to 1 so we deny pushing metadata again which is
-        * not valid anymore on the consumer side.
+        * might have died (e.g: relayd), or because the application has
+        * exited. If so, the metadata closed flag is set to 1 so we
+        * deny pushing metadata again which is not valid anymore on the
+        * consumer side.
         */
        if (registry->metadata_closed) {
                return -EPIPE;
@@ -547,6 +551,9 @@ error_push:
  * of socket throughout this function.
  *
  * Return 0 on success else a negative error.
+ * Returning a -EPIPE return value means we could not send the metadata,
+ * but it can be caused by recoverable errors (e.g. the application has
+ * terminated concurrently).
  */
 static int push_metadata(struct ust_registry_session *registry,
                struct consumer_output *consumer)
index 78e50df43fab90dab22892095f85050e1b1d2e11..ad076e3c3173085f922c3d7864d9959bb9c93c9c 100644 (file)
@@ -511,12 +511,15 @@ int ust_consumer_metadata_request(struct consumer_socket *socket)
        pthread_mutex_lock(&ust_reg->lock);
        ret_push = ust_app_push_metadata(ust_reg, socket, 1);
        pthread_mutex_unlock(&ust_reg->lock);
-       if (ret_push < 0) {
+       if (ret_push == -EPIPE) {
+               DBG("Application or relay closed while pushing metadata");
+       } else if (ret_push < 0) {
                ERR("Pushing metadata");
                ret = -1;
                goto end;
+       } else {
+               DBG("UST Consumer metadata pushed successfully");
        }
-       DBG("UST Consumer metadata pushed successfully");
        ret = 0;
 
 end:
This page took 0.029158 seconds and 5 git commands to generate.