From: Timo Sirainen Date: Mon, 22 Oct 2012 12:20:57 +0000 (+0300) Subject: director: Don't handle pending requests from all around the code. X-Git-Tag: 2.2.alpha1~20^2~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3ee8a7ee6912c7caa4e83d3ce5a5db1590a7ffcd;p=thirdparty%2Fdovecot%2Fcore.git director: Don't handle pending requests from all around the code. I'm not sure if this actually fixes any bugs, but it definitely makes the state cleaner. --- diff --git a/src/director/director.c b/src/director/director.c index 694df94a2c..016e1eb79d 100644 --- a/src/director/director.c +++ b/src/director/director.c @@ -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; diff --git a/src/director/director.h b/src/director/director.h index 4fcbf07a4f..725693995e 100644 --- a/src/director/director.h +++ b/src/director/director.h @@ -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;