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