dovecot-2.2: auth: Added hardcoded 5 second timeout to LDAP conn...

dovecot at dovecot.org dovecot at dovecot.org
Wed Nov 11 11:16:06 UTC 2015


details:   http://hg.dovecot.org/dovecot-2.2/rev/ca91d540fd87
changeset: 19350:ca91d540fd87
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Nov 11 13:15:30 2015 +0200
description:
auth: Added hardcoded 5 second timeout to LDAP connect()
Although it doesn't look like the timeout is exactly 5 seconds always due to
OpenSSL's internal workings, but this should be good enough.

diffstat:

 src/auth/db-ldap.c |  12 ++++++++++++
 src/auth/db-ldap.h |   2 ++
 2 files changed, 14 insertions(+), 0 deletions(-)

diffs (34 lines):

diff -r 0b1c73b01a5a -r ca91d540fd87 src/auth/db-ldap.c
--- a/src/auth/db-ldap.c	Tue Nov 10 10:00:11 2015 +0200
+++ b/src/auth/db-ldap.c	Wed Nov 11 13:15:30 2015 +0200
@@ -1096,6 +1096,18 @@
 	unsigned int ldap_version;
 	int value;
 
+#ifdef LDAP_OPT_NETWORK_TIMEOUT
+	struct timeval tv;
+	int ret;
+
+	tv.tv_sec = DB_LDAP_CONNECT_TIMEOUT_SECS; tv.tv_usec = 0;
+	ret = ldap_set_option(conn->ld, LDAP_OPT_NETWORK_TIMEOUT, &tv);
+	if (ret != LDAP_SUCCESS) {
+		i_fatal("LDAP %s: Can't set network-timeout: %s",
+			conn->config_path, ldap_err2string(ret));
+	}
+#endif
+
 	db_ldap_set_opt(conn, conn->ld, LDAP_OPT_DEREF, &conn->set.ldap_deref,
 			"deref", conn->set.deref);
 #ifdef LDAP_OPT_DEBUG_LEVEL
diff -r 0b1c73b01a5a -r ca91d540fd87 src/auth/db-ldap.h
--- a/src/auth/db-ldap.h	Tue Nov 10 10:00:11 2015 +0200
+++ b/src/auth/db-ldap.h	Wed Nov 11 13:15:30 2015 +0200
@@ -7,6 +7,8 @@
 
 /* Maximum number of pending requests before delaying new requests. */
 #define DB_LDAP_MAX_PENDING_REQUESTS 8
+/* connect() timeout to LDAP */
+#define DB_LDAP_CONNECT_TIMEOUT_SECS 5
 /* If LDAP connection is down, fail requests after waiting for this long. */
 #define DB_LDAP_REQUEST_DISCONNECT_TIMEOUT_SECS 4
 /* If request is still in queue after this many seconds and other requests


More information about the dovecot-cvs mailing list