Fix: handle session hang up in get_new_streams
authorJulien Desfossez <jdesfossez@efficios.com>
Thu, 30 Jan 2014 22:08:31 +0000 (17:08 -0500)
committerDavid Goulet <dgoulet@efficios.com>
Tue, 11 Feb 2014 19:57:09 +0000 (14:57 -0500)
Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
src/bin/lttng-relayd/live.c
src/bin/lttng-relayd/lttng-viewer-abi.h

index b2e8e7c8bb1305b07c121172ecb1d2e760339348..91d870493c9052eef6129c0a0396de9c8cf68ad8 100644 (file)
@@ -868,6 +868,17 @@ int viewer_get_new_streams(struct relay_connection *conn)
        nb_streams = nb_created + nb_unsent;
        response.streams_count = htobe32(nb_streams);
 
+       /*
+        * If the session is closed and we have no new streams to send,
+        * it means that the viewer has already received the whole trace
+        * for this session and should now close it.
+        */
+       if (nb_streams == 0 && session->close_flag) {
+               send_streams = 0;
+               response.status = htobe32(LTTNG_VIEWER_NEW_STREAMS_HUP);
+               goto send_reply;
+       }
+
 send_reply:
        health_code_update();
        ret = send_response(conn->sock, &response, sizeof(response));
index aa073c4e05cfe63cae4a87865924bf8f47b5e304..e1ea8a3e581bcce3c63f2feafb3def969fa6690f 100644 (file)
@@ -97,6 +97,7 @@ enum lttng_viewer_new_streams_return_code {
        LTTNG_VIEWER_NEW_STREAMS_OK           = 1, /* If new streams are being sent. */
        LTTNG_VIEWER_NEW_STREAMS_NO_NEW       = 2, /* If no new streams are available. */
        LTTNG_VIEWER_NEW_STREAMS_ERR          = 3, /* Error. */
+       LTTNG_VIEWER_NEW_STREAMS_HUP          = 4, /* Session closed. */
 };
 
 enum lttng_viewer_create_session_return_code {
This page took 0.030183 seconds and 4 git commands to generate.