Mercurial > dovecot > original-hg > dovecot-1.2
changeset 4385:2c4a39afea07 HEAD
Fixes
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Fri, 16 Jun 2006 14:42:59 +0300 |
parents | a8979ba36c74 |
children | e23469650c85 |
files | src/lib-dict/dict-client.c |
diffstat | 1 files changed, 25 insertions(+), 32 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-dict/dict-client.c Fri Jun 16 14:42:30 2006 +0300 +++ b/src/lib-dict/dict-client.c Fri Jun 16 14:42:59 2006 +0300 @@ -163,6 +163,15 @@ { struct client_dict *dict = (struct client_dict *)ctx->ctx.dict; + if (ctx->connect_counter != dict->connect_counter || ctx->failed) + return -1; + + if (dict->output == NULL) { + /* not connected currently */ + if (client_dict_connect(dict) < 0) + return -1; + } + if (o_stream_send_str(dict->output, query) < 0 || o_stream_flush(dict->output) < 0) { /* Send failed. Our transactions have died, so don't even try @@ -421,25 +430,20 @@ const char *query, *line; int ret = ctx->failed ? -1 : 0; - if (ctx->connect_counter != dict->connect_counter) + t_push(); + query = t_strdup_printf("%c%u\n", !ctx->failed ? + DICT_PROTOCOL_CMD_COMMIT : + DICT_PROTOCOL_CMD_ROLLBACK, ctx->id); + if (client_dict_send_transaction_query(ctx, query) < 0) ret = -1; - else { - t_push(); - query = t_strdup_printf("%c%u\n", !ctx->failed ? - DICT_PROTOCOL_CMD_COMMIT : - DICT_PROTOCOL_CMD_ROLLBACK, - ctx->id); - if (client_dict_send_transaction_query(ctx, query) < 0) + else if (ret == 0) { + /* read reply */ + line = client_dict_read_line(dict); + if (line == NULL || *line != DICT_PROTOCOL_REPLY_OK) ret = -1; - else if (ret == 0) { - /* read reply */ - line = client_dict_read_line(dict); - if (line == NULL || *line != DICT_PROTOCOL_REPLY_OK) - ret = -1; - } + } - t_pop(); - } + t_pop(); i_free(ctx); return ret; @@ -450,16 +454,13 @@ { struct client_dict_transaction_context *ctx = (struct client_dict_transaction_context *)_ctx; - struct client_dict *dict = (struct client_dict *)_ctx->dict; const char *query; - if (ctx->connect_counter == dict->connect_counter) { - t_push(); - query = t_strdup_printf("%c%u\n", DICT_PROTOCOL_CMD_ROLLBACK, - ctx->id); - (void)client_dict_send_transaction_query(ctx, query); - t_pop(); - } + t_push(); + query = t_strdup_printf("%c%u\n", DICT_PROTOCOL_CMD_ROLLBACK, ctx->id); + (void)client_dict_send_transaction_query(ctx, query); + t_pop(); + i_free(ctx); } @@ -468,12 +469,8 @@ { struct client_dict_transaction_context *ctx = (struct client_dict_transaction_context *)_ctx; - struct client_dict *dict = (struct client_dict *)_ctx->dict; const char *query; - if (ctx->connect_counter != dict->connect_counter) - return; - t_push(); query = t_strdup_printf("%c%u\t%s\t%s\n", DICT_PROTOCOL_CMD_SET, ctx->id, @@ -488,12 +485,8 @@ { struct client_dict_transaction_context *ctx = (struct client_dict_transaction_context *)_ctx; - struct client_dict *dict = (struct client_dict *)_ctx->dict; const char *query; - if (ctx->connect_counter != dict->connect_counter) - return; - t_push(); query = t_strdup_printf("%c%u\t%s\t%lld\n", DICT_PROTOCOL_CMD_ATOMIC_INC,