1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
/*-
* Copyright (c) 2004-2006
* Oracle Corporation. All rights reserved.
*
* http://www.apache.org/licenses/LICENSE-2.0.txt
*
* authors: George Schlossnagle <george@omniti.com>
*/
extern "C"
{
#include "httpd.h"
#include "http_config.h"
#include "http_core.h"
#include "http_log.h"
#include "http_main.h"
#include "http_protocol.h"
#include "scoreboard.h"
#include "util_script.h"
#include "sem_utils.h"
}
#include "mod_db4_export.h"
#include "utils.h"
extern scoreboard *ap_scoreboard_image;
/*
* Declare ourselves so the configuration routines can find and know us.
* We'll fill it in at the end of the module.
*/
extern module MODULE_VAR_EXPORT db4_module;
void kill_all_children()
{
int i, ret = 1;
ap_sync_scoreboard_image();
for(;ret != 0;) {
ret = 0;
for (i = 0; i < HARD_SERVER_LIMIT; ++i) {
ret += kill(ap_scoreboard_image->parent[i].pid, SIGTERM);
}
}
}
int moderator_main(void * ptr, child_info *ci)
{
for(;;) {
env_wait_for_child_crash();
kill_all_children();
env_global_rw_lock();
global_ref_count_clean();
env_ok_to_proceed();
env_global_unlock();
}
}
static void sig_unrecoverable(int sig)
{
env_child_crash();
/* reinstall default apache handler */
signal(sig, SIG_DFL);
kill(getpid(), sig);
}
static void db4_init(server_rec *s, pool *p)
{
int mpid;
env_locks_init();
mpid=ap_spawn_child(p, moderator_main, NULL, kill_always, NULL, NULL, NULL);
}
/*
* Worker process init
*/
static void db4_child_init(server_rec *s, pool *p)
{
/* install our private signal handlers */
signal(SIGSEGV, sig_unrecoverable);
signal(SIGBUS, sig_unrecoverable);
signal(SIGABRT, sig_unrecoverable);
signal(SIGILL, sig_unrecoverable);
env_rsrc_list_init();
}
/*
* Worker process exit
*/
static void db4_child_exit(server_rec *s, pool *p)
{
mod_db4_child_clean_process_shutdown();
}
static const command_rec db4_cmds[] =
{
{NULL}
};
module MODULE_VAR_EXPORT db4_module =
{
STANDARD_MODULE_STUFF,
db4_init, /* module initializer */
NULL, /* per-directory config creator */
NULL, /* dir config merger */
NULL, /* server config creator */
NULL, /* server config merger */
db4_cmds, /* command table */
NULL, /* [9] list of handlers */
NULL, /* [2] filename-to-URI translation */
NULL, /* [5] check/validate user_id */
NULL, /* [6] check user_id is valid *here* */
NULL, /* [4] check access by host address */
NULL, /* [7] MIME type checker/setter */
NULL, /* [8] fixups */
NULL, /* [10] logger */
#if MODULE_MAGIC_NUMBER >= 19970103
NULL, /* [3] header parser */
#endif
#if MODULE_MAGIC_NUMBER >= 19970719
db4_child_init, /* process initializer */
#endif
#if MODULE_MAGIC_NUMBER >= 19970728
db4_child_exit, /* process exit/cleanup */
#endif
#if MODULE_MAGIC_NUMBER >= 19970902
NULL /* [1] post read_request handling */
#endif
};
/* vim: set ts=4 sts=4 bs=2 ai expandtab : */
|