From: Volker Lendecke Date: Tue, 21 Jun 2016 11:04:25 +0000 (+0200) Subject: notify_msg: Deregister handler upon talloc_free X-Git-Tag: tdb-1.3.10~319 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7404feffd7130ce389be3a1f65a7ae8c7cc2d156;p=thirdparty%2Fsamba.git notify_msg: Deregister handler upon talloc_free So far, we haven't TALLOC_FREE'ed the notify context. This will change. Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- diff --git a/source3/smbd/notify_msg.c b/source3/smbd/notify_msg.c index 1379fc4aa6b..d349e914370 100644 --- a/source3/smbd/notify_msg.c +++ b/source3/smbd/notify_msg.c @@ -43,6 +43,7 @@ struct notify_context { static void notify_handler(struct messaging_context *msg, void *private_data, uint32_t msg_type, struct server_id src, DATA_BLOB *data); +static int notify_context_destructor(struct notify_context *ctx); struct notify_context *notify_init( TALLOC_CTX *mem_ctx, struct messaging_context *msg, @@ -84,9 +85,20 @@ struct notify_context *notify_init( } } + talloc_set_destructor(ctx, notify_context_destructor); + return ctx; } +static int notify_context_destructor(struct notify_context *ctx) +{ + if (ctx->callback != NULL) { + messaging_deregister(ctx->msg_ctx, MSG_PVFS_NOTIFY, ctx); + } + + return 0; +} + static void notify_handler(struct messaging_context *msg, void *private_data, uint32_t msg_type, struct server_id src, DATA_BLOB *data)