Fix: Remove useless consumer subdir string concatenation
[lttng-tools.git] / src / bin / lttng-relayd / main.c
index 0f81d556dd4df73a910471756b75cf6567581a36..9e6d4bf9fa594dc2f51e93ee2f918360acf994c8 100644 (file)
@@ -1208,9 +1208,12 @@ int relay_recv_metadata(struct lttcomm_relayd_hdr *recv_hdr,
        payload_size -= sizeof(struct lttcomm_relayd_metadata_payload);
 
        if (data_buffer_size < data_size) {
+               /* In case the realloc fails, we can free the memory */
+               char *tmp_data_ptr = data_buffer;
                data_buffer = realloc(data_buffer, data_size);
                if (!data_buffer) {
                        ERR("Allocating data buffer");
+                       free(tmp_data_ptr);
                        ret = -1;
                        goto end;
                }
@@ -1355,7 +1358,8 @@ int relay_data_available(struct lttcomm_relayd_hdr *recv_hdr,
                        " and last_seq %" PRIu64, stream_id, stream->prev_seq,
                        last_net_seq_num);
 
-       if (stream->prev_seq == -1UL || stream->prev_seq <= last_net_seq_num) {
+       /* Avoid wrapping issue */
+       if (((int64_t) (stream->prev_seq - last_net_seq_num)) <= 0) {
                /* Data has in fact been written and is available */
                ret = 1;
        } else {
@@ -1481,9 +1485,11 @@ int relay_process_data(struct relay_command *cmd, struct lttng_ht *streams_ht)
 
        data_size = be32toh(data_hdr.data_size);
        if (data_buffer_size < data_size) {
+               char *tmp_data_ptr = data_buffer;
                data_buffer = realloc(data_buffer, data_size);
                if (!data_buffer) {
                        ERR("Allocating data buffer");
+                       free(tmp_data_ptr);
                        ret = -1;
                        goto end_unlock;
                }
This page took 0.024106 seconds and 5 git commands to generate.