summaryrefslogtreecommitdiff
path: root/source4/lib
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2017-04-03 17:58:24 +0000
committerJeremy Allison <jra@samba.org>2017-04-17 19:13:07 +0200
commitfc8f858c8cdac4a50517e48d4f5af6273c27b894 (patch)
tree646fc8eecd2c0242c78e60dc5c42e3259098684e /source4/lib
parent5fe996bc1f0b80e8e68c6fd558222e42b5916b9a (diff)
downloadsamba-fc8f858c8cdac4a50517e48d4f5af6273c27b894.tar.gz
s4: messaging: When talloc_free()'ing an event context, only remove msg_dgm_ref's that point to *that* context.
Defensive programming change. Not strictly needed to prevent any crash/error. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
Diffstat (limited to 'source4/lib')
-rw-r--r--source4/lib/messaging/messaging.c8
-rw-r--r--source4/lib/messaging/messaging.h2
2 files changed, 6 insertions, 4 deletions
diff --git a/source4/lib/messaging/messaging.c b/source4/lib/messaging/messaging.c
index 19873c5bc39..2da0acc0c7a 100644
--- a/source4/lib/messaging/messaging.c
+++ b/source4/lib/messaging/messaging.c
@@ -256,18 +256,20 @@ static int imessaging_context_destructor(struct imessaging_context *msg)
}
/*
- * Cleanup messaging dgm contexts
+ * Cleanup messaging dgm contexts on a specific event context.
*
* We must make sure to unref all messaging_dgm_ref's *before* the
* tevent context goes away. Only when the last ref is freed, the
* refcounted messaging dgm context will be freed.
*/
-void imessaging_dgm_unref_all(void)
+void imessaging_dgm_unref_ev(struct tevent_context *ev)
{
struct imessaging_context *msg = NULL;
for (msg = msg_ctxs; msg != NULL; msg = msg->next) {
- TALLOC_FREE(msg->msg_dgm_ref);
+ if (msg->ev == ev) {
+ TALLOC_FREE(msg->msg_dgm_ref);
+ }
}
}
diff --git a/source4/lib/messaging/messaging.h b/source4/lib/messaging/messaging.h
index e587fdfb3aa..668464dc061 100644
--- a/source4/lib/messaging/messaging.h
+++ b/source4/lib/messaging/messaging.h
@@ -44,7 +44,7 @@ struct imessaging_context *imessaging_init(TALLOC_CTX *mem_ctx,
struct loadparm_context *lp_ctx,
struct server_id server_id,
struct tevent_context *ev);
-void imessaging_dgm_unref_all(void);
+void imessaging_dgm_unref_ev(struct tevent_context *ev);
NTSTATUS imessaging_reinit_all(void);
int imessaging_cleanup(struct imessaging_context *msg);
struct imessaging_context *imessaging_client_init(TALLOC_CTX *mem_ctx,