]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
notify_msg: Deregister handler upon talloc_free
authorVolker Lendecke <vl@samba.org>
Tue, 21 Jun 2016 11:04:25 +0000 (13:04 +0200)
committerJeremy Allison <jra@samba.org>
Wed, 20 Jul 2016 03:21:07 +0000 (05:21 +0200)
So far, we haven't TALLOC_FREE'ed the notify context. This will change.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/notify_msg.c

index 1379fc4aa6b5f620a72379f8f6567586d5abbad2..d349e91437075aba37506000bc799922fb559be5 100644 (file)
@@ -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)