X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Flib%2Flttng-ctl%2Fchannel.cpp;h=3613f1b1cde5e1912edead013894811660d4c5a7;hb=57fb67ac49ded29a2c1886529ae55f55999e5f71;hp=e7b044ac05aafad89f3ff9af02e611619b8b8b3c;hpb=4bd69c5f1161cd065f487da0f4c1aa03a73c47e4;p=lttng-tools.git diff --git a/src/lib/lttng-ctl/channel.cpp b/src/lib/lttng-ctl/channel.cpp index e7b044ac0..3613f1b1c 100644 --- a/src/lib/lttng-ctl/channel.cpp +++ b/src/lib/lttng-ctl/channel.cpp @@ -5,20 +5,20 @@ * */ -#include -#include -#include +#include +#include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include "lttng-ctl-helper.h" -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "lttng-ctl-helper.hpp" +#include static int handshake(struct lttng_notification_channel *channel); @@ -53,6 +53,10 @@ int receive_message(struct lttng_notification_channel *channel) goto error; } + if (msg.size == 0) { + goto skip_payload; + } + /* Reserve space for the payload. */ ret = lttng_dynamic_buffer_set_size(&channel->reception_payload.buffer, channel->reception_payload.buffer.size + msg.size); @@ -68,6 +72,7 @@ int receive_message(struct lttng_notification_channel *channel) goto error; } +skip_payload: /* Receive message fds. */ if (msg.fds != 0) { ret = lttcomm_recv_payload_fds_unix_sock(channel->socket, @@ -143,12 +148,12 @@ struct lttng_notification_channel *lttng_notification_channel_create( goto end; } - sock_path = (char *) zmalloc(LTTNG_PATH_MAX); + sock_path = calloc(LTTNG_PATH_MAX); if (!sock_path) { goto end; } - channel = (lttng_notification_channel *) zmalloc(sizeof(struct lttng_notification_channel)); + channel = zmalloc(); if (!channel) { goto end; } @@ -343,7 +348,7 @@ int enqueue_dropped_notification( goto end; } - pending_notification = (struct pending_notification *) zmalloc(sizeof(*pending_notification)); + pending_notification = zmalloc(); if (!pending_notification) { ret = -1; goto end; @@ -371,7 +376,7 @@ int enqueue_notification_from_current_message( goto end; } - pending_notification = (struct pending_notification *) zmalloc(sizeof(*pending_notification)); + pending_notification = zmalloc(); if (!pending_notification) { ret = -1; goto error; @@ -572,12 +577,13 @@ int handshake(struct lttng_notification_channel *channel) .major = LTTNG_NOTIFICATION_CHANNEL_VERSION_MAJOR, .minor = LTTNG_NOTIFICATION_CHANNEL_VERSION_MINOR, }; - struct lttng_notification_channel_message msg_header = { - .type = LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_HANDSHAKE, - .size = sizeof(handshake), - }; + struct lttng_notification_channel_message msg_header; char send_buffer[sizeof(msg_header) + sizeof(handshake)]; + msg_header.type = LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_HANDSHAKE; + msg_header.size = sizeof(handshake); + msg_header.fds = 0; + memcpy(send_buffer, &msg_header, sizeof(msg_header)); memcpy(send_buffer + sizeof(msg_header), &handshake, sizeof(handshake)); @@ -621,9 +627,11 @@ enum lttng_notification_channel_status send_condition_command( enum lttng_notification_channel_status status = LTTNG_NOTIFICATION_CHANNEL_STATUS_OK; struct lttng_payload payload; - struct lttng_notification_channel_message cmd_header = { - .type = (int8_t) type, - }; + struct lttng_notification_channel_message cmd_header; + + cmd_header.type = (int8_t) type; + cmd_header.size = 0; + cmd_header.fds = 0; lttng_payload_init(&payload);