trawick 01/05/16 12:14:53
Modified: . CHANGES
include/arch/unix misc.h
misc/unix otherchild.c
Log:
Automatically remove other-child registrations when the
associated pool is destroyed. This avoids garbage in the
list of registrations when a pool with a registration is
freed.
Revision Changes Path
1.105 +5 -0 apr/CHANGES
Index: CHANGES
===================================================================
RCS file: /home/cvs/apr/CHANGES,v
retrieving revision 1.104
retrieving revision 1.105
diff -u -r1.104 -r1.105
--- CHANGES 2001/05/12 03:41:53 1.104
+++ CHANGES 2001/05/16 19:14:39 1.105
@@ -1,5 +1,10 @@
Changes with APR b1
+ *) Other-child registrations are automatically removed when the
+ associated pool is destroyed. This avoids garbage in the list
+ of registrations when a pool with a registration is freed.
+ [Jeff Trawick]
+
*) Allow LTFLAGS to be overridden by the configure command-line
(default="--silent") and introduce LT_LDFLAGS. [Roy Fielding]
1.27 +1 -0 apr/include/arch/unix/misc.h
Index: misc.h
===================================================================
RCS file: /home/cvs/apr/include/arch/unix/misc.h,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- misc.h 2001/05/16 18:11:51 1.26
+++ misc.h 2001/05/16 19:14:45 1.27
@@ -89,6 +89,7 @@
#endif
struct apr_other_child_rec_t {
+ apr_pool_t *p;
struct apr_other_child_rec_t *next;
int id; /* This is either a pid or tid depending on the platform */
void (*maintenance) (int, void *, int);
1.22 +29 -8 apr/misc/unix/otherchild.c
Index: otherchild.c
===================================================================
RCS file: /home/cvs/apr/misc/unix/otherchild.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- otherchild.c 2001/05/04 18:33:41 1.21
+++ otherchild.c 2001/05/16 19:14:50 1.22
@@ -74,6 +74,22 @@
static apr_other_child_rec_t *other_children = NULL;
+static apr_status_t other_child_cleanup(void *data)
+{
+ apr_other_child_rec_t **pocr, *nocr;
+
+ for (pocr = &other_children; *pocr; pocr = &(*pocr)->next) {
+ if ((*pocr)->data == data) {
+ nocr = (*pocr)->next;
+ (*(*pocr)->maintenance) (APR_OC_REASON_UNREGISTER,
(*pocr)->data, -1);
+ *pocr = nocr;
+ /* XXX: um, well we've just wasted some space in pconf ? */
+ return APR_SUCCESS;
+ }
+ }
+ return APR_SUCCESS;
+}
+
APR_DECLARE(void) apr_proc_other_child_register(apr_proc_t *pid,
void (*maintenance) (int reason, void *, int status),
void *data, apr_file_t *write_fd, apr_pool_t *p)
@@ -81,6 +97,7 @@
apr_other_child_rec_t *ocr;
ocr = apr_palloc(p, sizeof(*ocr));
+ ocr->p = p;
ocr->id = pid->pid;
ocr->maintenance = maintenance;
ocr->data = data;
@@ -92,21 +109,25 @@
}
ocr->next = other_children;
other_children = ocr;
+ apr_pool_cleanup_register(p, ocr->data, other_child_cleanup,
+ apr_pool_cleanup_null);
}
APR_DECLARE(void) apr_proc_other_child_unregister(void *data)
{
- apr_other_child_rec_t **pocr, *nocr;
+ apr_other_child_rec_t *cur;
- for (pocr = &other_children; *pocr; pocr = &(*pocr)->next) {
- if ((*pocr)->data == data) {
- nocr = (*pocr)->next;
- (*(*pocr)->maintenance) (APR_OC_REASON_UNREGISTER,
(*pocr)->data, -1);
- *pocr = nocr;
- /* XXX: um, well we've just wasted some space in pconf ? */
- return;
+ cur = other_children;
+ while (cur) {
+ if (cur->data == data) {
+ break;
}
+ cur = cur->next;
}
+
+ /* segfault if this function called with invalid parm */
+ apr_pool_cleanup_kill(cur->p, cur->data, other_child_cleanup);
+ other_child_cleanup(data);
}
/* test to ensure that the write_fds are all still writable, otherwise