[dovecot-cvs] dovecot/src/lib-dict dict-client.c,1.10,1.11
cras at dovecot.org
cras at dovecot.org
Fri Jun 16 14:43:02 EEST 2006
Update of /var/lib/cvs/dovecot/src/lib-dict
In directory talvi:/tmp/cvs-serv9615
Modified Files:
dict-client.c
Log Message:
Fixes
Index: dict-client.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-dict/dict-client.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- dict-client.c 16 Jun 2006 09:52:25 -0000 1.10
+++ dict-client.c 16 Jun 2006 11:42:59 -0000 1.11
@@ -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,
More information about the dovecot-cvs
mailing list