uloop_process_add(&c->process);
c->timeout.cb = rpc_exec_timeout_cb;
- uloop_timeout_set(&c->timeout, RPC_EXEC_MAX_RUNTIME);
+ uloop_timeout_set(&c->timeout, exec_timeout);
if (c->stdin_cb)
{
#include <libubox/ustream.h>
#define RPC_EXEC_MAX_SIZE (4096 * 64)
-#define RPC_EXEC_MAX_RUNTIME (30 * 1000)
+#define RPC_EXEC_DEFAULT_TIMEOUT (120 * 1000)
#define ustream_for_each_read_buffer(stream, ptr, len) \
for (ptr = ustream_get_read_buf(stream, &len); \
ustream_fd_init(&us, fd); \
} while(0)
+extern int exec_timeout;
typedef int (*rpc_exec_write_cb_t)(struct ustream *, void *);
typedef int (*rpc_exec_read_cb_t)(struct blob_buf *, char *, int, void *);
*/
#include <unistd.h>
+#include <stdlib.h>
#include <libubox/blobmsg_json.h>
#include <libubus.h>
static struct ubus_context *ctx;
static bool respawn = false;
+int exec_timeout = RPC_EXEC_DEFAULT_TIMEOUT;
+
static void
handle_signal(int sig)
{
const char *ubus_socket = NULL;
int ch;
- 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':
+ exec_timeout = strtol(optarg, NULL, 0);
+ break;
+
default:
break;
}
}
+ if (exec_timeout < 1 || exec_timeout > 600) {
+ fprintf(stderr, "Invalid execution timeout specified\n");
+ return -1;
+ }
+
+ exec_timeout *= 1000;
+
if (stat(RPC_UCI_DIR_PREFIX, &s))
mkdir(RPC_UCI_DIR_PREFIX, 0700);