# HG changeset patch # User Timo Sirainen # Date 1445335944 -10800 # Node ID 467695fee3739e1f336b4299bba90cf4a288e3ed # Parent 0f5e58361c48aa5c6298aed7e16dfa1ff440d31c dict-sql: Fixed async iteration with MySQL and SQLite diff -r 0f5e58361c48 -r 467695fee373 src/lib-dict/dict-sql.c --- a/src/lib-dict/dict-sql.c Tue Oct 20 00:25:14 2015 +0300 +++ b/src/lib-dict/dict-sql.c Tue Oct 20 13:12:24 2015 +0300 @@ -45,6 +45,7 @@ const struct dict_sql_map *map; unsigned int key_prefix_len, pattern_prefix_len, next_map_idx; unsigned int path_idx, sql_fields_start_idx; + bool synchronous_result; bool failed; }; @@ -616,7 +617,7 @@ { sql_result_ref(result); ctx->result = result; - if (ctx->ctx.async_callback != NULL) + if (ctx->ctx.async_callback != NULL && !ctx->synchronous_result) ctx->ctx.async_callback(ctx->ctx.async_context); } @@ -638,8 +639,10 @@ 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; *error_r = t_strdup(error);