Fix: sessiond: snapshot: handle consumer return codes
[lttng-tools.git] / src / bin / lttng-sessiond / ust-app.c
index a133eeeef19fe563f06af0b89b52033c60fef60d..0e1907d8e99ed5fef30dd1e52f1bf802b51381ea 100644 (file)
@@ -487,9 +487,11 @@ void delete_ust_app_channel(int sock, struct ust_app_channel *ua_chan,
                registry = get_session_registry(ua_chan->session);
                if (registry) {
                        ust_registry_channel_del_free(registry, ua_chan->key,
-                               true);
+                               sock >= 0);
+               }
+               if (sock >= 0) {
+                       save_per_pid_lost_discarded_counters(ua_chan);
                }
-               save_per_pid_lost_discarded_counters(ua_chan);
        }
 
        if (ua_chan->obj != NULL) {
@@ -3017,7 +3019,7 @@ static int create_channel_per_pid(struct ust_app *app,
        if (ret < 0) {
                ERR("Error creating UST channel \"%s\" on the consumer daemon",
                        ua_chan->name);
-               goto error;
+               goto error_remove_from_registry;
        }
 
        ret = send_channel_pid_to_ust(app, ua_sess, ua_chan);
@@ -3025,7 +3027,7 @@ static int create_channel_per_pid(struct ust_app *app,
                if (ret != -ENOTCONN) {
                        ERR("Error sending channel to application");
                }
-               goto error;
+               goto error_remove_from_registry;
        }
 
        chan_reg_key = ua_chan->key;
@@ -3045,9 +3047,13 @@ static int create_channel_per_pid(struct ust_app *app,
        if (cmd_ret != LTTNG_OK) {
                ret = - (int) cmd_ret;
                ERR("Failed to add channel to notification thread");
-               goto error;
+               goto error_remove_from_registry;
        }
 
+error_remove_from_registry:
+       if (ret) {
+               ust_registry_channel_del_free(registry, ua_chan->key, false);
+       }
 error:
        rcu_read_unlock();
        return ret;
@@ -6060,15 +6066,17 @@ int ust_app_snapshot_record(struct ltt_ust_session *usess,
                                                nb_packets_per_stream,
                                                trace_archive_id);
                                if (ret < 0) {
+                                       if (ret == -LTTNG_ERR_CHAN_NOT_FOUND) {
+                                               continue;
+                                       }
                                        goto error;
                                }
                        }
 
                        registry = get_session_registry(ua_sess);
                        if (!registry) {
-                               DBG("Application session is being torn down. Abort snapshot record.");
-                               ret = -1;
-                               goto error;
+                               DBG("Application session is being torn down. Skip application.");
+                               continue;
                        }
                        ret = consumer_snapshot_channel(socket,
                                        registry->metadata_key, output,
@@ -6076,6 +6084,9 @@ int ust_app_snapshot_record(struct ltt_ust_session *usess,
                                        pathname, wait, 0,
                                        trace_archive_id);
                        if (ret < 0) {
+                               if (ret == -LTTNG_ERR_CHAN_NOT_FOUND) {
+                                       continue;
+                               }
                                goto error;
                        }
                }
@@ -6424,7 +6435,7 @@ int ust_app_rotate_session(struct ltt_session *session)
 
                        registry = get_session_registry(ua_sess);
                        if (!registry) {
-                               DBG("Application session is being torn down. Abort snapshot record.");
+                               DBG("Application session is being torn down. Abort session rotation.");
                                ret = -1;
                                goto error;
                        }
This page took 0.025241 seconds and 5 git commands to generate.