Main Page | Class Hierarchy | Data Structures | Directories | File List | Data Fields | Related Pages

mod_db4.c

00001 /*-
00002  * Copyright (c) 2004-2005
00003  *      Sleepycat Software.  All rights reserved.
00004  *
00005  * http://www.apache.org/licenses/LICENSE-2.0.txt
00006  * 
00007  * authors: George Schlossnagle <[email protected]>
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  * Declare ourselves so the configuration routines can find and know us.
00030  * We'll fill it in at the end of the module.
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     /* reinstall default apache handler */
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  * Worker process init
00076  */
00077 
00078 static void db4_child_init(server_rec *s, pool *p)
00079 {
00080     /* install our private signal handlers */
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  * Worker process exit
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,               /* module initializer */
00105     NULL,  /* per-directory config creator */
00106     NULL,   /* dir config merger */
00107     NULL,       /* server config creator */
00108     NULL,        /* server config merger */
00109     db4_cmds,               /* command table */
00110     NULL,           /* [9] list of handlers */
00111     NULL,  /* [2] filename-to-URI translation */
00112     NULL,      /* [5] check/validate user_id */
00113     NULL,       /* [6] check user_id is valid *here* */
00114     NULL,     /* [4] check access by host address */
00115     NULL,       /* [7] MIME type checker/setter */
00116     NULL,        /* [8] fixups */
00117     NULL,             /* [10] logger */
00118 #if MODULE_MAGIC_NUMBER >= 19970103
00119     NULL,      /* [3] header parser */
00120 #endif
00121 #if MODULE_MAGIC_NUMBER >= 19970719
00122     db4_child_init,         /* process initializer */
00123 #endif
00124 #if MODULE_MAGIC_NUMBER >= 19970728
00125     db4_child_exit,         /* process exit/cleanup */
00126 #endif
00127 #if MODULE_MAGIC_NUMBER >= 19970902
00128     NULL   /* [1] post read_request handling */
00129 #endif
00130 };
00131 /* vim: set ts=4 sts=4 bs=2 ai expandtab : */

Generated on Sun Dec 25 12:14:41 2005 for Berkeley DB 4.4.16 by  doxygen 1.4.2