fix assertion looking for connection in imap connection cache, r=standard8, sr=neil 454932

This commit is contained in:
David Bienvenu 2008-09-12 06:47:59 -07:00
Родитель fcd3301106
Коммит 97625ee0ed
1 изменённых файлов: 9 добавлений и 18 удалений

Просмотреть файл

@ -691,20 +691,17 @@ nsImapIncomingServer::GetImapConnection(nsIEventTarget *aEventTarget,
PRBool userCancelled = PR_FALSE; PRBool userCancelled = PR_FALSE;
// loop until we find a connection that can run the url, or doesn't have to wait? // 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]; connection = m_connectionCache[i];
if (connection) if (connection)
{ {
if (ConnectionTimeOut(connection)) PRBool badConnection = ConnectionTimeOut(connection);
if (!badConnection)
{ {
connection = nsnull; badConnection = NS_FAILED(connection->CanHandleUrl(aImapUrl,
i--; cnt--; // if the connection times out, we'll remove it from the array, &canRunUrlImmediately,
// so we need to adjust the array index. &canRunButBusy));
}
else
{
rv = connection->CanHandleUrl(aImapUrl, &canRunUrlImmediately, &canRunButBusy);
#ifdef DEBUG_bienvenu #ifdef DEBUG_bienvenu
nsCAutoString curSelectedFolderName; nsCAutoString curSelectedFolderName;
if (connection) if (connection)
@ -729,12 +726,11 @@ nsImapIncomingServer::GetImapConnection(nsIEventTarget *aEventTarget,
} }
#endif // DEBUG_bienvenu #endif // DEBUG_bienvenu
} }
} if (badConnection)
if (NS_FAILED(rv)) {
{
connection = nsnull; connection = nsnull;
rv = NS_OK; // don't want to return this error, just don't use the connection
continue; continue;
}
} }
// if this connection is wrong, but it's not busy, check if we should designate // 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; connection = nsnull;
} }
if (ConnectionTimeOut(connection))
connection = nsnull;
if (ConnectionTimeOut(freeConnection))
freeConnection = nsnull;
nsImapState requiredState; nsImapState requiredState;
aImapUrl->GetRequiredImapState(&requiredState); aImapUrl->GetRequiredImapState(&requiredState);
// refresh cnt in case we killed one or more dead connections. This // refresh cnt in case we killed one or more dead connections. This