dovecot-2.0: dict client: Allow connecting to server multiple ti...

dovecot at dovecot.org dovecot at dovecot.org
Fri Jun 4 20:26:09 EEST 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/24caf08ae7af
changeset: 11478:24caf08ae7af
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Jun 04 18:26:06 2010 +0100
description:
dict client: Allow connecting to server multiple times in a second.

diffstat:

 src/lib-dict/dict-client.c |  13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diffs (51 lines):

diff -r 0dfd28b930b3 -r 24caf08ae7af src/lib-dict/dict-client.c
--- a/src/lib-dict/dict-client.c	Fri Jun 04 18:05:28 2010 +0100
+++ b/src/lib-dict/dict-client.c	Fri Jun 04 18:26:06 2010 +0100
@@ -35,7 +35,7 @@
 	const char *path;
 	enum dict_data_type value_type;
 
-	time_t last_connect_try;
+	time_t last_failed_connect;
 	struct istream *input;
 	struct ostream *output;
 	struct io *io;
@@ -373,9 +373,11 @@
 
 static void client_dict_add_timeout(struct client_dict *dict)
 {
-	if (dict->to_idle != NULL)
+	if (dict->to_idle != NULL) {
+#if DICT_CLIENT_TIMEOUT_MSECS > 0
 		timeout_reset(dict->to_idle);
-	else if (client_dict_is_finished(dict)) {
+#endif
+	} else if (client_dict_is_finished(dict)) {
 		dict->to_idle = timeout_add(DICT_CLIENT_TIMEOUT_MSECS,
 					    client_dict_timeout, dict);
 	}
@@ -398,14 +400,14 @@
 
 	i_assert(dict->fd == -1);
 
-	if (dict->last_connect_try == ioloop_time) {
+	if (dict->last_failed_connect == ioloop_time) {
 		/* Try again later */
 		return -1;
 	}
-	dict->last_connect_try = ioloop_time;
 
 	dict->fd = net_connect_unix(dict->path);
 	if (dict->fd == -1) {
+		dict->last_failed_connect = ioloop_time;
 		i_error("net_connect_unix(%s) failed: %m", dict->path);
 		return -1;
 	}
@@ -424,6 +426,7 @@
 				DICT_CLIENT_PROTOCOL_MINOR_VERSION,
 				dict->value_type, dict->username, dict->uri);
 	if (client_dict_send_query(dict, query) < 0) {
+		dict->last_failed_connect = ioloop_time;
 		client_dict_disconnect(dict);
 		return -1;
 	}


More information about the dovecot-cvs mailing list