00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 extern "C"
00011 {
00012 #include "httpd.h"
00013 #include "http_config.h"
00014 #include "http_core.h"
00015 #include "http_log.h"
00016 #include "http_main.h"
00017 #include "http_protocol.h"
00018 #include "scoreboard.h"
00019 #include "util_script.h"
00020
00021 #include "sem_utils.h"
00022 }
00023 #include "mod_db4_export.h"
00024 #include "utils.h"
00025
00026 extern scoreboard *ap_scoreboard_image;
00027
00028
00029
00030
00031
00032
00033 extern module MODULE_VAR_EXPORT db4_module;
00034
00035 void kill_all_children()
00036 {
00037 int i, ret = 1;
00038 ap_sync_scoreboard_image();
00039 for(;ret != 0;) {
00040 ret = 0;
00041 for (i = 0; i < HARD_SERVER_LIMIT; ++i) {
00042 ret += kill(ap_scoreboard_image->parent[i].pid, SIGTERM);
00043 }
00044 }
00045 }
00046
00047 int moderator_main(void * ptr, child_info *ci)
00048 {
00049 for(;;) {
00050 env_wait_for_child_crash();
00051 kill_all_children();
00052 env_global_rw_lock();
00053 global_ref_count_clean();
00054 env_ok_to_proceed();
00055 env_global_unlock();
00056 }
00057 }
00058
00059 static void sig_unrecoverable(int sig)
00060 {
00061 env_child_crash();
00062
00063 signal(sig, SIG_DFL);
00064 kill(getpid(), sig);
00065 }
00066
00067 static void db4_init(server_rec *s, pool *p)
00068 {
00069 int mpid;
00070 env_locks_init();
00071 mpid=ap_spawn_child(p, moderator_main, NULL, kill_always, NULL, NULL, NULL);
00072 }
00073
00074
00075
00076
00077
00078 static void db4_child_init(server_rec *s, pool *p)
00079 {
00080
00081 signal(SIGSEGV, sig_unrecoverable);
00082 signal(SIGBUS, sig_unrecoverable);
00083 signal(SIGABRT, sig_unrecoverable);
00084 signal(SIGILL, sig_unrecoverable);
00085 env_rsrc_list_init();
00086 }
00087
00088
00089
00090
00091 static void db4_child_exit(server_rec *s, pool *p)
00092 {
00093 mod_db4_child_clean_process_shutdown();
00094 }
00095
00096 static const command_rec db4_cmds[] =
00097 {
00098 {NULL}
00099 };
00100
00101 module MODULE_VAR_EXPORT db4_module =
00102 {
00103 STANDARD_MODULE_STUFF,
00104 db4_init,
00105 NULL,
00106 NULL,
00107 NULL,
00108 NULL,
00109 db4_cmds,
00110 NULL,
00111 NULL,
00112 NULL,
00113 NULL,
00114 NULL,
00115 NULL,
00116 NULL,
00117 NULL,
00118 #if MODULE_MAGIC_NUMBER >= 19970103
00119 NULL,
00120 #endif
00121 #if MODULE_MAGIC_NUMBER >= 19970719
00122 db4_child_init,
00123 #endif
00124 #if MODULE_MAGIC_NUMBER >= 19970728
00125 db4_child_exit,
00126 #endif
00127 #if MODULE_MAGIC_NUMBER >= 19970902
00128 NULL
00129 #endif
00130 };
00131