You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Doug MacEachern <do...@opengroup.org> on 1997/07/25 20:26:21 UTC
child_exit?
Now that we have the new child_init hook, I think a child_exit hook
is in order to give modules a chance to cleanup, etc., instead of just
exit'ing in child_main() once we hit max_request_per_child, etc. I
can't recall if this has been discussed before, a simple patch is
below for you to consider. If there are +1s I'll add the NULL slot to
the rest of the modules.
-Doug
Index: http_config.c
===================================================================
RCS file: /export/home/cvs/apache/src/http_config.c,v
retrieving revision 1.65
diff -u -C3 -r1.65 http_config.c
/usr/bin/diff: conflicting specifications of output style
*** http_config.c 1997/07/24 04:38:08 1.65
--- http_config.c 1997/07/25 18:19:46
***************
*** 1230,1235 ****
--- 1230,1246 ----
(*m->child_init) (s, p);
}
+ void child_exit_modules(pool *p, server_rec *s)
+ {
+ module *m;
+
+ for (m = top_module; m; m = m->next)
+ if (m->child_exit)
+ (*m->child_exit) (s, p);
+
+ exit(0);
+ }
+
/********************************************************************
* Configuration directives are restricted in terms of where they may
* appear in the main configuration files and/or .htaccess files according
Index: http_config.h
===================================================================
RCS file: /export/home/cvs/apache/src/http_config.h,v
retrieving revision 1.40
diff -u -C3 -r1.40 http_config.h
/usr/bin/diff: conflicting specifications of output style
*** http_config.h 1997/07/21 05:53:42 1.40
--- http_config.h 1997/07/25 18:19:46
***************
*** 233,238 ****
--- 233,244 ----
#else
void (*child_init)(server_rec *, pool *);
#endif
+ #ifdef ULTRIX_BRAIN_DEATH
+ void (*child_exit)();
+ #else
+ void (*child_exit)(server_rec *, pool *);
+ #endif
+
} module;
/* Initializer for the first few module slots, which are only
***************
*** 282,287 ****
--- 288,294 ----
server_rec *read_config (pool *conf_pool, pool *temp_pool, char *config_name);
void init_modules(pool *p, server_rec *s);
void child_init_modules(pool *p, server_rec *s);
+ void child_exit_modules(pool *p, server_rec *s);
void setup_prelinked_modules(void);
void show_directives(void);
void show_modules(void);
Index: http_core.c
===================================================================
RCS file: /export/home/cvs/apache/src/http_core.c,v
retrieving revision 1.100
diff -u -C3 -r1.100 http_core.c
/usr/bin/diff: conflicting specifications of output style
*** http_core.c 1997/07/24 04:38:09 1.100
--- http_core.c 1997/07/25 18:19:47
***************
*** 1454,1458 ****
NULL, /* pre-run fixups */
NULL, /* logger */
NULL, /* header parser */
! NULL /* child_init */
};
--- 1454,1459 ----
NULL, /* pre-run fixups */
NULL, /* logger */
NULL, /* header parser */
! NULL, /* child_init */
! NULL /* child_exit */
};
Index: http_main.c
===================================================================
RCS file: /export/home/cvs/apache/src/http_main.c,v
retrieving revision 1.187
diff -u -C3 -r1.187 http_main.c
/usr/bin/diff: conflicting specifications of output style
*** http_main.c 1997/07/24 04:35:47 1.187
--- http_main.c 1997/07/25 18:19:49
***************
*** 2202,2213 ****
sync_scoreboard_image();
if (scoreboard_image->global.exit_generation >= generation)
! exit(0);
if ((max_requests_per_child > 0
&& ++requests_this_child >= max_requests_per_child))
{
! exit(0);
}
(void)update_child_status(child_num, SERVER_READY, (request_rec*)NULL);
--- 2202,2213 ----
sync_scoreboard_image();
if (scoreboard_image->global.exit_generation >= generation)
! child_exit_modules(pconf, server_conf);
if ((max_requests_per_child > 0
&& ++requests_this_child >= max_requests_per_child))
{
! child_exit_modules(pconf, server_conf);
}
(void)update_child_status(child_num, SERVER_READY, (request_rec*)NULL);
***************
*** 2249,2255 ****
if (csd >= 0 || errno != EINTR) break;
if (deferred_die) {
/* we didn't get a socket, and we were told to die */
! exit (0);
}
}
--- 2249,2255 ----
if (csd >= 0 || errno != EINTR) break;
if (deferred_die) {
/* we didn't get a socket, and we were told to die */
! child_exit_modules(pconf, server_conf);
}
}
***************
*** 2271,2284 ****
signal (SIGUSR1, just_die);
if (deferred_die) {
/* ok maybe not, see ya later */
! exit (0);
}
/* or maybe we missed a signal, you never know on systems
* without reliable signals
*/
sync_scoreboard_image();
if (scoreboard_image->global.exit_generation >= generation)
! exit(0);
}
accept_mutex_off(); /* unlock after "accept" */
--- 2271,2284 ----
signal (SIGUSR1, just_die);
if (deferred_die) {
/* ok maybe not, see ya later */
! child_exit_modules(pconf, server_conf);
}
/* or maybe we missed a signal, you never know on systems
* without reliable signals
*/
sync_scoreboard_image();
if (scoreboard_image->global.exit_generation >= generation)
! child_exit_modules(pconf, server_conf);
}
accept_mutex_off(); /* unlock after "accept" */
***************
*** 2363,2369 ****
sync_scoreboard_image();
if (scoreboard_image->global.exit_generation >= generation) {
bclose(conn_io);
! exit(0);
}
/* In case we get a graceful restart while we're blocked
--- 2363,2369 ----
sync_scoreboard_image();
if (scoreboard_image->global.exit_generation >= generation) {
bclose(conn_io);
! child_exit_modules(pconf, server_conf);
}
/* In case we get a graceful restart while we're blocked
Index: mod_access.c
===================================================================
RCS file: /export/home/cvs/apache/src/mod_access.c,v
retrieving revision 1.19
diff -u -C3 -r1.19 mod_access.c
/usr/bin/diff: conflicting specifications of output style
*** mod_access.c 1997/07/21 05:53:48 1.19
--- mod_access.c 1997/07/25 18:19:50
***************
*** 280,284 ****
NULL, /* fixups */
NULL, /* logger */
NULL, /* header parser */
! NULL /* child_init */
};
--- 280,285 ----
NULL, /* fixups */
NULL, /* logger */
NULL, /* header parser */
! NULL, /* child_init */
! NULL /* child_exit */
};
Index: mod_actions.c
===================================================================
RCS file: /export/home/cvs/apache/src/mod_actions.c,v
retrieving revision 1.13
diff -u -C3 -r1.13 mod_actions.c
/usr/bin/diff: conflicting specifications of output style
*** mod_actions.c 1997/07/17 22:27:31 1.13
--- mod_actions.c 1997/07/25 18:19:50
***************
*** 216,220 ****
NULL, /* fixups */
NULL, /* logger */
NULL, /* header parser */
! NULL /* child_init */
};
--- 216,221 ----
NULL, /* fixups */
NULL, /* logger */
NULL, /* header parser */
! NULL, /* child_init */
! NULL /* child_exit */
};
Index: mod_alias.c
===================================================================
RCS file: /export/home/cvs/apache/src/mod_alias.c,v
retrieving revision 1.20
diff -u -C3 -r1.20 mod_alias.c
/usr/bin/diff: conflicting specifications of output style
*** mod_alias.c 1997/07/24 04:38:09 1.20
--- mod_alias.c 1997/07/25 18:19:50
***************
*** 385,389 ****
fixup_redir, /* fixups */
NULL, /* logger */
NULL, /* header parser */
! NULL /* child_init */
};
--- 385,390 ----
fixup_redir, /* fixups */
NULL, /* logger */
NULL, /* header parser */
! NULL, /* child_init */
! NULL /* child_exit */
};
Index: mod_asis.c
===================================================================
RCS file: /export/home/cvs/apache/src/mod_asis.c,v
retrieving revision 1.15
diff -u -C3 -r1.15 mod_asis.c
/usr/bin/diff: conflicting specifications of output style
*** mod_asis.c 1997/07/17 22:27:31 1.15
--- mod_asis.c 1997/07/25 18:19:50
***************
*** 127,131 ****
NULL, /* pre-run fixups */
NULL, /* logger */
NULL, /* header parser */
! NULL /* child_init */
};
--- 127,132 ----
NULL, /* pre-run fixups */
NULL, /* logger */
NULL, /* header parser */
! NULL, /* child_init */
! NULL /* child_exit */
};
Index: mod_auth.c
===================================================================
RCS file: /export/home/cvs/apache/src/mod_auth.c,v
retrieving revision 1.21
diff -u -C3 -r1.21 mod_auth.c
/usr/bin/diff: conflicting specifications of output style
*** mod_auth.c 1997/07/19 08:02:04 1.21
--- mod_auth.c 1997/07/25 18:19:50
***************
*** 297,301 ****
NULL, /* fixups */
NULL, /* logger */
NULL, /* header parser */
! NULL /* child_init */
};
--- 297,302 ----
NULL, /* fixups */
NULL, /* logger */
NULL, /* header parser */
! NULL, /* child_init */
! NULL /* child_exit */
};
Re: child_exit?
Posted by Dean Gaudet <dg...@arctic.org>.
On Fri, 25 Jul 1997, Doug MacEachern wrote:
> Now that we have the new child_init hook, I think a child_exit hook
> is in order to give modules a chance to cleanup, etc., instead of just
> exit'ing in child_main() once we hit max_request_per_child, etc. I
> can't recall if this has been discussed before, a simple patch is
> below for you to consider. If there are +1s I'll add the NULL slot to
> the rest of the modules.
You should mask USR1 and HUP during child_exit_modules. Documentation
should include a note that there's absolutely no guarantee that the exit
function will be called.
Did you miss just_die() ?
I hope the pconf pool is sane at that point. I'm worried that a USR1/HUP
could come in while it's in the middle of a block_alarm() critical
section...
Dean