Fix: src.ctf.lttng-live: checking `errno` value on all errors
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Tue, 5 Nov 2019 19:25:15 +0000 (14:25 -0500)
committerSimon Marchi <simon.marchi@efficios.com>
Fri, 15 Nov 2019 15:50:55 +0000 (10:50 -0500)
Issue
=====
We check the errno value even in cases where the errno is not set by the
function that witnessed the error.
For example, we have a `goto error;` after the
`lttng_live_get_one_metadata_packet() call.

Solution
========
Move the errno check right after the functions that set it on error.

Note
====
This erroneous change was introduced by this commit:
  commit c28512ab93b16501a8b0da494f0a03e5f0f22662
  Author: Francis Deslauriers <francis.deslauriers@efficios.com>
  Date:   Mon Oct 28 14:49:08 2019 -0400

      src.ctf.lttng-live: make `lttng_live_get_one_metadata_packet()` return status

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I7acb86984249658460888079fd7968d35f6d43fa
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2342
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
src/plugins/ctf/lttng-live/metadata.c

index de8f3dc9a00b952eca4df3b8e105277b9c99fc48..787fc0b322da0c39d68494b636c852a6e6ec8876 100644 (file)
@@ -154,9 +154,15 @@ enum lttng_live_iterator_status lttng_live_metadata_update(
        /* Open for writing */
        fp = bt_open_memstream(&metadata_buf, &size);
        if (!fp) {
-               BT_COMP_LOGE_APPEND_CAUSE_ERRNO(self_comp,
-                       "Metadata open_memstream", ".");
-               goto error;
+               if (errno == EINTR &&
+                               lttng_live_graph_is_canceled(session->lttng_live_msg_iter)) {
+                       status = LTTNG_LIVE_ITERATOR_STATUS_AGAIN;
+               } else {
+                       BT_COMP_LOGE_APPEND_CAUSE_ERRNO(self_comp,
+                               "Metadata open_memstream", ".");
+                       status = LTTNG_LIVE_ITERATOR_STATUS_ERROR;
+               }
+               goto end;
        }
 
        keep_receiving = true;
@@ -222,9 +228,15 @@ enum lttng_live_iterator_status lttng_live_metadata_update(
 
        fp = bt_fmemopen(metadata_buf, len_read, "rb");
        if (!fp) {
-               BT_COMP_LOGE_APPEND_CAUSE_ERRNO(self_comp,
-                       "Cannot memory-open metadata buffer", ".");
-               goto error;
+               if (errno == EINTR &&
+                               lttng_live_graph_is_canceled(session->lttng_live_msg_iter)) {
+                       status = LTTNG_LIVE_ITERATOR_STATUS_AGAIN;
+               } else {
+                       BT_COMP_LOGE_APPEND_CAUSE_ERRNO(self_comp,
+                               "Cannot memory-open metadata buffer", ".");
+                       status = LTTNG_LIVE_ITERATOR_STATUS_ERROR;
+               }
+               goto end;
        }
 
        /*
@@ -277,13 +289,7 @@ enum lttng_live_iterator_status lttng_live_metadata_update(
        goto end;
 
 error:
-       if (errno == EINTR) {
-               if (lttng_live_graph_is_canceled(session->lttng_live_msg_iter)) {
-                       status = LTTNG_LIVE_ITERATOR_STATUS_AGAIN;
-               }
-       } else {
-               status = LTTNG_LIVE_ITERATOR_STATUS_ERROR;
-       }
+       status = LTTNG_LIVE_ITERATOR_STATUS_ERROR;
 end:
        if (fp) {
                int closeret;
This page took 0.025302 seconds and 4 git commands to generate.