]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-dict: Moved/removed explicit stack frames in dict drivers.
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 6 May 2016 09:19:21 +0000 (12:19 +0300)
committerGitLab <gitlab@git.dovecot.net>
Sun, 8 May 2016 21:29:56 +0000 (00:29 +0300)
Added them back to dict_set/unset/atomic_inc() in dict.c. Others are
unlikely to be called many times.

src/lib-dict-extra/dict-ldap.c
src/lib-dict/dict-client.c
src/lib-dict/dict-memcached-ascii.c
src/lib-dict/dict-memcached.c
src/lib-dict/dict-redis.c
src/lib-dict/dict-sql.c
src/lib-dict/dict.c

index 8b797c0105b7a3031b96ff4c91bc9d52875acabd..6d460d063dbd7003175d8cd067a7355541c56aa8 100644 (file)
@@ -309,15 +309,13 @@ int ldap_dict_lookup(struct dict *dict, pool_t pool,
        pool_t orig_pool = pool;
        int ret;
 
-       T_BEGIN {
-               ldap_dict_lookup_async(dict, key, ldap_dict_lookup_done, &res);
+       ldap_dict_lookup_async(dict, key, ldap_dict_lookup_done, &res);
 
-               if ((ret = ldap_dict_wait(dict)) == 0) {
-                       if (res.ret == 0) {
-                               *value_r = p_strdup(orig_pool, res.value);
-                       } else ret = res.ret;
-               }
-       } T_END;
+       if ((ret = ldap_dict_wait(dict)) == 0) {
+               if (res.ret == 0) {
+                       *value_r = p_strdup(orig_pool, res.value);
+               } else ret = res.ret;
+       }
        return ret;
 }
 
@@ -383,30 +381,28 @@ void ldap_dict_lookup_async(struct dict *dict, const char *key,
 
        /* key needs to be transformed into something else */
        ARRAY_TYPE(const_string) values;
-       T_BEGIN {
-               const char *attributes[2] = {0, 0};
-               t_array_init(&values, 8);
-               const struct dict_ldap_map *map = ldap_dict_find_map(ctx, key, &values);
-
-               if (map != NULL) {
-                       op->map = map;
-                       attributes[0] = map->value_attribute;
-                       /* build lookup */
-                       memset(&input, 0, sizeof(input));
-                       input.base_dn = map->base_dn;
-                       input.scope = map->scope_val;
-                       ldap_dict_build_query(ctx, map, &values, strncmp(key, DICT_PATH_PRIVATE, strlen(DICT_PATH_PRIVATE))==0, query);
-                       input.filter = str_c(query);
-                       input.attributes = attributes;
-                       input.timeout_secs = ctx->set->timeout;
-                       ctx->pending++;
-                       ldap_search_start(ctx->client, &input, ldap_dict_lookup_callback, op);
-               } else {
-                       op->res.error = "no such key";
-                       callback(&(op->res), context);
-                       pool_unref(&oppool);
-               }
-       } T_END;
+       const char *attributes[2] = {0, 0};
+       t_array_init(&values, 8);
+       const struct dict_ldap_map *map = ldap_dict_find_map(ctx, key, &values);
+
+       if (map != NULL) {
+               op->map = map;
+               attributes[0] = map->value_attribute;
+               /* build lookup */
+               memset(&input, 0, sizeof(input));
+               input.base_dn = map->base_dn;
+               input.scope = map->scope_val;
+               ldap_dict_build_query(ctx, map, &values, strncmp(key, DICT_PATH_PRIVATE, strlen(DICT_PATH_PRIVATE))==0, query);
+               input.filter = str_c(query);
+               input.attributes = attributes;
+               input.timeout_secs = ctx->set->timeout;
+               ctx->pending++;
+               ldap_search_start(ctx->client, &input, ldap_dict_lookup_callback, op);
+       } else {
+               op->res.error = "no such key";
+               callback(&(op->res), context);
+               pool_unref(&oppool);
+       }
 }
 
 struct dict dict_driver_ldap = {
index 0766783b37ed240711a9f8a6001d3590ec1e6f03..7c7f75b90df73a6c4634b779d23b5ac0d8b32135 100644 (file)
@@ -198,17 +198,13 @@ client_dict_transaction_send_begin(struct client_dict_transaction_context *ctx)
        if (ctx->failed)
                return -1;
 
-       T_BEGIN {
-               const char *query;
-
-               query = t_strdup_printf("%c%u\n", DICT_PROTOCOL_CMD_BEGIN,
-                                       ctx->id);
-               if (client_dict_send_query(dict, query) < 0)
-                       ctx->failed = TRUE;
-               else
-                       ctx->connect_counter = dict->connect_counter;
-       } T_END;
+       const char *query;
 
+       query = t_strdup_printf("%c%u\n", DICT_PROTOCOL_CMD_BEGIN, ctx->id);
+       if (client_dict_send_query(dict, query) < 0)
+               ctx->failed = TRUE;
+       else
+               ctx->connect_counter = dict->connect_counter;
        return ctx->failed ? -1 : 0;
 }
 
