summaryrefslogtreecommitdiff
path: root/cli.c
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2011-02-11 02:40:39 +0100
committerFelix Fietkau <nbd@openwrt.org>2011-02-11 02:40:39 +0100
commitf2ee96c51d38363092415cc333f8f7a62f16783a (patch)
tree7e2fc636ff820cc28f71b443cf71da3d1291b58c /cli.c
parentfb45e383c2985c43a9aaf42050fef039473745ce (diff)
downloadubus-f2ee96c51d38363092415cc333f8f7a62f16783a.tar.gz
add support for timeouts on synchronous requests
Diffstat (limited to 'cli.c')
-rw-r--r--cli.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/cli.c b/cli.c
index d020b8e..76fb0c4 100644
--- a/cli.c
+++ b/cli.c
@@ -4,6 +4,7 @@
#include "libubus.h"
static struct blob_buf b;
+static int timeout = 30;
static const char *format_type(void *priv, struct blob_attr *attr)
{
@@ -96,7 +97,7 @@ static int ubus_cli_call(struct ubus_context *ctx, int argc, char **argv)
if (ret)
return ret;
- return ubus_invoke(ctx, id, argv[1], b.head, receive_call_result_data, NULL);
+ return ubus_invoke(ctx, id, argv[1], b.head, receive_call_result_data, NULL, timeout * 1000);
}
static int ubus_cli_listen(struct ubus_context *ctx, int argc, char **argv)
@@ -194,11 +195,14 @@ int main(int argc, char **argv)
progname = argv[0];
- while ((ch = getopt(argc, argv, "s:")) != -1) {
+ while ((ch = getopt(argc, argv, "s:t:")) != -1) {
switch (ch) {
case 's':
ubus_socket = optarg;
break;
+ case 't':
+ timeout = atoi(optarg);
+ break;
default:
return usage(progname);
}