diff options
author | Felix Fietkau <nbd@openwrt.org> | 2011-02-11 02:40:39 +0100 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2011-02-11 02:40:39 +0100 |
commit | f2ee96c51d38363092415cc333f8f7a62f16783a (patch) | |
tree | 7e2fc636ff820cc28f71b443cf71da3d1291b58c /cli.c | |
parent | fb45e383c2985c43a9aaf42050fef039473745ce (diff) | |
download | ubus-f2ee96c51d38363092415cc333f8f7a62f16783a.tar.gz |
add support for timeouts on synchronous requests
Diffstat (limited to 'cli.c')
-rw-r--r-- | cli.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -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); } |