OK. now's my working patch. Now i noticed that it allways leaves 2
threads up (even though i have one active connection).
Janno Sannik wrote:
yeah actually I suspected that it does that :).
Rommer wrote:
Hello,
Janno Sannik wrote:
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.
My function:
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;
}
And this condition:
(idle_processors (i) > 1 || total_processes (i) == 1)
resolves this feature
_______________________________________________
Peruser mailing list
[email protected]
http://www.telana.com/mailman/listinfo/peruser
_______________________________________________
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 17:15:14.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;
@@ -1969,6 +1970,20 @@
#define MAX_SPAWN_RATE (32)
#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)
{
@@ -1986,12 +2001,14 @@
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) &&
+ (idle_processors (i) > 1 || total_processes (i) == 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 +2021,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 +2914,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 +2942,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