1 |
3 |
ahitrov@rambler.ru |
diff -ru ./src/include/http_conf_globals.h /home/lonerr/tmp/apache13/apache_1.3.41/src/include/http_conf_globals.h |
2 |
|
|
--- ./src/include/http_conf_globals.h 2006-07-12 12:16:05.000000000 +0400 |
3 |
|
|
+++ /home/lonerr/tmp/apache13/apache_1.3.41/src/include/http_conf_globals.h 2008-03-06 14:34:45.000000000 +0300 |
4 |
|
|
@@ -45,6 +45,7 @@ |
5 |
|
|
extern API_VAR_EXPORT int ap_daemons_to_start; |
6 |
|
|
extern API_VAR_EXPORT int ap_daemons_min_free; |
7 |
|
|
extern API_VAR_EXPORT int ap_daemons_max_free; |
8 |
|
|
+extern API_VAR_EXPORT int ap_spare_reaper_delay; |
9 |
|
|
extern API_VAR_EXPORT int ap_daemons_limit; |
10 |
|
|
extern API_VAR_EXPORT int ap_suexec_enabled; |
11 |
|
|
extern API_VAR_EXPORT int ap_listenbacklog; |
12 |
|
|
diff -ru ./src/main/http_core.c /home/lonerr/tmp/apache13/apache_1.3.41/src/main/http_core.c |
13 |
|
|
--- ./src/main/http_core.c 2006-07-12 12:16:05.000000000 +0400 |
14 |
|
|
+++ /home/lonerr/tmp/apache13/apache_1.3.41/src/main/http_core.c 2008-03-06 14:34:53.000000000 +0300 |
15 |
|
|
@@ -2478,6 +2478,17 @@ |
16 |
|
|
return NULL; |
17 |
|
|
} |
18 |
|
|
|
19 |
|
|
+static const char *set_spare_reaper_delay(cmd_parms *cmd, void *dummy, char *arg) |
20 |
|
|
+{ |
21 |
|
|
+ const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); |
22 |
|
|
+ if (err != NULL) { |
23 |
|
|
+ return err; |
24 |
|
|
+ } |
25 |
|
|
+ |
26 |
|
|
+ ap_spare_reaper_delay = atoi(arg); |
27 |
|
|
+ return NULL; |
28 |
|
|
+} |
29 |
|
|
+ |
30 |
|
|
static const char *set_server_limit (cmd_parms *cmd, void *dummy, char *arg) |
31 |
|
|
{ |
32 |
|
|
const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); |
33 |
|
|
@@ -3616,6 +3627,8 @@ |
34 |
|
|
"Minimum number of idle children, to handle request spikes" }, |
35 |
|
|
{ "MaxSpareServers", set_max_free_servers, NULL, RSRC_CONF, TAKE1, |
36 |
|
|
"Maximum number of idle children" }, |
37 |
|
|
+{ "SpareReaperDelay", set_spare_reaper_delay, NULL, RSRC_CONF, TAKE1, |
38 |
|
|
+ "Delay to kill spare servers" }, |
39 |
|
|
{ "MaxServers", set_max_free_servers, NULL, RSRC_CONF, TAKE1, |
40 |
|
|
"Deprecated equivalent to MaxSpareServers" }, |
41 |
|
|
{ "ServersSafetyLimit", set_server_limit, NULL, RSRC_CONF, TAKE1, |
42 |
|
|
diff -ru ./src/main/http_main.c /home/lonerr/tmp/apache13/apache_1.3.41/src/main/http_main.c |
43 |
|
|
--- ./src/main/http_main.c 2007-11-16 00:31:15.000000000 +0300 |
44 |
|
|
+++ /home/lonerr/tmp/apache13/apache_1.3.41/src/main/http_main.c 2008-03-06 14:34:53.000000000 +0300 |
45 |
|
|
@@ -214,6 +214,7 @@ |
46 |
|
|
API_VAR_EXPORT int ap_daemons_to_start=0; |
47 |
|
|
API_VAR_EXPORT int ap_daemons_min_free=0; |
48 |
|
|
API_VAR_EXPORT int ap_daemons_max_free=0; |
49 |
|
|
+API_VAR_EXPORT int ap_spare_reaper_delay=0; |
50 |
|
|
API_VAR_EXPORT int ap_daemons_limit=0; |
51 |
|
|
API_VAR_EXPORT time_t ap_restart_time=0; |
52 |
|
|
API_VAR_EXPORT int ap_suexec_enabled = 0; |
53 |
|
|
@@ -5117,7 +5118,7 @@ |
54 |
|
|
#define SIG_TIMEOUT_KILL SIGALRM |
55 |
|
|
#endif |
56 |
|
|
|
57 |
|
|
-static void perform_idle_server_maintenance(void) |
58 |
|
|
+static void perform_idle_server_maintenance(int *rloop) |
59 |
|
|
{ |
60 |
|
|
int i; |
61 |
|
|
int to_kill; |
62 |
|
|
@@ -5209,11 +5210,20 @@ |
63 |
|
|
*/ |
64 |
|
|
pid = ap_scoreboard_image->parent[to_kill].pid; |
65 |
|
|
if (in_pid_table(pid)) { |
66 |
|
|
- kill(pid, SIG_IDLE_KILL); |
67 |
|
|
- idle_spawn_rate = 1; |
68 |
|
|
+ if (*rloop >= ap_spare_reaper_delay) { |
69 |
|
|
+ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, server_conf, |
70 |
|
|
+ "reaping spare child (pid: %d, delay: %d/%d)", pid, *rloop, ap_spare_reaper_delay); |
71 |
|
|
+ kill(pid, SIG_IDLE_KILL); |
72 |
|
|
+ idle_spawn_rate = 1; |
73 |
|
|
+ *rloop = 0; |
74 |
|
|
#ifdef TPF |
75 |
|
|
- ap_update_child_status(to_kill, SERVER_DEAD, (request_rec *)NULL); |
76 |
|
|
+ ap_update_child_status(to_kill, SERVER_DEAD, (request_rec *)NULL); |
77 |
|
|
#endif |
78 |
|
|
+ } else { |
79 |
|
|
+ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_DEBUG, server_conf, |
80 |
|
|
+ "empty reaper cycle (delay: %d/%d)", *rloop, ap_spare_reaper_delay); |
81 |
|
|
+ ++*rloop; |
82 |
|
|
+ } |
83 |
|
|
} |
84 |
|
|
else { |
85 |
|
|
ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, server_conf, |
86 |
|
|
@@ -5221,6 +5231,7 @@ |
87 |
|
|
} |
88 |
|
|
} |
89 |
|
|
else if (idle_count < ap_daemons_min_free) { |
90 |
|
|
+ *rloop = 0; |
91 |
|
|
/* terminate the free list */ |
92 |
|
|
if (free_length == 0) { |
93 |
|
|
/* only report this condition once */ |
94 |
|
|
@@ -5268,6 +5279,7 @@ |
95 |
|
|
} |
96 |
|
|
} |
97 |
|
|
else { |
98 |
|
|
+ *rloop = 0; |
99 |
|
|
idle_spawn_rate = 1; |
100 |
|
|
} |
101 |
|
|
} |
102 |
|
|
@@ -5450,6 +5462,7 @@ |
103 |
|
|
amutex->name, ap_default_mutex_method()); |
104 |
|
|
restart_pending = shutdown_pending = 0; |
105 |
|
|
|
106 |
|
|
+ int reaper_loop = 0; |
107 |
|
|
while (!restart_pending && !shutdown_pending) { |
108 |
|
|
int child_slot; |
109 |
|
|
ap_wait_t status; |
110 |
|
|
@@ -5517,7 +5530,7 @@ |
111 |
|
|
continue; |
112 |
|
|
} |
113 |
|
|
|
114 |
|
|
- perform_idle_server_maintenance(); |
115 |
|
|
+ perform_idle_server_maintenance(&reaper_loop); |
116 |
|
|
} |
117 |
|
|
|
118 |
|
|
if (shutdown_pending) { |