src.ctf.lttng-live: make `lttng_live_attach_session()` return status
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Tue, 29 Oct 2019 19:55:29 +0000 (15:55 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 1 Nov 2019 14:49:33 +0000 (10:49 -0400)
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: Id7a2924ea9f5ac91bf9848995029e3c6edb9a4d3
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2306
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
src/plugins/ctf/lttng-live/lttng-live.c
src/plugins/ctf/lttng-live/lttng-live.h
src/plugins/ctf/lttng-live/viewer-connection.c

index 774b91c8e39926c9bb7ee6c68b4cc53ca61da9a4..fa493cbb3853fc7960764ecaf34ee00f1b33a9ee 100644 (file)
@@ -437,11 +437,11 @@ enum lttng_live_iterator_status lttng_live_get_session(
 {
        enum lttng_live_iterator_status status;
        uint64_t trace_idx;
-       int ret = 0;
 
        if (!session->attached) {
-               ret = lttng_live_attach_session(session);
-               if (ret) {
+               enum lttng_live_attach_session_status attach_status =
+                       lttng_live_attach_session(session);
+               if (attach_status != LTTNG_LIVE_ATTACH_SESSION_STATUS_OK) {
                        if (lttng_live_graph_is_canceled(lttng_live_msg_iter)) {
                                status = LTTNG_LIVE_ITERATOR_STATUS_AGAIN;
                        } else {
index 994563d0fc9afb4cb947350457f58258685555cb..511c0c486793e9d98ecd774ad6b223847bac8ec2 100644 (file)
@@ -284,7 +284,15 @@ bt_component_class_message_iterator_initialize_method_status lttng_live_msg_iter
 void lttng_live_msg_iter_finalize(bt_self_message_iterator *it);
 
 int lttng_live_create_viewer_session(struct lttng_live_msg_iter *lttng_live_msg_iter);
-int lttng_live_attach_session(struct lttng_live_session *session);
+
+enum lttng_live_attach_session_status {
+       LTTNG_LIVE_ATTACH_SESSION_STATUS_OK     = 0,
+       LTTNG_LIVE_ATTACH_SESSION_STATUS_ERROR  = -2,
+};
+
+enum lttng_live_attach_session_status lttng_live_attach_session(
+               struct lttng_live_session *session);
+
 int lttng_live_detach_session(struct lttng_live_session *session);
 enum lttng_live_iterator_status lttng_live_get_new_streams(
                struct lttng_live_session *session);
index f094a8f96553f3c9e098c373d3a177df9fc0eecf..e3ac7f8d84fc78d05f5bf806cf75cbc71f740a0e 100644 (file)
@@ -810,9 +810,11 @@ error:
 }
 
 BT_HIDDEN
-int lttng_live_attach_session(struct lttng_live_session *session)
+enum lttng_live_attach_session_status lttng_live_attach_session(
+               struct lttng_live_session *session)
 {
        struct lttng_viewer_cmd cmd;
+       enum lttng_live_attach_session_status attach_status;
        struct lttng_viewer_attach_session_request rq;
        struct lttng_viewer_attach_session_response rp;
        struct lttng_live_msg_iter *lttng_live_msg_iter =
@@ -889,10 +891,14 @@ int lttng_live_attach_session(struct lttng_live_session *session)
        session->attached = true;
        session->new_streams_needed = false;
 
-       return 0;
+       attach_status = LTTNG_LIVE_ATTACH_SESSION_STATUS_OK;
+       goto end;
 
 error:
-       return -1;
+       attach_status = LTTNG_LIVE_ATTACH_SESSION_STATUS_ERROR;
+
+end:
+       return attach_status;
 }
 
 BT_HIDDEN
This page took 0.028885 seconds and 4 git commands to generate.