]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Rather than block for two seconds, we can just call ldap_result() again if
authorTimo Sirainen <tss@iki.fi>
Mon, 17 Feb 2003 13:38:38 +0000 (15:38 +0200)
committerTimo Sirainen <tss@iki.fi>
Mon, 17 Feb 2003 13:38:38 +0000 (15:38 +0200)
it returns 0..

--HG--
branch : HEAD

src/auth/db-ldap.c

index 07bbf09ee508cea3db3136ec4a1e461e3fb2a2fb..935a17d562d27ec6e528c2a7f2c3bf31e07ccba4 100644 (file)
@@ -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 @@ static void ldap_input(void *context)
 
        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",