summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authortrawick <trawick@13f79535-47bb-0310-9956-ffa450edef68>2001-05-16 19:14:50 +0000
committertrawick <trawick@13f79535-47bb-0310-9956-ffa450edef68>2001-05-16 19:14:50 +0000
commit5848bed185070e612faae212402c1d6db2eb133c (patch)
tree123b35e6256d88b568e5731476578c6307536c6a /misc
parentc6412158a79b8cdf2c6cb5cfcb2a3b61acb085b3 (diff)
downloadlibapr-5848bed185070e612faae212402c1d6db2eb133c.tar.gz
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. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@61652 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'misc')
-rw-r--r--misc/unix/otherchild.c37
1 files changed, 29 insertions, 8 deletions
diff --git a/misc/unix/otherchild.c b/misc/unix/otherchild.c
index 8ebe69851..b263392a7 100644
--- a/misc/unix/otherchild.c
+++ b/misc/unix/otherchild.c
@@ -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_DECLARE(void) apr_proc_other_child_register(apr_proc_t *pid,
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 @@ APR_DECLARE(void) apr_proc_other_child_register(apr_proc_t *pid,
}
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