changeset 1181:ac7dbb236b59 HEAD

Rather than block for two seconds, we can just call ldap_result() again if it returns 0..
author Timo Sirainen <tss@iki.fi>
date Mon, 17 Feb 2003 15:38:38 +0200
parents 930452c85250
children 27fb52c532a4
files src/auth/db-ldap.c
diffstat 1 files changed, 8 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/auth/db-ldap.c	Fri Feb 14 17:23:34 2003 +0200
+++ b/src/auth/db-ldap.c	Mon Feb 17 15:38:38 2003 +0200
@@ -14,8 +14,8 @@
 
 #include <stddef.h>
 
-/* This may block the process for two seconds, but at least it works. */
-#if LDAP_VENDOR_VERSION <= 20026
+/* Older versions may require calling ldap_result() twice */
+#if LDAP_VENDOR_VERSION <= 20112
 #  define OPENLDAP_ASYNC_WORKAROUND
 #endif
 
@@ -130,12 +130,14 @@
 
 	for (;;) {
 		memset(&timeout, 0, sizeof(timeout));
+		ret = ldap_result(conn->ld, LDAP_RES_ANY, 1, &timeout, &res);
 #ifdef OPENLDAP_ASYNC_WORKAROUND
-		/* we may block, but at least we work */
-		timeout.tv_sec = 2;
+		if (ret == 0) {
+			/* try again, there may be another in buffer */
+			ret = ldap_result(conn->ld, LDAP_RES_ANY, 1,
+					  &timeout, &res);
+		}
 #endif
-
-		ret = ldap_result(conn->ld, LDAP_RES_ANY, 1, &timeout, &res);
 		if (ret <= 0) {
 			if (ret < 0) {
 				i_error("LDAP: ldap_result() failed: %s",