From 877d9404c2354ea825400b68e737cfa7429c8ad1 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Thu, 11 Feb 2010 09:23:48 +0000 Subject: added --max-children to options parser diff --git a/doc/rhdropbox.8.txt b/doc/rhdropbox.8.txt index 843ab2a..da95a82 100644 --- a/doc/rhdropbox.8.txt +++ b/doc/rhdropbox.8.txt @@ -88,6 +88,9 @@ The following options can be passed to the *rhdropbox* daemon: consider a file to be complete when it size doesn't change 3-5seconds after the event got received. +*-m|--max-children <#of children>*:: + Limits the total concurrent executions of *-x|--script*. A value of 0 means no limit. + COMMAND INTERFACE ----------------- diff --git a/options.c b/options.c index 93e01ad..d567891 100644 --- a/options.c +++ b/options.c @@ -174,6 +174,7 @@ int options_parse(options_t* opt, int argc, char* argv[]) PARSE_STRING_LIST("-L","--log", opt->log_targets_) PARSE_STRING_PARAM("-s","--command-sock", opt->command_sock_) PARSE_STRING_PARAM("-x","--script", opt->script_) + PARSE_INT_PARAM("-m","--max-children", opt->max_children_) else return i; } @@ -186,6 +187,14 @@ int options_parse_post(options_t* opt) if(!opt) return -1; + if(opt->max_children_ < 0) { + log_printf(ERROR, "-m|--max-children invalid value %d", opt->max_children_); + return 1; + } + + if(opt->max_children_ == 0) + log_printf(WARNING, "disabling child limit, this may be harmful to your system"); + return 0; } @@ -205,6 +214,7 @@ void options_default(options_t* opt) opt->command_sock_ = strdup("/var/run/rhdropbox/cmd.sock"); opt->script_ = strdup("newfile.sh"); + opt->max_children_ = 8; } void options_clear(options_t* opt) @@ -244,6 +254,7 @@ void options_print_usage() printf(" add a log target, can be invoked several times\n"); printf(" [-s|--command-sock] the command socket e.g. /var/run/rhdropbox/cmd.sock\n"); printf(" [-x|--script]