Thanks.
It worked, but Stefan's IdleTimeout suggestion looked more appealing. So
i added new configuration variable IdleTimeout.
I'm not so familiar with apache coding :(. I've added my currently
buggy working copy).
Sat IdleTimeout to 5 seconds and ExpireTimeout 30 seconds. After 5
seconds all free threads were killed and after 30 seconds my download
got cancelled.
IdleTimeout seemes to work as expected, but as there is some child
processing request it won't make any new children and server was stalled
until that request (large file download) finished. Anybody know what
i'm doing wrong:? All children that allready exist work okay.
Rommer wrote:
Hello,
my expire timeout patch
------------------------------------------------------------------------
diff -Nru a/server/mpm/experimental/peruser/peruser.c
b/server/mpm/experimental/peruser/peruser.c
--- a/server/mpm/experimental/peruser/peruser.c 2006-04-16 13:24:41.495669137
+0300
+++ b/server/mpm/experimental/peruser/peruser.c 2006-04-16 13:27:32.076667271
+0300
@@ -1970,6 +1970,23 @@
#endif
static int hold_off_on_exponential_spawning;
+static int total_processes(int child_num)
+{
+ int i, total;
+
+ for(i = 0, total = 0; i < NUM_CHILDS; ++i)
+ {
+ if(CHILD_INFO_TABLE[i].senv == CHILD_INFO_TABLE[child_num].senv &&
+ (!(CHILD_INFO_TABLE[i].type == CHILD_TYPE_PROCESSOR &&
+ CHILD_INFO_TABLE[i].status == CHILD_STATUS_STANDBY)))
+ {
+ total++;
+ }
+ }
+
+ return total;
+}
+
static void perform_idle_server_maintenance(apr_pool_t *p)
{
int i;
@@ -1990,7 +2007,8 @@
(CHILD_INFO_TABLE[i].type == CHILD_TYPE_PROCESSOR ||
CHILD_INFO_TABLE[i].type == CHILD_TYPE_WORKER) &&
ap_scoreboard_image->parent[i].pid > 1 &&
- ap_scoreboard_image->servers[i][0].status != SERVER_DEAD &&
+ ap_scoreboard_image->servers[i][0].status == SERVER_READY &&
+ (idle_processors (i) > 1 || total_processes (i) == 1) &&
apr_time_sec(now - ap_scoreboard_image->servers[i][0].last_used) >
expire_timeout)
{
CHILD_INFO_TABLE[i].pid = 0;
------------------------------------------------------------------------
_______________________________________________
Peruser mailing list
[email protected]
http://www.telana.com/mailman/listinfo/peruser
--- httpd-2.0.55/server/mpm/experimental/peruser/peruser.c 2007-01-29 09:33:00.000000000 +0200
+++ httpd-2.0.55-new/server/mpm/experimental/peruser/peruser.c 2007-01-29 15:22:54.000000000 +0200
@@ -204,6 +204,7 @@
static int ap_max_processors=DEFAULT_MAX_PROCESSORS;
static int ap_daemons_limit=0; /* MaxClients */
static int expire_timeout=1800;
+static int idle_timeout=900;
static int server_limit = DEFAULT_SERVER_LIMIT;
static int first_server_limit;
static int changed_limit_at_restart;
@@ -1986,12 +1987,13 @@
if(CHILD_INFO_TABLE[i].status == CHILD_STATUS_STARTING)
make_child(ap_server_conf, i);
}
- else if(expire_timeout > 0 &&
- (CHILD_INFO_TABLE[i].type == CHILD_TYPE_PROCESSOR ||
- CHILD_INFO_TABLE[i].type == CHILD_TYPE_WORKER) &&
- ap_scoreboard_image->parent[i].pid > 1 &&
- ap_scoreboard_image->servers[i][0].status != SERVER_DEAD &&
- apr_time_sec(now - ap_scoreboard_image->servers[i][0].last_used) > expire_timeout)
+ else if(((CHILD_INFO_TABLE[i].type == CHILD_TYPE_PROCESSOR ||
+ CHILD_INFO_TABLE[i].type == CHILD_TYPE_WORKER) &&
+ (ap_scoreboard_image->parent[i].pid > 1)) && (
+ (expire_timeout > 0 && ap_scoreboard_image->servers[i][0].status != SERVER_DEAD &&
+ apr_time_sec(now - ap_scoreboard_image->servers[i][0].last_used) > expire_timeout) ||
+ (idle_timeout > 0 && ap_scoreboard_image->servers[i][0].status == SERVER_READY &&
+ apr_time_sec(now - ap_scoreboard_image->servers[i][0].last_used) > idle_timeout)))
{
CHILD_INFO_TABLE[i].pid = 0;
CHILD_INFO_TABLE[i].status = CHILD_STATUS_STANDBY;
@@ -2004,12 +2006,12 @@
CHILD_INFO_TABLE[i].type = CHILD_TYPE_UNKNOWN;
CHILD_INFO_TABLE[i].sock_fd = -3; /* -1 and -2 are taken */
}
-
if(kill(ap_scoreboard_image->parent[i].pid, SIGTERM) == -1)
{
ap_log_error(APLOG_MARK, APLOG_WARNING, errno,
ap_server_conf, "kill SIGTERM");
}
+
ap_update_child_status_from_indexes(i, 0, SERVER_DEAD, NULL);
}
@@ -2897,6 +2899,17 @@
return NULL;
}
+static const char *set_idle_timeout (cmd_parms *cmd, void *dummy, const char *arg) {
+ const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
+ if (err != NULL) {
+ return err;
+ }
+
+ idle_timeout = atoi(arg);
+
+ return NULL;
+}
+
static const command_rec peruser_cmds[] = {
UNIX_DAEMON_COMMANDS,
LISTEN_COMMANDS,
@@ -2914,6 +2927,8 @@
"Maximum value of MaxClients for this run of Apache"),
AP_INIT_TAKE1("ExpireTimeout", set_expire_timeout, NULL, RSRC_CONF,
"Maximum idle time before a child is killed, 0 to disable"),
+AP_INIT_TAKE1("IdleTimeout", set_idle_timeout, NULL, RSRC_CONF,
+ "Maximum time before a child is killed after being idle, 0 to disable"),
AP_INIT_TAKE23("Multiplexer", cf_Multiplexer, NULL, RSRC_CONF,
"Specify an Multiplexer Child configuration."),
AP_INIT_TAKE23("Processor", cf_Processor, NULL, RSRC_CONF,
_______________________________________________
Peruser mailing list
[email protected]
http://www.telana.com/mailman/listinfo/peruser