aboutsummaryrefslogtreecommitdiff
path: root/src/pies.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2009-11-24 18:34:29 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2009-11-24 18:34:29 +0200
commita7779d56bb758157e122a420a56f2d7b4475e554 (patch)
tree98241b97aa36b7713b2a76677b387cf214a1dbb7 /src/pies.c
parente6772c4d68849cfdb4547a59bc51cb6dd0acd2c6 (diff)
downloadpies-a7779d56bb758157e122a420a56f2d7b4475e554.tar.gz
pies-a7779d56bb758157e122a420a56f2d7b4475e554.tar.bz2
Implement inetd connection rate.
* src/pies.h (struct component): New member "max_rate". (default_max_rate): New extern. * src/progman.c (check_rate): New function. (check_spawn_rate, check_connection_rate): New functions. (prog_open_socket): New function. (prog_start): Rewrite using the above functions. (_prog_accept): Check connection rate. (progman_start): Special handling for inetd listeners. (progman_wake_sleeping): Likewise. * src/pies.c (default_max_rate): New global. (component_keywords): New keyword max-rate. (options): New option "rate". (parse_opt): Handle the new option. * src/inetd.c (inetd_conf_file): Set max_rate, instead of max_instances.
Diffstat (limited to 'src/pies.c')
-rw-r--r--src/pies.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/pies.c b/src/pies.c
index fd83e04..74e71f7 100644
--- a/src/pies.c
+++ b/src/pies.c
@@ -34,6 +34,7 @@ char *ctlfile = LOCALSTATEDIR "/pies.ctl";
char *statfile = LOCALSTATEDIR "/pies.stat";
mode_t pies_umask = 0;
unsigned long shutdown_timeout = 5;
+size_t default_max_rate;
pies_acl_t pies_acl;
limits_record_t pies_limits;
int force_option;
@@ -900,6 +901,12 @@ struct grecs_keyword component_keywords[] = {
grecs_type_size, NULL,
offsetof (struct component, max_instances),
NULL },
+ {"max-rate",
+ NULL,
+ N_("Maximum number of times an inetd component can be invoked in one minute."),
+ grecs_type_size, NULL,
+ offsetof (struct component, max_rate),
+ NULL },
{"socket",
N_("url: string"),
N_("Listen on the given url."),
@@ -1389,7 +1396,8 @@ enum
OPT_DUMP_DEPMAP,
OPT_FORCE,
OPT_CONFIG_HELP,
- OPT_SOURCE_INFO
+ OPT_SOURCE_INFO,
+ OPT_RATE
};
#define OPT_RESTART 'R'
@@ -1415,6 +1423,9 @@ static struct argp_option options[] = {
N_("use FILE instead of the default configuration"), GRP + 1},
{"config-help", OPT_CONFIG_HELP, NULL, 0,
N_("show configuration file summary"), GRP + 1},
+ {"rate", OPT_RATE, N_("NUMBER"), 0,
+ N_("set default maximum rate for inetd-style components"),
+ GRP + 1},
#undef GRP
#define GRP 5
@@ -1455,6 +1466,8 @@ static struct argp_option options[] = {
static error_t
parse_opt (int key, char *arg, struct argp_state *state)
{
+ char *p;
+
switch (key)
{
case 'c':
@@ -1513,6 +1526,15 @@ parse_opt (int key, char *arg, struct argp_state *state)
debug_level = strtoul (arg, NULL, 0);
break;
+ case OPT_RATE:
+ default_max_rate = strtoul (arg, &p, 10);
+ if (*p)
+ {
+ logmsg (LOG_ERR, _("not a number: %s"), arg);
+ exit (EX_USAGE);
+ }
+ break;
+
case OPT_SOURCE_INFO:
source_info_option = 1;
break;

Return to:

Send suggestions and report system problems to the System administrator.