cli: do not use default timeout for listen
authorFelix Fietkau <nbd@nbd.name>
Wed, 15 Feb 2017 10:35:35 +0000 (11:35 +0100)
committerFelix Fietkau <nbd@nbd.name>
Wed, 15 Feb 2017 10:35:38 +0000 (11:35 +0100)
Default to listening for events forever unless -t is explicitly
specified on the command line

Signed-off-by: Felix Fietkau <nbd@nbd.name>
cli.c

diff --git a/cli.c b/cli.c
index 624c089..1949a17 100644 (file)
--- a/cli.c
+++ b/cli.c
@@ -17,6 +17,7 @@
 #include "libubus.h"
 
 static struct blob_buf b;
 #include "libubus.h"
 
 static struct blob_buf b;
+static int listen_timeout;
 static int timeout = 30;
 static bool simple_output = false;
 static int verbose = 0;
 static int timeout = 30;
 static bool simple_output = false;
 static int verbose = 0;
@@ -171,7 +172,8 @@ static void do_listen(struct ubus_context *ctx, struct cli_listen_data *data)
        data->timeout.cb = listen_timeout;
        uloop_init();
        ubus_add_uloop(ctx);
        data->timeout.cb = listen_timeout;
        uloop_init();
        ubus_add_uloop(ctx);
-       uloop_timeout_set(&data->timeout, timeout * 1000);
+       if (listen_timeout)
+               uloop_timeout_set(&data->timeout, listen_timeout * 1000);
        uloop_run();
        uloop_done();
 }
        uloop_run();
        uloop_done();
 }
@@ -585,6 +587,7 @@ int main(int argc, char **argv)
                        ubus_socket = optarg;
                        break;
                case 't':
                        ubus_socket = optarg;
                        break;
                case 't':
+                       listen_timeout = atoi(optarg);
                        timeout = atoi(optarg);
                        break;
                case 'S':
                        timeout = atoi(optarg);
                        break;
                case 'S':