diff options
author | Christian Pointner <equinox@helsinki.at> | 2010-02-11 09:23:48 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2010-02-11 09:23:48 (GMT) |
commit | 877d9404c2354ea825400b68e737cfa7429c8ad1 (patch) | |
tree | 611d685e5b6a3b610b7729ff1414cc7ac2a7ec57 | |
parent | 3bcdcbca5f992232ff3c95487a46e10942e459d4 (diff) |
added --max-children to options parser
-rw-r--r-- | doc/rhdropbox.8.txt | 3 | ||||
-rw-r--r-- | options.c | 12 | ||||
-rw-r--r-- | options.h | 1 |
3 files changed, 16 insertions, 0 deletions
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 ----------------- @@ -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] <unix sock> the command socket e.g. /var/run/rhdropbox/cmd.sock\n"); printf(" [-x|--script] <script> the command socket e.g. newfile.sh\n"); + printf(" [-m|--max-children] <#of children> limit of children to be started e.g. 8\n"); } void options_print(options_t* opt) @@ -262,4 +273,5 @@ void options_print(options_t* opt) printf("command_sock: '%s'\n", opt->command_sock_); printf("script: '%s'\n", opt->script_); + printf("max_children: %d\n", opt->max_children_); } @@ -35,6 +35,7 @@ struct options_struct { char* command_sock_; char* script_; + int max_children_; }; typedef struct options_struct options_t; |