From: Jérémie Galarneau Date: Tue, 12 Nov 2019 21:28:50 +0000 (-0500) Subject: relayd: rename viewer_session_set_trace_chunk and hide it X-Git-Tag: v2.12.0-rc1~243 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=664eef54fd79a523dc0674df806d155c9766a2d1;p=lttng-tools.git relayd: rename viewer_session_set_trace_chunk and hide it viewer_session_set_trace_chunk() is renamed to viewer_session_set_trace_chunk_copy() as it creates a copy of the source trace chunk before setting it on a viewer_session. The function is also marked static as it is only needed within the viewer-session.c TU. Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng-relayd/viewer-session.c b/src/bin/lttng-relayd/viewer-session.c index d394465ba..7a5bd6dca 100644 --- a/src/bin/lttng-relayd/viewer-session.c +++ b/src/bin/lttng-relayd/viewer-session.c @@ -41,6 +41,28 @@ end: return vsession; } +static int viewer_session_set_trace_chunk_copy(struct relay_viewer_session *vsession, + struct lttng_trace_chunk *relay_session_trace_chunk) +{ + int ret = 0; + struct lttng_trace_chunk *viewer_chunk; + + assert(relay_session_trace_chunk); + assert(!vsession->current_trace_chunk); + + DBG("Copying relay session's current trace chunk to the viewer session"); + viewer_chunk = lttng_trace_chunk_copy(relay_session_trace_chunk); + if (!viewer_chunk) { + ERR("Failed to create a viewer trace chunk from the relay session's current chunk"); + ret = -1; + goto end; + } + + vsession->current_trace_chunk = viewer_chunk; +end: + return ret; +} + /* The existence of session must be guaranteed by the caller. */ enum lttng_viewer_attach_return_code viewer_session_attach( struct relay_viewer_session *vsession, @@ -65,7 +87,7 @@ enum lttng_viewer_attach_return_code viewer_session_attach( assert(!vsession->current_trace_chunk); session->viewer_attached = true; - ret = viewer_session_set_trace_chunk(vsession, + ret = viewer_session_set_trace_chunk_copy(vsession, session->current_trace_chunk); if (ret) { /* @@ -204,25 +226,3 @@ end: pthread_mutex_unlock(&session->lock); return found; } - -int viewer_session_set_trace_chunk(struct relay_viewer_session *vsession, - struct lttng_trace_chunk *relay_session_trace_chunk) -{ - int ret = 0; - struct lttng_trace_chunk *viewer_chunk; - - assert(relay_session_trace_chunk); - assert(!vsession->current_trace_chunk); - - DBG("Copying relay session's current trace chunk to the viewer session"); - viewer_chunk = lttng_trace_chunk_copy(relay_session_trace_chunk); - if (!viewer_chunk) { - ERR("Failed to create a viewer trace chunk from the relay session's current chunk"); - ret = -1; - goto end; - } - - vsession->current_trace_chunk = viewer_chunk; -end: - return ret; -} diff --git a/src/bin/lttng-relayd/viewer-session.h b/src/bin/lttng-relayd/viewer-session.h index 5c8b2e54d..d57337926 100644 --- a/src/bin/lttng-relayd/viewer-session.h +++ b/src/bin/lttng-relayd/viewer-session.h @@ -55,7 +55,5 @@ int viewer_session_is_attached(struct relay_viewer_session *vsession, struct relay_session *session); void viewer_session_close_one_session(struct relay_viewer_session *vsession, struct relay_session *session); -int viewer_session_set_trace_chunk(struct relay_viewer_session *vsession, - struct lttng_trace_chunk *relay_session_trace_chunk); #endif /* _VIEWER_SESSION_H */