X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-relayd%2Fmain.c;h=bb038a670b0a763afd41b1343cbbb1e919fbe1f7;hp=156fc83ee6d534599bbb6d44a1b747099eeb08c2;hb=309167d2a6f59d0c8cbf64eb23ba912cdea76a34;hpb=be96a7d15e24cd8742c404cf3a76d14c75b00f06 diff --git a/src/bin/lttng-relayd/main.c b/src/bin/lttng-relayd/main.c index 156fc83ee..bb038a670 100644 --- a/src/bin/lttng-relayd/main.c +++ b/src/bin/lttng-relayd/main.c @@ -105,12 +105,12 @@ static void usage(void) { fprintf(stderr, "Usage: %s OPTIONS\n\nOptions:\n", progname); - fprintf(stderr, " -h, --help Display this usage.\n"); - fprintf(stderr, " -d, --daemonize Start as a daemon.\n"); - fprintf(stderr, " -C, --control-port Control port listening (URI)\n"); - fprintf(stderr, " -D, --data-port Data port listening (URI)\n"); - fprintf(stderr, " -o, --output Output path for traces (PATH)\n"); - fprintf(stderr, " -v, --verbose Verbose mode. Activate DBG() macro.\n"); + fprintf(stderr, " -h, --help Display this usage.\n"); + fprintf(stderr, " -d, --daemonize Start as a daemon.\n"); + fprintf(stderr, " -C, --control-port URL Control port listening.\n"); + fprintf(stderr, " -D, --data-port URL Data port listening.\n"); + fprintf(stderr, " -o, --output PATH Output path for traces. Must use an absolute path.\n"); + fprintf(stderr, " -v, --verbose Verbose mode. Activate DBG() macro.\n"); } static @@ -868,7 +868,7 @@ int relay_add_stream(struct lttcomm_relayd_hdr *recv_hdr, * uses its own credentials for the stream files. */ ret = utils_create_stream_file(stream->path_name, stream->channel_name, - stream->tracefile_size, 0, -1, -1); + stream->tracefile_size, 0, -1, -1, NULL); if (ret < 0) { ERR("Create output file"); goto end; @@ -1187,12 +1187,8 @@ int relay_send_version(struct lttcomm_relayd_hdr *recv_hdr, goto end; } - ret = sscanf(VERSION, "%10u.%10u", &reply.major, &reply.minor); - if (ret < 2) { - ERR("Error in scanning version"); - ret = -1; - goto end; - } + reply.major = RELAYD_VERSION_COMM_MAJOR; + reply.minor = RELAYD_VERSION_COMM_MINOR; /* Major versions must be the same */ if (reply.major != be32toh(msg.major)) { @@ -1630,12 +1626,15 @@ int relay_process_data(struct relay_command *cmd, struct lttng_ht *streams_ht) ret = utils_rotate_stream_file(stream->path_name, stream->channel_name, stream->tracefile_size, stream->tracefile_count, -1, -1, - stream->fd, &(stream->tracefile_count_current)); + stream->fd, &(stream->tracefile_count_current), + &stream->fd); if (ret < 0) { ERR("Rotating output file"); goto end; } stream->fd = ret; + /* Reset current size because we just perform a stream rotation. */ + stream->tracefile_size_current = 0; } stream->tracefile_size_current += data_size; do { @@ -2069,6 +2068,11 @@ int main(int argc, char **argv) /* Try to create directory if -o, --output is specified. */ if (opt_output_path) { + if (*opt_output_path != '/') { + ERR("Please specify an absolute path for -o, --output PATH"); + goto exit; + } + ret = utils_mkdir_recursive(opt_output_path, S_IRWXU | S_IRWXG); if (ret < 0) { ERR("Unable to create %s", opt_output_path); @@ -2107,6 +2111,9 @@ int main(int argc, char **argv) /* Set up max poll set size */ lttng_poll_set_max_size(); + /* Initialize communication library */ + lttcomm_init(); + /* Setup the dispatcher thread */ ret = pthread_create(&dispatcher_thread, NULL, relay_thread_dispatcher, (void *) NULL);