Fix: tests: start relayd in background mode (-b)
[lttng-tools.git] / src / bin / lttng-relayd / main.c
index 7e5733ec8c3253432bd61dbac17b0968fefef21a..7ac5630fb9790262b7355df43f7066deadfb671b 100644 (file)
@@ -63,7 +63,7 @@
 
 /* command line options */
 char *opt_output_path;
-static int opt_daemon;
+static int opt_daemon, opt_background;
 static struct lttng_uri *control_uri;
 static struct lttng_uri *data_uri;
 static struct lttng_uri *live_uri;
@@ -131,6 +131,7 @@ static struct option long_options[] = {
        { "data-port", 1, 0, 'D', },
        { "live-port", 1, 0, 'L', },
        { "daemonize", 0, 0, 'd', },
+       { "background", 0, 0, 'b', },
        { "group", 1, 0, 'g', },
        { "help", 0, 0, 'h', },
        { "output", 1, 0, 'o', },
@@ -150,6 +151,7 @@ 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, "  -b, --background          Start as a daemon, keeping console open.\n");
        fprintf(stderr, "  -C, --control-port URL    Control port listening.\n");
        fprintf(stderr, "  -D, --data-port URL       Data port listening.\n");
        fprintf(stderr, "  -L, --live-port URL       Live view port listening.\n");
@@ -210,6 +212,9 @@ int set_option(int opt, const char *arg, const char *optname)
        case 'd':
                opt_daemon = 1;
                break;
+       case 'b':
+               opt_background = 1;
+               break;
        case 'g':
                tracing_group_name = strdup(arg);
                tracing_group_name_override = 1;
@@ -1166,18 +1171,10 @@ void set_viewer_ready_flag(struct relay_command *cmd)
                         * Stream is most probably being cleaned up by the data thread thus
                         * simply continue to the next one.
                         */
+                       rcu_read_unlock();
                        continue;
                }
 
-               /*
-                * If any of the streams in the list doesn't have a ctf_trace assigned,
-                * it means that we never received the metadata stream, so we have to
-                * wait until it arrives to make the streams available to the viewer.
-                */
-               if (!stream->ctf_trace) {
-                       goto end;
-               }
-
                stream->viewer_ready = 1;
                rcu_read_unlock();
 
@@ -1186,7 +1183,6 @@ void set_viewer_ready_flag(struct relay_command *cmd)
                free(node);
        }
 
-end:
        return;
 }
 
@@ -1308,7 +1304,11 @@ int relay_add_stream(struct lttcomm_relayd_hdr *recv_hdr,
         * stream message is received, this list is emptied and streams are set
         * with the viewer ready flag.
         */
-       queue_stream_handle(stream->stream_handle, cmd);
+       if (stream->metadata_flag) {
+               stream->viewer_ready = 1;
+       } else {
+               queue_stream_handle(stream->stream_handle, cmd);
+       }
 
        lttng_ht_node_init_ulong(&stream->stream_n,
                        (unsigned long) stream->stream_handle);
@@ -2852,8 +2852,8 @@ int main(int argc, char **argv)
        }
 
        /* Daemonize */
-       if (opt_daemon) {
-               ret = daemon(0, 0);
+       if (opt_daemon || opt_background) {
+               ret = daemon(0, opt_background);
                if (ret < 0) {
                        PERROR("daemon");
                        goto exit;
@@ -2886,6 +2886,7 @@ int main(int argc, char **argv)
 
        /* Initialize communication library */
        lttcomm_init();
+       lttcomm_inet_init();
 
        relay_ctx = zmalloc(sizeof(struct relay_local_data));
        if (!relay_ctx) {
This page took 0.027764 seconds and 5 git commands to generate.