]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
director: Don't handle pending requests from all around the code.
authorTimo Sirainen <tss@iki.fi>
Mon, 22 Oct 2012 12:20:57 +0000 (15:20 +0300)
committerTimo Sirainen <tss@iki.fi>
Mon, 22 Oct 2012 12:20:57 +0000 (15:20 +0300)
I'm not sure if this actually fixes any bugs, but it definitely makes the
state cleaner.

src/director/director.c
src/director/director.h

index 694df94a2cb97d5208d18e5847f8db8fada6bc68..016e1eb79df30f1245291fd4430fff3b7e714dbe 100644 (file)
@@ -787,11 +787,22 @@ void director_user_killed_everywhere(struct director *dir,
                user->username_hash));
 }
 
-void director_set_state_changed(struct director *dir)
+static void director_state_callback_timeout(struct director *dir)
 {
+       timeout_remove(&dir->to_callback);
        dir->state_change_callback(dir);
 }
 
+void director_set_state_changed(struct director *dir)
+{
+       /* we may get called to here from various places. use a timeout to
+          make sure the state callback is called with a clean state. */
+       if (dir->to_callback == NULL) {
+               dir->to_callback =
+                       timeout_add(0, director_state_callback_timeout, dir);
+       }
+}
+
 void director_update_send(struct director *dir, struct director_host *src,
                          const char *cmd)
 {
@@ -866,6 +877,8 @@ void director_deinit(struct director **_dir)
                timeout_remove(&dir->to_sync);
        if (dir->to_remove_dirs != NULL)
                timeout_remove(&dir->to_remove_dirs);
+       if (dir->to_callback != NULL)
+               timeout_remove(&dir->to_callback);
        while (array_count(&dir->dir_hosts) > 0) {
                hostp = array_idx(&dir->dir_hosts, 0);
                host = *hostp;
index 4fcbf07a4fe01bcf50dfcc4df9b49b2da916e2e3..725693995e183bda18c4077cb2866c19828e66f0 100644 (file)
@@ -44,6 +44,7 @@ struct director {
        ARRAY_DEFINE(connections, struct director_connection *);
        struct timeout *to_reconnect;
        struct timeout *to_sync;
+       struct timeout *to_callback;
 
        /* current mail hosts */
        struct mail_host_list *mail_hosts;