[dovecot-cvs] dovecot/src/dict dict-cache.c, 1.1, 1.2 dict-server.c, 1.4, 1.5

cras at dovecot.org cras at dovecot.org
Wed Jan 11 23:48:17 EET 2006


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

Modified Files:
	dict-cache.c dict-server.c 
Log Message:
Fixes to dict proxy.



Index: dict-cache.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/dict/dict-cache.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- dict-cache.c	30 Dec 2005 22:09:03 -0000	1.1
+++ dict-cache.c	11 Jan 2006 21:48:14 -0000	1.2
@@ -40,6 +40,7 @@
 		entry = i_new(struct dict_entry, 1);
 		entry->dict = dict_init(uri);
 		entry->uri = i_strdup(uri);
+		hash_insert(cache->dicts, entry->uri, entry);
 	}
 	entry->refcount++;
 	return entry->dict;

Index: dict-server.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/dict/dict-server.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- dict-server.c	30 Dec 2005 22:19:55 -0000	1.4
+++ dict-server.c	11 Jan 2006 21:48:14 -0000	1.5
@@ -60,10 +60,11 @@
 	/* <key> */
 	ret = dict_lookup(conn->dict, pool_datastack_create(), line, &value);
 	if (ret > 0) {
-		reply = t_strdup_printf("%c%s", DICT_PROTOCOL_REPLY_OK, value);
+		reply = t_strdup_printf("%c%s\n",
+					DICT_PROTOCOL_REPLY_OK, value);
 		o_stream_send_str(conn->output, reply);
 	} else {
-		reply = t_strdup_printf("%c", ret == 0 ?
+		reply = t_strdup_printf("%c\n", ret == 0 ?
 					DICT_PROTOCOL_REPLY_NOTFOUND :
 					DICT_PROTOCOL_REPLY_FAIL);
 		o_stream_send_str(conn->output, reply);
@@ -91,7 +92,7 @@
 		/* FIXME: we don't want to keep blocking here. set a flush
 		   function and send the replies there when buffer gets full */
 		t_push();
-		reply = t_strdup_printf("%s\t%s", key, value);
+		reply = t_strdup_printf("%s\t%s\n", key, value);
 		o_stream_send_str(conn->output, reply);
 		t_pop();
 	}
@@ -193,7 +194,7 @@
 		return -1;
 
 	ret = dict_transaction_commit(trans->ctx);
-	reply = t_strdup_printf("%c", ret == 0 ? DICT_PROTOCOL_REPLY_OK :
+	reply = t_strdup_printf("%c\n", ret == 0 ? DICT_PROTOCOL_REPLY_OK :
 				DICT_PROTOCOL_REPLY_FAIL);
 	o_stream_send_str(conn->output, reply);
 	dict_server_transaction_array_remove(conn, trans);
@@ -298,6 +299,9 @@
 	/* the rest is dict URI */
 	conn->uri = i_strdup(line);
 	conn->dict = dict_cache_get(conn->server->cache, conn->uri);
+	if (conn->dict == NULL)
+		return -1;
+
 	return 0;
 }
 
@@ -356,10 +360,12 @@
 	const struct dict_server_transaction *transactions;
 	unsigned int i, count;
 
-	transactions = array_get(&conn->transactions, &count);
-	for (i = 0; i < count; i++)
-                dict_transaction_rollback(transactions[i].ctx);
-	array_free(&conn->transactions);
+	if (array_is_created(&conn->transactions)) {
+		transactions = array_get(&conn->transactions, &count);
+		for (i = 0; i < count; i++)
+			dict_transaction_rollback(transactions[i].ctx);
+		array_free(&conn->transactions);
+	}
 
 	io_remove(conn->io);
 	i_stream_unref(conn->input);



More information about the dovecot-cvs mailing list