Live: send the number of streams in list_sessions
authorJulien Desfossez <jdesfossez@efficios.com>
Wed, 6 Nov 2013 16:38:51 +0000 (11:38 -0500)
committerDavid Goulet <dgoulet@efficios.com>
Wed, 6 Nov 2013 20:39:09 +0000 (15:39 -0500)
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 <jdesfossez@efficios.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
src/bin/lttng-relayd/live.c
src/bin/lttng-relayd/lttng-viewer.h
src/bin/lttng-relayd/main.c

index 26d6e33d505447918e659255faee54b129ede6c7..86dc2ff7bba5ca619a888d3ba39e05ffcbf5c6ab 100644 (file)
@@ -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();
 
index 56fa5632db86b6411dc4f2beb88ae9d55058b1f2..79aecd6b3f41d3145a49ce25d8aa327cfd93550b 100644 (file)
@@ -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 {
index f943488be5b94309efd332196bd52e876d2eea1a..1bdef652eb64d7ad60ffb3b582ca540f24a62361 100644 (file)
@@ -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);
This page took 0.029494 seconds and 4 git commands to generate.