summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2010-02-11 09:23:48 +0000
committerChristian Pointner <equinox@helsinki.at>2010-02-11 09:23:48 +0000
commit877d9404c2354ea825400b68e737cfa7429c8ad1 (patch)
tree611d685e5b6a3b610b7729ff1414cc7ac2a7ec57
parentfixed close after recv error (diff)
added --max-children to options parser
-rw-r--r--doc/rhdropbox.8.txt3
-rw-r--r--options.c12
-rw-r--r--options.h1
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
-----------------
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] <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_);
}
diff --git a/options.h b/options.h
index aae2bd7..b29fa96 100644
--- a/options.h
+++ b/options.h
@@ -35,6 +35,7 @@ struct options_struct {
char* command_sock_;
char* script_;
+ int max_children_;
};
typedef struct options_struct options_t;