summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
79a4298)
Viewer streams can be creating while serving a "GET_STREAMS" viewer
client command for a session that is being destroyed. If this happens,
the viewer streams will be created with a NULL viewer trace chunk,
which would result in a crash.
The fix consists in returning a stream error when such a command
happens during the destruction of a session. This is the same
behaviour than if the session could not be found at all, introducing
no meaningful change in behaviour from the viewer's perspective.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
}
if (!viewer_session_is_attached(conn->viewer_session, session)) {
}
if (!viewer_session_is_attached(conn->viewer_session, session)) {
response.status = htobe32(LTTNG_VIEWER_NEW_STREAMS_ERR);
goto send_reply;
}
response.status = htobe32(LTTNG_VIEWER_NEW_STREAMS_ERR);
goto send_reply;
}
- send_streams = 1;
- response.status = htobe32(LTTNG_VIEWER_NEW_STREAMS_OK);
-
pthread_mutex_lock(&session->lock);
pthread_mutex_lock(&session->lock);
+ if (!session->current_trace_chunk) {
+ /*
+ * Means the session is being destroyed. React the same way
+ * as if it could not be found at all.
+ */
+ DBG("Relay session %" PRIu64 " has no current trace chunk, replying LTTNG_VIEWER_NEW_STREAMS_ERR",
+ session_id);
+ response.status = htobe32(LTTNG_VIEWER_NEW_STREAMS_ERR);
+ goto send_reply_unlock;
+ }
+
if (!conn->viewer_session->current_trace_chunk &&
session->current_trace_chunk) {
ret = viewer_session_set_trace_chunk(conn->viewer_session,
if (!conn->viewer_session->current_trace_chunk &&
session->current_trace_chunk) {
ret = viewer_session_set_trace_chunk(conn->viewer_session,
if (ret < 0) {
goto error_unlock_session;
}
if (ret < 0) {
goto error_unlock_session;
}
- pthread_mutex_unlock(&session->lock);
+ send_streams = 1;
+ response.status = htobe32(LTTNG_VIEWER_NEW_STREAMS_OK);
/* Only send back the newly created streams with the unsent ones. */
nb_streams = nb_created + nb_unsent;
/* Only send back the newly created streams with the unsent ones. */
nb_streams = nb_created + nb_unsent;
send_streams = 0;
response.streams_count = 0;
response.status = htobe32(LTTNG_VIEWER_NEW_STREAMS_HUP);
send_streams = 0;
response.streams_count = 0;
response.status = htobe32(LTTNG_VIEWER_NEW_STREAMS_HUP);
+ goto send_reply_unlock;
+send_reply_unlock:
+ pthread_mutex_unlock(&session->lock);
send_reply:
health_code_update();
send_reply:
health_code_update();