From 97625ee0ed37e9dc2951b8449d878101fb94b7ab Mon Sep 17 00:00:00 2001 From: David Bienvenu Date: Fri, 12 Sep 2008 06:47:59 -0700 Subject: [PATCH] fix assertion looking for connection in imap connection cache, r=standard8, sr=neil 454932 --- mailnews/imap/src/nsImapIncomingServer.cpp | 27 ++++++++-------------- 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/mailnews/imap/src/nsImapIncomingServer.cpp b/mailnews/imap/src/nsImapIncomingServer.cpp index 2f19efedad..e86e236afb 100644 --- a/mailnews/imap/src/nsImapIncomingServer.cpp +++ b/mailnews/imap/src/nsImapIncomingServer.cpp @@ -691,20 +691,17 @@ nsImapIncomingServer::GetImapConnection(nsIEventTarget *aEventTarget, PRBool userCancelled = PR_FALSE; // loop until we find a connection that can run the url, or doesn't have to wait? - for (PRInt32 i = 0; i < cnt && !canRunUrlImmediately && !canRunButBusy; i++) + for (PRInt32 i = cnt - 1; i >= 0 && !canRunUrlImmediately && !canRunButBusy; i--) { connection = m_connectionCache[i]; if (connection) { - if (ConnectionTimeOut(connection)) + PRBool badConnection = ConnectionTimeOut(connection); + if (!badConnection) { - connection = nsnull; - i--; cnt--; // if the connection times out, we'll remove it from the array, - // so we need to adjust the array index. - } - else - { - rv = connection->CanHandleUrl(aImapUrl, &canRunUrlImmediately, &canRunButBusy); + badConnection = NS_FAILED(connection->CanHandleUrl(aImapUrl, + &canRunUrlImmediately, + &canRunButBusy)); #ifdef DEBUG_bienvenu nsCAutoString curSelectedFolderName; if (connection) @@ -729,12 +726,11 @@ nsImapIncomingServer::GetImapConnection(nsIEventTarget *aEventTarget, } #endif // DEBUG_bienvenu } - } - if (NS_FAILED(rv)) - { + if (badConnection) + { connection = nsnull; - rv = NS_OK; // don't want to return this error, just don't use the connection continue; + } } // if this connection is wrong, but it's not busy, check if we should designate @@ -763,11 +759,6 @@ nsImapIncomingServer::GetImapConnection(nsIEventTarget *aEventTarget, connection = nsnull; } - if (ConnectionTimeOut(connection)) - connection = nsnull; - if (ConnectionTimeOut(freeConnection)) - freeConnection = nsnull; - nsImapState requiredState; aImapUrl->GetRequiredImapState(&requiredState); // refresh cnt in case we killed one or more dead connections. This