common/messaging: Free message list header if all message handlers are freed
authorAmitay Isaacs <amitay@gmail.com>
Tue, 2 Apr 2013 01:08:39 +0000 (12:08 +1100)
committerAmitay Isaacs <amitay@gmail.com>
Fri, 5 Apr 2013 01:59:25 +0000 (12:59 +1100)
This makes sure that even if the srvids are not deregistered, the header
structure is freed when the last message handler has been freed as a result of
client going away.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
common/ctdb_message.c

index 50d21890f8f515b61c5f297269c605e68ae315b4..2152c88dc9aa42533b797e7afb2a261de546f7c2 100644 (file)
@@ -176,6 +176,9 @@ static int message_handler_destructor(struct ctdb_message_list *m)
        struct ctdb_message_list_header *h = m->h;
 
        DLIST_REMOVE(h->m, m);
+       if (h->m == NULL) {
+               talloc_free(h);
+       }
        return 0;
 }
 
@@ -255,9 +258,6 @@ int ctdb_deregister_message_handler(struct ctdb_context *ctdb, uint64_t srvid, v
        for (m=h->m; m; m=m->next) {
                if (m->message_private == private_data) {
                        talloc_free(m);
-                       if (h->m == NULL) {
-                               talloc_free(h);
-                       }
                        return 0;
                }
        }