]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-dict: Changed dict_wait() to return void.
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 6 May 2016 10:10:42 +0000 (13:10 +0300)
committerGitLab <gitlab@git.dovecot.net>
Sun, 8 May 2016 21:29:56 +0000 (00:29 +0300)
If it encounters any failures, it should just make sure to abort any pending
async requests before returning.

src/lib-dict-extra/dict-ldap.c
src/lib-dict/dict-client.c
src/lib-dict/dict-private.h
src/lib-dict/dict-sql.c
src/lib-dict/dict.c
src/lib-dict/dict.h
src/lib-storage/index/index-storage.c
src/lib-storage/mail-user.c
src/plugins/last-login/last-login-plugin.c
src/plugins/quota/quota-dict.c

index 9dd151bf712ba2a3241aead4f7f666bd4df24e9e..a80f9d20fdb0f8f60d8cb269f39a06bc074764ee 100644 (file)
@@ -232,8 +232,8 @@ void ldap_dict_deinit(struct dict *dict)
        pool_unref(&ctx->pool);
 }
 
-static
-int ldap_dict_wait(struct dict *dict) {
+static void ldap_dict_wait(struct dict *dict)
+{
        struct ldap_dict *ctx = (struct ldap_dict *)dict;
 
        i_assert(ctx->ioloop == NULL);
@@ -251,8 +251,6 @@ int ldap_dict_wait(struct dict *dict) {
        io_loop_set_current(ctx->ioloop);
        io_loop_destroy(&ctx->ioloop);
        ctx->prev_ioloop = NULL;
-
-       return 0;
 }
 
 static
@@ -309,10 +307,7 @@ ldap_dict_lookup(struct dict *dict, pool_t pool, const char *key,
 
        ldap_dict_lookup_async(dict, key, ldap_dict_lookup_done, &res);
 
-       if (ldap_dict_wait(dict) < 0) {
-               *error_r = "ldap: Communication failure";
-               return -1;
-       }
+       ldap_dict_wait(dict);
        if (res.ret < 0) {
                *error_r = res.error;
                return -1;
index 83e71e568edf1126e9502ed5d814cd4165b4fe53..efdf32d1a462d28a1633e62daaa850c08ed51f67 100644 (file)
@@ -572,7 +572,7 @@ static void client_dict_deinit(struct dict *_dict)
        pool_unref(&dict->pool);
 }
 
-static int client_dict_wait(struct dict *_dict)
+static void client_dict_wait(struct dict *_dict)
 {
        struct client_dict *dict = (struct client_dict *)_dict;
        const char *error;
@@ -593,7 +593,6 @@ static int client_dict_wait(struct dict *_dict)
        }
        /* we should have aborted all the async calls if we disconnected */
        i_assert(dict->async_commits == 0);
-       return 0;
 }
 
 static int client_dict_lookup(struct dict *_dict, pool_t pool, const char *key,
index 1d2b00ec4ded35b0f344320a6c01730b95fa0087..3d1c89bbab5f4ecfdeb0f12f16963cfdc10dbedf 100644 (file)
@@ -8,7 +8,7 @@ struct dict_vfuncs {
                    const struct dict_settings *set,
                    struct dict **dict_r, const char **error_r);
        void (*deinit)(struct dict *dict);
-       int (*wait)(struct dict *dict);
+       void (*wait)(struct dict *dict);
 
        int (*lookup)(struct dict *dict, pool_t pool,
                      const char *key, const char **value_r,
index 290a024e8c02c15ddee0daea6b7545229f0051b2..58bae58a8c6055498f53a1ee78a30aeb21addc1a 100644 (file)
@@ -111,10 +111,9 @@ static void sql_dict_deinit(struct dict *_dict)
        pool_unref(&dict->pool);
 }
 
-static int sql_dict_wait(struct dict *dict ATTR_UNUSED)
+static void sql_dict_wait(struct dict *dict ATTR_UNUSED)
 {
        /* FIXME: lib-sql doesn't support this yet */
-       return 0;
 }
 
 static bool
index bad2ee7a72a6bf2f23cc7a523c6ce53eb38e29c2..45fd8017b0ef280f5208b632294a01fae9881765 100644 (file)
@@ -88,9 +88,10 @@ void dict_deinit(struct dict **_dict)
        dict->v.deinit(dict);
 }
 
-int dict_wait(struct dict *dict)
+void dict_wait(struct dict *dict)
 {
-       return dict->v.wait == NULL ? 1 : dict->v.wait(dict);
+       if (dict->v.wait != NULL)
+               dict->v.wait(dict);
 }
 
 static bool dict_key_prefix_is_valid(const char *key)
index 53e9d73c841b55f9a8b6e9aaf2e49ea327e9fa0a..7b674ca068eb5a51133a03be03654efb8146ba01 100644 (file)
@@ -64,9 +64,8 @@ int dict_init(const char *uri, const struct dict_settings *set,
              struct dict **dict_r, const char **error_r);
 /* Close dictionary. */
 void dict_deinit(struct dict **dict);
-/* Wait for all pending asynchronous operations to finish.
-   Returns 0 if ok, -1 if error. */
-int dict_wait(struct dict *dict);
+/* Wait for all pending asynchronous operations to finish. */
+void dict_wait(struct dict *dict);
 
 /* Lookup value for key. Set it to NULL if it's not found.
    Returns 1 if found, 0 if not found and -1 if lookup failed. */
index 339ebbb7d106b3427b56896686285967daedde8f..b4fbe858d015bc670eec388511494baeb3eae8c1 100644 (file)
@@ -943,7 +943,7 @@ int index_storage_set_subscribed(struct mailbox *box, bool set)
 void index_storage_destroy(struct mail_storage *storage)
 {
        if (storage->_shared_attr_dict != NULL) {
-               (void)dict_wait(storage->_shared_attr_dict);
+               dict_wait(storage->_shared_attr_dict);
                dict_deinit(&storage->_shared_attr_dict);
        }
 }
index 9078d32f4e6a9c04b18f4fb87ad319f9cf0f03a3..bf0b2d0ff68d3caedba2af6430144b73a6cf16bc 100644 (file)
@@ -31,7 +31,7 @@ struct auth_master_connection *mail_user_auth_master_conn;
 static void mail_user_deinit_base(struct mail_user *user)
 {
        if (user->_attr_dict != NULL) {
-               (void)dict_wait(user->_attr_dict);
+               dict_wait(user->_attr_dict);
                dict_deinit(&user->_attr_dict);
        }
        mail_namespaces_deinit(&user->namespaces);
index 54a8d1de1b2aac387c744756c99094a0258506f2..e091dc8f111f412507c828100d1b0ee064765563 100644 (file)
@@ -30,7 +30,7 @@ static void last_login_dict_deinit(struct mail_user *user)
        struct last_login_user *luser = LAST_LOGIN_USER_CONTEXT(user);
 
        if (luser->dict != NULL) {
-               (void)dict_wait(luser->dict);
+               dict_wait(luser->dict);
                dict_deinit(&luser->dict);
        }
        /* remove timeout after dict_wait(), which may trigger
index e357a6770646c02d14a9deac304fc4007b4c0ba8..3fdfe113c43bc2712e8b0829aae9d51649a7bedb 100644 (file)
@@ -242,10 +242,10 @@ static void dict_quota_flush(struct quota_root *_root)
 {
        struct dict_quota_root *root = (struct dict_quota_root *)_root;
 
-       (void)dict_wait(root->dict);
+       dict_wait(root->dict);
        if (root->to_update != NULL) {
                dict_quota_recalc_timeout(root);
-               (void)dict_wait(root->dict);
+               dict_wait(root->dict);
        }
 }