Fix: relayd close stream command was not working
[lttng-tools.git] / src / bin / lttng-relayd / main.c
index d01491e9cbb400257892a913ee2aab590783b9af..60908bfedc5aad85ed309b6be98d3560e831b18e 100644 (file)
@@ -1046,6 +1046,7 @@ int relay_close_stream(struct lttcomm_relayd_hdr *recv_hdr,
                goto end_unlock;
        }
 
+       stream->last_net_seq_num = be64toh(stream_info.last_net_seq_num);
        stream->close_flag = 1;
 
        if (close_stream_check(stream)) {
@@ -1265,7 +1266,7 @@ static
 int relay_send_version(struct lttcomm_relayd_hdr *recv_hdr,
                struct relay_command *cmd)
 {
-       int ret = htobe32(LTTNG_OK);
+       int ret;
        struct lttcomm_relayd_version reply;
        struct relay_session *session;
 
@@ -1284,7 +1285,12 @@ int relay_send_version(struct lttcomm_relayd_hdr *recv_hdr,
        }
        session->version_check_done = 1;
 
-       sscanf(VERSION, "%u.%u", &reply.major, &reply.minor);
+       ret = sscanf(VERSION, "%u.%u", &reply.major, &reply.minor);
+       if (ret < 2) {
+               ERR("Error in scanning version");
+               ret = -1;
+               goto end;
+       }
        reply.major = htobe32(reply.major);
        reply.minor = htobe32(reply.minor);
        ret = cmd->sock->ops->sendmsg(cmd->sock, &reply,
@@ -1402,14 +1408,14 @@ int relay_process_data(struct relay_command *cmd, struct lttng_ht *streams_ht)
                goto end_unlock;
        }
 
+       DBG2("Relay wrote %d bytes to tracefile for stream id %" PRIu64,
+                       ret, stream->stream_handle);
+
        ret = write_padding_to_file(stream->fd, be32toh(data_hdr.padding_size));
        if (ret < 0) {
                goto end_unlock;
        }
 
-       DBG2("Relay wrote %d bytes to tracefile for stream id %" PRIu64,
-               ret, stream->stream_handle);
-
        stream->prev_seq = net_seq_num;
 
        /* Check if we need to close the FD */
This page took 0.023978 seconds and 4 git commands to generate.