@@ -594,17 +590,11 @@ static int client_dict_lookup(struct dict *_dict, pool_t pool,
                              const char *key, const char **value_r)
 {
        struct client_dict *dict = (struct client_dict *)_dict;
-       const char *line;
-       int ret;
+       const char *query, *line;
 
-       T_BEGIN {
-               const char *query;
-
-               query = t_strdup_printf("%c%s\n", DICT_PROTOCOL_CMD_LOOKUP,
-                                       dict_client_escape(key));
-               ret = client_dict_send_query(dict, query);
-       } T_END;
-       if (ret < 0)
+       query = t_strdup_printf("%c%s\n", DICT_PROTOCOL_CMD_LOOKUP,
+                               dict_client_escape(key));
+       if (client_dict_send_query(dict, query) < 0)
                return -1;
 
        /* read reply */
@@ -634,6 +624,8 @@ client_dict_iterate_init(struct dict *_dict, const char *const *paths,
 {
        struct client_dict *dict = (struct client_dict *)_dict;
         struct client_dict_iterate_context *ctx;
+       string_t *query = t_str_new(256);
+       unsigned int i;
 
        if (dict->in_iteration)
                i_panic("dict-client: Only one iteration supported");
@@ -643,19 +635,14 @@ client_dict_iterate_init(struct dict *_dict, const char *const *paths,
        ctx->ctx.dict = _dict;
        ctx->pool = pool_alloconly_create("client dict iteration", 512);
 
-       T_BEGIN {
-               string_t *query = t_str_new(256);
-               unsigned int i;
-
-               str_printfa(query, "%c%d", DICT_PROTOCOL_CMD_ITERATE, flags);
-               for (i = 0; paths[i] != NULL; i++) {
-                       str_append_c(query, '\t');
+       str_printfa(query, "%c%d", DICT_PROTOCOL_CMD_ITERATE, flags);
+       for (i = 0; paths[i] != NULL; i++) {
+               str_append_c(query, '\t');
                        str_append(query, dict_client_escape(paths[i]));
-               }
-               str_append_c(query, '\n');
-               if (client_dict_send_query(dict, str_c(query)) < 0)
-                       ctx->failed = TRUE;
-       } T_END;
+       }
+       str_append_c(query, '\n');
+       if (client_dict_send_query(dict, str_c(query)) < 0)
+               ctx->failed = TRUE;
        return &ctx->ctx;
 }
 
@@ -776,7 +763,7 @@ client_dict_transaction_commit(struct dict_transaction_context *_ctx,
        int ret = ctx->failed ? -1 : 1;
 
        ctx->committed = TRUE;
-       if (ctx->sent_begin && !ctx->failed) T_BEGIN {
+       if (ctx->sent_begin && !ctx->failed) {
                const char *query, *line;
 
                query = t_strdup_printf("%c%u\n", !async ?
@@ -823,7 +810,7 @@ client_dict_transaction_commit(struct dict_transaction_context *_ctx,
                                ret = -1;
                        }
                }
-       } T_END;
+       }
 
        if (ret < 0 || !async) {
                DLLIST_REMOVE(&dict->transactions, ctx);
@@ -841,13 +828,13 @@ client_dict_transaction_rollback(struct dict_transaction_context *_ctx)
                (struct client_dict_transaction_context *)_ctx;
        struct client_dict *dict = (struct client_dict *)_ctx->dict;
 
-       if (ctx->sent_begin) T_BEGIN {
+       if (ctx->sent_begin) {
                const char *query;
 
                query = t_strdup_printf("%c%u\n", DICT_PROTOCOL_CMD_ROLLBACK,
                                        ctx->id);
                client_dict_send_transaction_query(ctx, query);
-       } T_END;
+       }
 
        DLLIST_REMOVE(&dict->transactions, ctx);
        i_free(ctx);
@@ -860,16 +847,13 @@ static void client_dict_set(struct dict_transaction_context *_ctx,
 {
        struct client_dict_transaction_context *ctx =
                (struct client_dict_transaction_context *)_ctx;
+       const char *query;
 
-       T_BEGIN {
-               const char *query;
-
-               query = t_strdup_printf("%c%u\t%s\t%s\n",
-                                       DICT_PROTOCOL_CMD_SET, ctx->id,
-                                       dict_client_escape(key),
-                                       dict_client_escape(value));
-               client_dict_send_transaction_query(ctx, query);
-       } T_END;
+       query = t_strdup_printf("%c%u\t%s\t%s\n",
+                               DICT_PROTOCOL_CMD_SET, ctx->id,
+                               dict_client_escape(key),
+                               dict_client_escape(value));
+       client_dict_send_transaction_query(ctx, query);
 }
 
 static void client_dict_unset(struct dict_transaction_context *_ctx,
@@ -877,15 +861,12 @@ static void client_dict_unset(struct dict_transaction_context *_ctx,
 {
        struct client_dict_transaction_context *ctx =
                (struct client_dict_transaction_context *)_ctx;
+       const char *query;
 
-       T_BEGIN {
-               const char *query;
-
-               query = t_strdup_printf("%c%u\t%s\n",
-                                       DICT_PROTOCOL_CMD_UNSET, ctx->id,
-                                       dict_client_escape(key));
-               client_dict_send_transaction_query(ctx, query);
-       } T_END;
+       query = t_strdup_printf("%c%u\t%s\n",
+                               DICT_PROTOCOL_CMD_UNSET, ctx->id,
+                               dict_client_escape(key));
+       client_dict_send_transaction_query(ctx, query);
 }
 
 static void client_dict_atomic_inc(struct dict_transaction_context *_ctx,
@@ -893,14 +874,12 @@ static void client_dict_atomic_inc(struct dict_transaction_context *_ctx,
 {
        struct client_dict_transaction_context *ctx =
                (struct client_dict_transaction_context *)_ctx;
+       const char *query;
 
-       T_BEGIN {
-               const char *query;
-               query = t_strdup_printf("%c%u\t%s\t%lld\n",
-                                       DICT_PROTOCOL_CMD_ATOMIC_INC,
-                                       ctx->id, dict_client_escape(key), diff);
-               client_dict_send_transaction_query(ctx, query);
-       } T_END;
+       query = t_strdup_printf("%c%u\t%s\t%lld\n",
+                               DICT_PROTOCOL_CMD_ATOMIC_INC,
+                               ctx->id, dict_client_escape(key), diff);
+       client_dict_send_transaction_query(ctx, query);
 }
 
 struct dict dict_driver_client = {
index dfa5341e510f7d1c89aa48b1f8e39ffb31d60f76..1e36cac5c383ae3bdcdfdec316fab7acc3c53f71 100644 (file)
@@ -483,11 +483,12 @@ memcached_ascii_dict_get_full_key(struct memcached_ascii_dict *dict,
 }
 
 static int
-memcached_ascii_dict_lookup_real(struct memcached_ascii_dict *dict, pool_t pool,
-                                const char *key, const char **value_r)
+memcached_ascii_dict_lookup(struct dict *_dict, pool_t pool,
+                           const char *key, const char **value_r)
 {
-       enum memcached_ascii_input_state state = MEMCACHED_INPUT_STATE_GET;
+       struct memcached_ascii_dict *dict = (struct memcached_ascii_dict *)_dict;
        struct memcached_ascii_dict_reply *reply;
+       enum memcached_ascii_input_state state = MEMCACHED_INPUT_STATE_GET;
 
        if (memcached_ascii_connect(dict) < 0)
                return -1;
@@ -507,21 +508,6 @@ memcached_ascii_dict_lookup_real(struct memcached_ascii_dict *dict, pool_t pool,
        return dict->conn.value_received ? 1 : 0;
 }
 
-static int
-memcached_ascii_dict_lookup(struct dict *_dict, pool_t pool,
-                           const char *key, const char **value_r)
-{
-       struct memcached_ascii_dict *dict = (struct memcached_ascii_dict *)_dict;
-       int ret;
-
-       if (pool->datastack_pool)
-               ret = memcached_ascii_dict_lookup_real(dict, pool, key, value_r);
-       else T_BEGIN {
-               ret = memcached_ascii_dict_lookup_real(dict, pool, key, value_r);
-       } T_END;
-       return ret;
-}
-
 static struct dict_transaction_context *
 memcached_ascii_transaction_init(struct dict *_dict)
 {
index fd1cf1782b299cc2c23e16f66cc855d74685e551..f9bded4450cd9d026e4fe040b2f87217c0ae485e 100644 (file)
@@ -271,10 +271,10 @@ static void memcached_add_header(buffer_t *buf, unsigned int key_len)
        i_assert(buf->used == MEMCACHED_REQUEST_HDR_LENGTH);
 }
 
-static int
-memcached_dict_lookup_real(struct memcached_dict *dict, pool_t pool,
-                          const char *key, const char **value_r)
+static int memcached_dict_lookup(struct dict *_dict, pool_t pool,
+                                const char *key, const char **value_r)
 {
+       struct memcached_dict *dict = (struct memcached_dict *)_dict;
        struct ioloop *prev_ioloop = current_ioloop;
        struct timeout *to;
        unsigned int key_len;
@@ -360,20 +360,6 @@ memcached_dict_lookup_real(struct memcached_dict *dict, pool_t pool,
        return -1;
 }
 
-static int memcached_dict_lookup(struct dict *_dict, pool_t pool,
-                                const char *key, const char **value_r)
-{
-       struct memcached_dict *dict = (struct memcached_dict *)_dict;
-       int ret;
-
-       if (pool->datastack_pool)
-               ret = memcached_dict_lookup_real(dict, pool, key, value_r);
-       else T_BEGIN {
-               ret = memcached_dict_lookup_real(dict, pool, key, value_r);
-       } T_END;
-       return ret;
-}
-
 struct dict dict_driver_memcached = {
        .name = "memcached",
        {
index 205b3fb85985ca310ea1b79802a01f9e336cf11d..ca2688a685f294860dcf3410866437b87d54b0bb 100644 (file)
@@ -488,10 +488,10 @@ static void redis_dict_select_db(struct redis_dict *dict)
        redis_input_state_add(dict, REDIS_INPUT_STATE_SELECT);
 }
 
-static int
-redis_dict_lookup_real(struct redis_dict *dict, pool_t pool,
-                      const char *key, const char **value_r)
+static int redis_dict_lookup(struct dict *_dict, pool_t pool,
+                            const char *key, const char **value_r)
 {
+       struct redis_dict *dict = (struct redis_dict *)_dict;
        struct timeout *to;
        const char *cmd;
 
@@ -551,22 +551,6 @@ redis_dict_lookup_real(struct redis_dict *dict, pool_t pool,
        return 1;
 }
 
-static int redis_dict_lookup(struct dict *_dict, pool_t pool,
-                            const char *key, const char **value_r)
-{
-       struct redis_dict *dict = (struct redis_dict *)_dict;
-       int ret;
-
-       i_assert(!dict->transaction_open);
-
-       if (pool->datastack_pool)
-               ret = redis_dict_lookup_real(dict, pool, key, value_r);
-       else T_BEGIN {
-               ret = redis_dict_lookup_real(dict, pool, key, value_r);
-       } T_END;
-       return ret;
-}
-
 static struct dict_transaction_context *
 redis_transaction_init(struct dict *_dict)
 {
index ee9e94d6edaaa2f00284f5cb32126f6f5226f067..a60a1cdd6f6a4fc044f35f7093b78e4b329912d0 100644 (file)
@@ -424,23 +424,17 @@ static int sql_dict_lookup(struct dict *_dict, pool_t pool,
        struct sql_dict *dict = (struct sql_dict *)_dict;
        const struct dict_sql_map *map;
        struct sql_result *result = NULL;
+       string_t *query = t_str_new(256);
+       const char *error;
        int ret;
 
-       T_BEGIN {
-               string_t *query = t_str_new(256);
-               const char *error;
-
-               ret = sql_lookup_get_query(dict, key, query, &map, &error);
-               if (ret < 0)
-                       i_error("%s", error);
-               else
-                       result = sql_query_s(dict->db, str_c(query));
-       } T_END;
-
+       ret = sql_lookup_get_query(dict, key, query, &map, &error);
        if (ret < 0) {
+               i_error("%s", error);
                *value_r = NULL;
                return -1;
        }
+       result = sql_query_s(dict->db, str_c(query));
 
        ret = sql_result_next_row(result);
        if (ret <= 0) {
@@ -489,27 +483,24 @@ sql_dict_lookup_async(struct dict *_dict, const char *key,
        struct sql_dict *dict = (struct sql_dict *)_dict;
        const struct dict_sql_map *map;
        struct sql_dict_lookup_context *ctx;
+       string_t *query = t_str_new(256);
+       const char *error;
 
-       T_BEGIN {
-               string_t *query = t_str_new(256);
-               const char *error;
-
-               if (sql_lookup_get_query(dict, key, query, &map, &error) < 0) {
-                       struct dict_lookup_result result;
+       if (sql_lookup_get_query(dict, key, query, &map, &error) < 0) {
+               struct dict_lookup_result result;
 
-                       memset(&result, 0, sizeof(result));
-                       result.ret = -1;
-                       result.error = error;
-                       callback(&result, context);
-               } else {
-                       ctx = i_new(struct sql_dict_lookup_context, 1);
-                       ctx->callback = callback;
-                       ctx->context = context;
-                       ctx->map = map;
-                       sql_query(dict->db, str_c(query),
-                                 sql_dict_lookup_async_callback, ctx);
-               }
-       } T_END;
+               memset(&result, 0, sizeof(result));
+               result.ret = -1;
+               result.error = error;
+               callback(&result, context);
+       } else {
+               ctx = i_new(struct sql_dict_lookup_context, 1);
+               ctx->callback = callback;
+               ctx->context = context;
+               ctx->map = map;
+               sql_query(dict->db, str_c(query),
+                         sql_dict_lookup_async_callback, ctx);
+       }
 }
 
 static const struct dict_sql_map *
@@ -625,26 +616,23 @@ static int sql_dict_iterate_next_query(struct sql_dict_iterate_context *ctx,
                                       const char **error_r)
 {
        struct sql_dict *dict = (struct sql_dict *)ctx->ctx.dict;
+       string_t *query = t_str_new(256);
        char *error = NULL;
        int ret;
 
-       T_BEGIN {
-               string_t *query = t_str_new(256);
-
-               ret = sql_dict_iterate_build_next_query(ctx, query, error_r);
-               if (ret <= 0) {
-                       /* failed */
-                       error = i_strdup(*error_r);
-               } else if ((ctx->flags & DICT_ITERATE_FLAG_ASYNC) == 0) {
-                       ctx->result = sql_query_s(dict->db, str_c(query));
-               } else {
-                       i_assert(ctx->result == NULL);
-                       ctx->synchronous_result = TRUE;
-                       sql_query(dict->db, str_c(query),
-                                 sql_dict_iterate_callback, ctx);
-                       ctx->synchronous_result = FALSE;
-               }
-       } T_END;
+       ret = sql_dict_iterate_build_next_query(ctx, query, error_r);
+       if (ret <= 0) {
+               /* failed */
+               error = i_strdup(*error_r);
+       } else if ((ctx->flags & DICT_ITERATE_FLAG_ASYNC) == 0) {
+               ctx->result = sql_query_s(dict->db, str_c(query));
+       } else {
+               i_assert(ctx->result == NULL);
+               ctx->synchronous_result = TRUE;
+               sql_query(dict->db, str_c(query),
+                         sql_dict_iterate_callback, ctx);
+               ctx->synchronous_result = FALSE;
+       }
        *error_r = t_strdup(error);
        i_free(error);
        return ret;
@@ -1001,6 +989,9 @@ static void sql_dict_set(struct dict_transaction_context *_ctx,
        struct sql_dict *dict = (struct sql_dict *)_ctx->dict;
        const struct dict_sql_map *map;
        ARRAY_TYPE(const_string) values;
+       struct dict_sql_build_query build;
+       struct dict_sql_build_query_field field;
+       const char *query, *error;
 
        map = sql_dict_find_map(dict, key, &values);
        if (map == NULL) {
@@ -1012,29 +1003,23 @@ static void sql_dict_set(struct dict_transaction_context *_ctx,
        if (ctx->prev_inc_map != NULL)
                sql_dict_prev_inc_flush(ctx);
 
-       T_BEGIN {
-               struct dict_sql_build_query build;
-               struct dict_sql_build_query_field field;
-               const char *query, *error;
+       field.map = map;
+       field.value = value;
 
-               field.map = map;
-               field.value = value;
-
-               memset(&build, 0, sizeof(build));
-               build.dict = dict;
-               t_array_init(&build.fields, 1);
-               array_append(&build.fields, &field, 1);
-               build.extra_values = &values;
-               build.key1 = key[0];
+       memset(&build, 0, sizeof(build));
+       build.dict = dict;
+       t_array_init(&build.fields, 1);
+       array_append(&build.fields, &field, 1);
+       build.extra_values = &values;
+       build.key1 = key[0];
 
-               if (sql_dict_set_query(&build, &query, &error) < 0) {
-                       i_error("dict-sql: Failed to set %s=%s: %s",
-                               key, value, error);
-                       ctx->failed = TRUE;
-               } else {
-                       sql_update(ctx->sql_ctx, query);
-               }
-       } T_END;
+       if (sql_dict_set_query(&build, &query, &error) < 0) {
+               i_error("dict-sql: Failed to set %s=%s: %s",
+                       key, value, error);
+               ctx->failed = TRUE;
+       } else {
+               sql_update(ctx->sql_ctx, query);
+       }
 }
 
 static void sql_dict_unset(struct dict_transaction_context *_ctx,
@@ -1045,6 +1030,8 @@ static void sql_dict_unset(struct dict_transaction_context *_ctx,
        struct sql_dict *dict = (struct sql_dict *)_ctx->dict;
        const struct dict_sql_map *map;
        ARRAY_TYPE(const_string) values;
+       string_t *query = t_str_new(256);
+       const char *error;
 
        if (ctx->prev_inc_map != NULL)
                sql_dict_prev_inc_flush(ctx);
@@ -1056,19 +1043,14 @@ static void sql_dict_unset(struct dict_transaction_context *_ctx,
                return;
        }
 
-       T_BEGIN {
-               string_t *query = t_str_new(256);
-               const char *error;
-
-               str_printfa(query, "DELETE FROM %s", map->table);
-               if (sql_dict_where_build(dict, map, &values, key[0],
-                                        SQL_DICT_RECURSE_NONE, query, &error) < 0) {
-                       i_error("dict-sql: Failed to delete %s: %s", key, error);
-                       ctx->failed = TRUE;
-               } else {
-                       sql_update(ctx->sql_ctx, str_c(query));
-               }
-       } T_END;
+       str_printfa(query, "DELETE FROM %s", map->table);
+       if (sql_dict_where_build(dict, map, &values, key[0],
+                                SQL_DICT_RECURSE_NONE, query, &error) < 0) {
+               i_error("dict-sql: Failed to delete %s: %s", key, error);
+               ctx->failed = TRUE;
+       } else {
+               sql_update(ctx->sql_ctx, str_c(query));
+       }
 }
 
 static unsigned int *
@@ -1093,34 +1075,31 @@ static void sql_dict_atomic_inc_real(struct sql_dict_transaction_context *ctx,
        struct sql_dict *dict = (struct sql_dict *)ctx->ctx.dict;
        const struct dict_sql_map *map;
        ARRAY_TYPE(const_string) values;
+       struct dict_sql_build_query build;
+       struct dict_sql_build_query_field field;
+       const char *query, *error;
 
        map = sql_dict_find_map(dict, key, &values);
        i_assert(map != NULL);
 
-       T_BEGIN {
-               struct dict_sql_build_query build;
-               struct dict_sql_build_query_field field;
-               const char *query, *error;
-
-               field.map = map;
-               field.value = t_strdup_printf("%lld", diff);
+       field.map = map;
+       field.value = t_strdup_printf("%lld", diff);
 
-               memset(&build, 0, sizeof(build));
-               build.dict = dict;
-               t_array_init(&build.fields, 1);
-               array_append(&build.fields, &field, 1);
-               build.extra_values = &values;
-               build.key1 = key[0];
-               build.inc = TRUE;
+       memset(&build, 0, sizeof(build));
+       build.dict = dict;
+       t_array_init(&build.fields, 1);
+       array_append(&build.fields, &field, 1);
+       build.extra_values = &values;
+       build.key1 = key[0];
+       build.inc = TRUE;
 
-               if (sql_dict_update_query(&build, &query, &error) < 0) {
-                       i_error("dict-sql: Failed to increase %s: %s", key, error);
-                       ctx->failed = TRUE;
-               } else {
-                       sql_update_get_rows(ctx->sql_ctx, query,
-                                           sql_dict_next_inc_row(ctx));
-               }
-       } T_END;
+       if (sql_dict_update_query(&build, &query, &error) < 0) {
+               i_error("dict-sql: Failed to increase %s: %s", key, error);
+               ctx->failed = TRUE;
+       } else {
+               sql_update_get_rows(ctx->sql_ctx, query,
+                                   sql_dict_next_inc_row(ctx));
+       }
 }
 
 static void sql_dict_prev_inc_flush(struct sql_dict_transaction_context *ctx)
@@ -1195,7 +1174,7 @@ static void sql_dict_atomic_inc(struct dict_transaction_context *_ctx,
                                         ctx->prev_inc_key, key, &values)) {
                sql_dict_prev_inc_flush(ctx);
                sql_dict_atomic_inc_real(ctx, key, diff);
-       } else T_BEGIN {
+       } else {
                struct dict_sql_build_query build;
                struct dict_sql_build_query_field *field;
                const char *query, *error;
@@ -1224,7 +1203,7 @@ static void sql_dict_atomic_inc(struct dict_transaction_context *_ctx,
 
                i_free_and_null(ctx->prev_inc_key);
                ctx->prev_inc_map = NULL;
-       } T_END;
+       }
 }
 
 static struct dict sql_dict = {
index a45af846f58116844790c1a2b8205293420d7730..5e2b08ca3b9627f78497c98e0e985909ca5f88fc 100644 (file)
@@ -216,7 +216,9 @@ void dict_set(struct dict_transaction_context *ctx,
 {
        i_assert(dict_key_prefix_is_valid(key));
 
-       ctx->dict->v.set(ctx, key, value);
+       T_BEGIN {
+               ctx->dict->v.set(ctx, key, value);
+       } T_END;
        ctx->changed = TRUE;
 }
 
@@ -225,7 +227,9 @@ void dict_unset(struct dict_transaction_context *ctx,
 {
        i_assert(dict_key_prefix_is_valid(key));
 
-       ctx->dict->v.unset(ctx, key);
+       T_BEGIN {
+               ctx->dict->v.unset(ctx, key);
+       } T_END;
        ctx->changed = TRUE;
 }
 
@@ -234,10 +238,10 @@ void dict_atomic_inc(struct dict_transaction_context *ctx,
 {
        i_assert(dict_key_prefix_is_valid(key));
 
-       if (diff != 0) {
+       if (diff != 0) T_BEGIN {
                ctx->dict->v.atomic_inc(ctx, key, diff);
                ctx->changed = TRUE;
-       }
+       } T_END;
 }
 
 const char *dict_escape_string(const char *str)