]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-program-client: Do not call callback when destroying
authorAki Tuomi <aki.tuomi@dovecot.fi>
Wed, 9 Nov 2016 13:40:48 +0000 (15:40 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Tue, 15 Nov 2016 20:15:38 +0000 (22:15 +0200)
src/lib-program-client/program-client-private.h
src/lib-program-client/program-client.c

index ab0bac4cf1a3aaec99b012e85546490656dbc524..ee6498ba92bc75ffbb5be27986f51fa82619aa06 100644 (file)
@@ -60,6 +60,7 @@ struct program_client {
        bool debug:1;
        bool disconnected:1;
        bool output_seekable:1;
+       bool destroying:1;
 };
 
 void program_client_init(struct program_client *pclient, pool_t pool, const char *path,
index 047e9ed2a3ab458204db25887a9c685d34c3bc2b..16b21ce93acb528f3a163225e6c4171b675b35bd 100644 (file)
 static
 void program_client_callback(struct program_client *pclient, int result, void *context)
 {
+       /* do not call callback when destroying */
+       if (pclient->destroying) return;
        program_client_callback_t *callback = pclient->callback;
        i_assert(pclient->callback != NULL);
-       pclient->callback = NULL;
        callback(result, context);
 }
 
@@ -525,6 +526,10 @@ void program_client_init_streams(struct program_client *pclient)
 void program_client_destroy(struct program_client **_pclient)
 {
        struct program_client *pclient = *_pclient;
+       *_pclient = NULL;
+
+       pclient->destroying = TRUE;
+       pclient->callback = NULL;
 
        program_client_disconnect(pclient, TRUE);
 
@@ -549,7 +554,6 @@ void program_client_destroy(struct program_client **_pclient)
                pclient->destroy(pclient);
 
        pool_unref(&pclient->pool);
-       *_pclient = NULL;
 }
 
 void program_client_switch_ioloop(struct program_client *pclient)