[dovecot-cvs] dovecot/src/lib-dict dict-client.c,1.8.2.2,1.8.2.3

cras at dovecot.org cras at dovecot.org
Fri Jun 16 14:42:58 EEST 2006


Update of /var/lib/cvs/dovecot/src/lib-dict
In directory talvi:/tmp/cvs-serv9105

Modified Files:
      Tag: branch_1_0
	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.8.2.2
retrieving revision 1.8.2.3
diff -u -d -r1.8.2.2 -r1.8.2.3
--- dict-client.c	14 Jun 2006 12:46:58 -0000	1.8.2.2
+++ dict-client.c	16 Jun 2006 11:42:56 -0000	1.8.2.3
@@ -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