From: Julien Desfossez Date: Wed, 6 Nov 2013 16:38:51 +0000 (-0500) Subject: Live: send the number of streams in list_sessions X-Git-Tag: v2.4.0-rc1~74 X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=commitdiff_plain;h=87b576ecd158f43c99a16b9c7c2092f7291aee00;hp=43c5442ea57aca20701fd49fba1e3456d48cc7b2 Live: send the number of streams in list_sessions This allows the viewer to quickly know if a session is really active or just created and idle. Before this patch, we had to attach to a session to discover the number of streams active in that session. Signed-off-by: Julien Desfossez Signed-off-by: David Goulet --- diff --git a/src/bin/lttng-relayd/live.c b/src/bin/lttng-relayd/live.c index 26d6e33d5..86dc2ff7b 100644 --- a/src/bin/lttng-relayd/live.c +++ b/src/bin/lttng-relayd/live.c @@ -583,6 +583,7 @@ int viewer_list_sessions(struct relay_command *cmd, send_session.id = htobe64(session->id); send_session.live_timer = htobe32(session->live_timer); send_session.clients = htobe32(session->viewer_attached); + send_session.streams = htobe32(session->stream_count); health_code_update(); diff --git a/src/bin/lttng-relayd/lttng-viewer.h b/src/bin/lttng-relayd/lttng-viewer.h index 56fa5632d..79aecd6b3 100644 --- a/src/bin/lttng-relayd/lttng-viewer.h +++ b/src/bin/lttng-relayd/lttng-viewer.h @@ -90,6 +90,7 @@ struct lttng_viewer_session { char session_name[LTTNG_VIEWER_NAME_MAX]; uint32_t live_timer; uint32_t clients; + uint32_t streams; } __attribute__((__packed__)); struct lttng_viewer_stream { diff --git a/src/bin/lttng-relayd/main.c b/src/bin/lttng-relayd/main.c index f943488be..1bdef652e 100644 --- a/src/bin/lttng-relayd/main.c +++ b/src/bin/lttng-relayd/main.c @@ -898,6 +898,8 @@ void relay_delete_session(struct relay_command *cmd, stream = caa_container_of(node, struct relay_stream, stream_n); if (stream->session == cmd->session) { destroy_stream(stream); + cmd->session->stream_count--; + assert(cmd->session->stream_count >= 0); } } @@ -1094,6 +1096,7 @@ int relay_add_stream(struct lttcomm_relayd_hdr *recv_hdr, lttng_ht_node_init_str(&stream->ctf_trace_node, stream->path_name); lttng_ht_add_str(cmd->ctf_traces_ht, &stream->ctf_trace_node); + session->stream_count++; DBG("Relay new stream added %s with ID %" PRIu64, stream->channel_name, stream->stream_handle); @@ -1170,6 +1173,8 @@ int relay_close_stream(struct lttcomm_relayd_hdr *recv_hdr, stream->last_net_seq_num = be64toh(stream_info.last_net_seq_num); stream->close_flag = 1; + session->stream_count--; + assert(session->stream_count >= 0); if (close_stream_check(stream)) { destroy_stream(stream);