fix retry on imap auth error if server drops connection,r=mconley,a=Standard8 bug 760624
authorDavid Bienvenu <bienvenu@nventure.com>
Fri, 01 Jun 2012 13:11:48 -0700
changeset 30809 0c203b72f169476543598e29b74348fa3e166e1d
parent 30808 afb461fe599735fb9f065f17cecc671d6ccef69b
child 30810 9f64f487a9576064b7377f04698c89190e1668b9
push id1
push userclokep@gmail.com
push dateMon, 07 May 2018 22:45:56 +0000
treeherdercomm-esr60@57eacde5ef40 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconley, Standard8
bugs760624
fix retry on imap auth error if server drops connection,r=mconley,a=Standard8 bug 760624
mailnews/imap/src/nsImapProtocol.cpp
--- a/mailnews/imap/src/nsImapProtocol.cpp
+++ b/mailnews/imap/src/nsImapProtocol.cpp
@@ -8316,16 +8316,22 @@ bool nsImapProtocol::TryToLogon()
    * 4. User provided wrong password.
    * 5. We tried too often and the server shut us down, so even a correct attempt
    *    will now (currently) fail.
    * The above problems may overlap, e.g. 3. with 1. and 2., and we can't differentiate
    * between 2. and 4., which is really unfortunate.
    */
 
   bool newPasswordRequested = false;
+  // remember the msgWindow before we start trying to logon, because if the
+  // server drops the connection on errors, TellThreadToDie will null out the
+  // protocolsink and we won't be able to get the msgWindow.
+  nsCOMPtr<nsIMsgWindow> msgWindow;
+  GetMsgWindow(getter_AddRefs(msgWindow));
+
   // This loops over 1) auth methods (only one per loop) and 2) password tries (with UI)
   while (!loginSucceeded && !skipLoop && !DeathSignalReceived())
   {
       // Get password
       if (m_currentAuthMethod != kHasAuthGssApiCapability && // GSSAPI uses no pw in apps
           m_currentAuthMethod != kHasAuthExternalCapability &&
           m_currentAuthMethod != kHasAuthNoneCapability)
       {
@@ -8363,18 +8369,16 @@ bool nsImapProtocol::TryToLogon()
             break;
           }
 
           // The reason that we failed might be a wrong password, so
           // ask user what to do
           PR_LOG(IMAP, PR_LOG_WARN, ("IMAP: ask user what to do (after login failed): new passwort, retry, cancel"));
           if (!m_imapServerSink)
             break;
-          nsCOMPtr<nsIMsgWindow> msgWindow;
-          GetMsgWindow(getter_AddRefs(msgWindow));
           // if there's no msg window, don't forget the password
           if (!msgWindow)
             break;
           PRInt32 buttonPressed = 1;
           rv = m_imapServerSink->PromptLoginFailed(msgWindow,
                                                     &buttonPressed);
           if (NS_FAILED(rv))
             break;