From: Timo Sirainen Date: Mon, 17 Feb 2003 13:38:38 +0000 (+0200) Subject: Rather than block for two seconds, we can just call ldap_result() again if X-Git-Tag: 1.1.alpha1~4925 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a8fc29f19ea6e2d472ba779b2dd5ca4e1f3dac79;p=thirdparty%2Fdovecot%2Fcore.git Rather than block for two seconds, we can just call ldap_result() again if it returns 0.. --HG-- branch : HEAD --- diff --git a/src/auth/db-ldap.c b/src/auth/db-ldap.c index 07bbf09ee5..935a17d562 100644 --- a/src/auth/db-ldap.c +++ b/src/auth/db-ldap.c @@ -14,8 +14,8 @@ #include -/* 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",