#include <sys/stat.h>
#include <inttypes.h>
-#include <common/common.h>
-#include <common/defaults.h>
-#include <common/compat/endian.h>
-#include <common/compat/string.h>
-#include <common/sessiond-comm/relayd.h>
-#include <common/index/ctf-index.h>
-#include <common/trace-chunk.h>
-#include <common/string-utils/format.h>
+#include <common/common.hpp>
+#include <common/defaults.hpp>
+#include <common/compat/endian.hpp>
+#include <common/compat/string.hpp>
+#include <common/sessiond-comm/relayd.hpp>
+#include <common/index/ctf-index.hpp>
+#include <common/trace-chunk.hpp>
+#include <common/string-utils/format.hpp>
-#include "relayd.h"
+#include "relayd.hpp"
static
bool relayd_supports_chunks(const struct lttcomm_relayd_sock *sock)
buf_size += size;
}
- buf = (char *) zmalloc(buf_size);
+ buf = calloc<char>(buf_size);
if (buf == NULL) {
PERROR("zmalloc relayd send command buf");
ret = -1;
memcpy(buf + sizeof(header), data, size);
}
- DBG3("Relayd sending command %d of size %" PRIu64, (int) cmd, buf_size);
+ DBG3("Relayd sending command %s of size %" PRIu64,
+ lttcomm_relayd_command_str(cmd), buf_size);
ret = rsock->sock.ops->sendmsg(&rsock->sock, buf, buf_size, flags);
if (ret < 0) {
- PERROR("Failed to send command %d of size %" PRIu64,
- (int) cmd, buf_size);
+ PERROR("Failed to send command %s of size %" PRIu64,
+ lttcomm_relayd_command_str(cmd), buf_size);
+ ret = rsock->sock.ops->sendmsg(&rsock->sock, buf, buf_size, flags);
ret = -errno;
goto error;
}
const char *session_name, const char *hostname,
const char *base_path, int session_live_timer,
unsigned int snapshot, uint64_t sessiond_session_id,
- const lttng_uuid sessiond_uuid, const uint64_t *current_chunk_id,
+ const lttng_uuid& sessiond_uuid, const uint64_t *current_chunk_id,
time_t creation_time, bool session_name_contains_creation_time,
struct lttcomm_relayd_create_session_reply_2_11 *reply,
char *output_path)
base_path_len = strlen(base_path) + 1;
msg_length = sizeof(*msg) + session_name_len + hostname_len + base_path_len;
- msg = (lttcomm_relayd_create_session_2_11 *) zmalloc(msg_length);
+ msg = zmalloc<lttcomm_relayd_create_session_2_11>(msg_length);
if (!msg) {
PERROR("zmalloc create_session_2_11 command message");
ret = -1;
msg->live_timer = htobe32(session_live_timer);
msg->snapshot = !!snapshot;
- lttng_uuid_copy(msg->sessiond_uuid, sessiond_uuid);
+ std::copy(sessiond_uuid.begin(), sessiond_uuid.end(), msg->sessiond_uuid);
msg->session_id = htobe64(sessiond_session_id);
msg->session_name_contains_creation_time = session_name_contains_creation_time;
if (current_chunk_id) {
const char *session_name, const char *hostname,
const char *base_path, int session_live_timer,
unsigned int snapshot, uint64_t sessiond_session_id,
- const lttng_uuid sessiond_uuid,
+ const lttng_uuid& sessiond_uuid,
const uint64_t *current_chunk_id,
time_t creation_time, bool session_name_contains_creation_time,
char *output_path)
pathname_len = strlen(pathname) + 1;
msg_length = sizeof(*msg) + channel_name_len + pathname_len;
- msg = (lttcomm_relayd_add_stream_2_11 *) zmalloc(msg_length);
+ msg = zmalloc<lttcomm_relayd_add_stream_2_11>(msg_length);
if (!msg) {
PERROR("zmalloc add_stream_2_11 command message");
ret = -1;