From: David Goulet Date: Wed, 25 Jul 2012 20:59:30 +0000 (-0400) Subject: Fix: Off by uint64_t in the metadata transfer X-Git-Tag: v2.1.0-rc1~46 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=87c1611dab332f28b4b72c6ed96cb2a2ef31d5f7;p=lttng-tools.git Fix: Off by uint64_t in the metadata transfer This patch also adds a couple of debug output along with this fix. Signed-off-by: David Goulet --- diff --git a/src/bin/lttng-relayd/main.c b/src/bin/lttng-relayd/main.c index abefba865..f0663d10d 100644 --- a/src/bin/lttng-relayd/main.c +++ b/src/bin/lttng-relayd/main.c @@ -1071,7 +1071,12 @@ int relay_recv_metadata(struct lttcomm_relayd_hdr *recv_hdr, } data_size = be64toh(recv_hdr->data_size); - payload_size = data_size - sizeof(uint64_t); + payload_size = data_size; + /* + * Add 8 bytes (uint64_t) to the data size which is the value of the + * stream_id and the payload size. + */ + data_size += sizeof(uint64_t); if (data_buffer_size < data_size) { data_buffer = realloc(data_buffer, data_size); if (!data_buffer) { @@ -1083,7 +1088,8 @@ int relay_recv_metadata(struct lttcomm_relayd_hdr *recv_hdr, } memset(data_buffer, 0, data_size); DBG2("Relay receiving metadata, waiting for %lu bytes", data_size); - ret = cmd->sock->ops->recvmsg(cmd->sock, data_buffer, data_size, MSG_WAITALL); + ret = cmd->sock->ops->recvmsg(cmd->sock, data_buffer, data_size, + MSG_WAITALL); if (ret < 0 || ret != data_size) { ret = -1; ERR("Relay didn't receive the whole metadata"); @@ -1103,7 +1109,7 @@ int relay_recv_metadata(struct lttcomm_relayd_hdr *recv_hdr, ret = write(metadata_stream->fd, metadata_struct->payload, payload_size); } while (ret < 0 && errno == EINTR); - if (ret < (payload_size)) { + if (ret < payload_size) { ERR("Relay error writing metadata on file"); ret = -1; goto end_unlock; @@ -1234,6 +1240,7 @@ int relay_process_data(struct relay_command *cmd, struct lttng_ht *streams_ht) } memset(data_buffer, 0, data_size); + DBG3("Receiving data of size %u for stream id %zu", data_size, stream_id); ret = cmd->sock->ops->recvmsg(cmd->sock, data_buffer, data_size, MSG_WAITALL); if (ret <= 0) { ret = -1; @@ -1377,6 +1384,7 @@ void *relay_thread_worker(void *data) /* Infinite blocking call, waiting for transmission */ restart: + DBG3("Relayd worker thread polling..."); ret = lttng_poll_wait(&events, -1); if (ret < 0) { /* diff --git a/src/common/ust-consumer/ust-consumer.c b/src/common/ust-consumer/ust-consumer.c index 4cd697212..a57bf1598 100644 --- a/src/common/ust-consumer/ust-consumer.c +++ b/src/common/ust-consumer/ust-consumer.c @@ -63,7 +63,8 @@ ssize_t lttng_ustconsumer_on_read_subbuffer_mmap( if (stream->net_seq_idx != -1) { relayd = consumer_find_relayd(stream->net_seq_idx); if (relayd == NULL) { - ERR("Cannot find relay for network stream\n"); + ERR("UST consumer mmap(), unable to find relay for index %d", + stream->net_seq_idx); goto end; } }