From f05357e9a75cf550eaff6a308909cf98d6628b29 Mon Sep 17 00:00:00 2001 From: "leif%netscape.com" Date: Wed, 22 Aug 2001 01:30:19 +0000 Subject: [PATCH] Bug 85452, 100% CPU usage in LDAP autocomplete. r=dmose, sr=mscott, patch=leif. --- directory/xpcom/base/src/nsLDAPConnection.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/directory/xpcom/base/src/nsLDAPConnection.cpp b/directory/xpcom/base/src/nsLDAPConnection.cpp index e59210d49f1b..41aae24a5101 100644 --- a/directory/xpcom/base/src/nsLDAPConnection.cpp +++ b/directory/xpcom/base/src/nsLDAPConnection.cpp @@ -561,7 +561,7 @@ nsLDAPConnectionLoop::Run(void) LDAPMessage *msgHandle; nsCOMPtr msg; struct timeval timeout = { 1, 0 }; - PRIntervalTime sleepTime = PR_MillisecondsToInterval(10); + PRIntervalTime sleepTime = PR_MillisecondsToInterval(40); PR_LOG(gLDAPLogModule, PR_LOG_DEBUG, ("nsLDAPConnection::Run() entered\n")); @@ -644,10 +644,19 @@ nsLDAPConnectionLoop::Run(void) lderrno = ldap_get_lderrno(rawConn->mConnectionHandle, 0, 0); + // Sleep briefly, to avoid a very busy loop again. + // + PR_Sleep(sleepTime); + switch (lderrno) { case LDAP_SERVER_DOWN: - // XXXreconnect or fail ? + // We might want to shutdown the thread here, but it has + // implications to the user of the nsLDAPConnection, so + // for now we just ignore it. It's up to the owner of + // the nsLDAPConnection to detect the error, and then + // create a new connection. + // break; case LDAP_DECODING_ERROR: