bug 466933 r/sr/a=standard8, error getting pop3 mail after resuming from sleep mode

This commit is contained in:
David Bienvenu 2010-05-12 07:57:48 -07:00
Родитель fe243545bb
Коммит 7fd3b63cdd
5 изменённых файлов: 66 добавлений и 38 удалений

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

@ -610,6 +610,15 @@ nsPop3IncomingServer::GetCanSearchMessages(PRBool *canSearchMessages)
return GetCanFileMessagesOnServer(canSearchMessages);
}
NS_IMETHODIMP
nsPop3IncomingServer::CloseCachedConnections()
{
nsCOMPtr<nsIRequest> channel = do_QueryInterface(m_runningProtocol);
if (channel)
channel->Cancel(NS_ERROR_ABORT);
return NS_OK;
}
NS_IMETHODIMP
nsPop3IncomingServer::GetOfflineSupportLevel(PRInt32 *aSupportLevel)
{

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

@ -65,6 +65,7 @@ public:
NS_IMETHOD GetCanBeDefaultServer(PRBool *canBeDefaultServer);
NS_IMETHOD GetCanSearchMessages(PRBool *canSearchMessages);
NS_IMETHOD GetOfflineSupportLevel(PRInt32 *aSupportLevel);
NS_IMETHOD CloseCachedConnections();
NS_IMETHOD GetRootMsgFolder(nsIMsgFolder **aRootMsgFolder);
NS_IMETHOD GetCanFileMessagesOnServer(PRBool *aCanFileMessagesOnServer);
NS_IMETHOD GetCanCreateFoldersOnServer(PRBool *aCanCreateFoldersOnServer);

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

@ -83,7 +83,7 @@
#define EXTRA_SAFETY_SPACE 3096
static PRLogModuleInfo *POP3LOGMODULE = nsnull;
PRLogModuleInfo *POP3LOGMODULE = nsnull;
static PRIntn
@ -918,15 +918,25 @@ NS_IMETHODIMP nsPop3Protocol::OnTransportStatus(nsITransport *aTransport, nsresu
}
// stop binding is a "notification" informing us that the stream associated with aURL is going away.
NS_IMETHODIMP nsPop3Protocol::OnStopRequest(nsIRequest *request, nsISupports * aContext, nsresult aStatus)
NS_IMETHODIMP nsPop3Protocol::OnStopRequest(nsIRequest *aRequest, nsISupports * aContext, nsresult aStatus)
{
nsresult rv = nsMsgProtocol::OnStopRequest(request, aContext, aStatus);
// turn off the server busy flag on stop request - we know we're done, right?
if (m_pop3Server)
PRBool socketWasOpen = m_socketIsOpen;
nsresult rv = nsMsgProtocol::OnStopRequest(aRequest, aContext, aStatus);
// If the server dropped the connection, m_socketIsOpen will be true, before
// we call nsMsgProtocol::OnStopRequest. The call will force a close socket,
// but we still want to go through the state machine one more time to cleanup
// the protocol object.
if (socketWasOpen)
{
nsCOMPtr<nsIMsgIncomingServer> server = do_QueryInterface(m_pop3Server);
if (server)
server->SetServerBusy(PR_FALSE); // the server is not busy
m_pop3ConData->next_state = POP3_ERROR_DONE;
ProcessProtocolState(nsnull, nsnull, 0, 0);
}
// turn off the server busy flag on stop request - we know we're done, right?
nsCOMPtr<nsIMsgIncomingServer> server = do_QueryInterface(m_pop3Server);
if (server)
{
PR_LOG(POP3LOGMODULE, PR_LOG_MAX, ("Clearing server busy in OnStopRequest"));
server->SetServerBusy(PR_FALSE); // the server is not busy
}
if(m_pop3ConData->list_done)
CommitState(PR_TRUE);
@ -944,8 +954,8 @@ void nsPop3Protocol::Abort()
}
// need this to close the stream on the inbox.
m_nsIPop3Sink->AbortMailDelivery(this);
PR_LOG(POP3LOGMODULE, PR_LOG_MAX, ("Clearing running protocol in nsPop3Protocol::Abort"));
m_pop3Server->SetRunningProtocol(nsnull);
}
NS_IMETHODIMP nsPop3Protocol::Cancel(nsresult status) // handle stop button
@ -1026,6 +1036,8 @@ nsresult nsPop3Protocol::LoadUrl(nsIURI* aURL, nsISupports * /* aConsumer */)
if (server)
{
rv = server->GetLocalPath(getter_AddRefs(mailDirectory));
NS_ENSURE_SUCCESS(rv, rv);
PR_LOG(POP3LOGMODULE, PR_LOG_MAX, ("Setting server busy in nsPop3Protocol::LoadUrl"));
server->SetServerBusy(PR_TRUE); // the server is now busy
server->GetHostName(hostName);
server->GetUsername(userName);
@ -2325,10 +2337,13 @@ nsPop3Protocol::GetStat()
rv = m_nsIPop3Sink->BeginMailDelivery(m_pop3ConData->only_uidl != nsnull, msgWindow,
&m_pop3ConData->msg_del_started);
if (NS_FAILED(rv))
{
m_nsIPop3Sink->AbortMailDelivery(this);
if (rv == NS_MSG_FOLDER_BUSY)
return(Error(POP3_MESSAGE_FOLDER_BUSY));
else
return(Error(POP3_MESSAGE_WRITE_ERROR));
}
if(!m_pop3ConData->msg_del_started)
return(Error(POP3_MESSAGE_WRITE_ERROR));
@ -4060,22 +4075,22 @@ nsresult nsPop3Protocol::ProcessProtocolState(nsIURI * url, nsIInputStream * aIn
break;
case POP3_FREE:
UpdateProgressPercent(0,0); // clear out the progress meter
NS_ASSERTION(m_nsIPop3Sink, "with no sink, can't clear busy flag");
if (m_nsIPop3Sink)
{
UpdateProgressPercent(0,0); // clear out the progress meter
nsCOMPtr<nsIMsgIncomingServer> server = do_QueryInterface(m_pop3Server);
if (server)
{
PR_LOG(POP3LOGMODULE, PR_LOG_MAX, ("Clearing server busy in POP3_FREE"));
server->SetServerBusy(PR_FALSE); // the server is now not busy
}
PR_LOG(POP3LOGMODULE, PR_LOG_MAX, ("Clearing running protocol in POP3_FREE"));
m_pop3Server->SetRunningProtocol(nsnull);
if (mailnewsurl && urlStatusSet)
mailnewsurl->SetUrlState(PR_FALSE, m_pop3ConData->urlStatus);
CloseSocket();
return NS_OK;
}
m_pop3Server->SetRunningProtocol(nsnull);
if (mailnewsurl && urlStatusSet)
mailnewsurl->SetUrlState(PR_FALSE, m_pop3ConData->urlStatus);
CloseSocket();
return NS_OK;
break;
default:
NS_ERROR("Got to unexpected state in nsPop3Protocol::ProcessProtocolState");

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

@ -36,6 +36,10 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifdef MOZ_LOGGING
#define FORCE_PR_LOG
#endif
#include "msgCore.h" // precompiled header...
#include "nsPop3Sink.h"
@ -72,6 +76,7 @@
#include "nsIPop3Service.h"
#include "nsMsgLocalCID.h"
extern PRLogModuleInfo *POP3LOGMODULE;
NS_IMPL_THREADSAFE_ISUPPORTS1(nsPop3Sink, nsIPop3Sink)
@ -94,6 +99,9 @@ nsPop3Sink::nsPop3Sink()
m_popServer = nsnull;
m_outFileStream = nsnull;
m_buildMessageUri = PR_FALSE;
if (!POP3LOGMODULE)
POP3LOGMODULE = PR_NewLogModule("POP3");
}
nsPop3Sink::~nsPop3Sink()
@ -101,6 +109,7 @@ nsPop3Sink::~nsPop3Sink()
PR_Free(m_accountUrl);
PR_Free(m_outputBuffer);
NS_IF_RELEASE(m_popServer);
PR_LOG(POP3LOGMODULE, PR_LOG_MAX, ("Calling ReleaseFolderLock from ~nsPop3Sink"));
ReleaseFolderLock();
NS_IF_RELEASE(m_newMailParser);
}
@ -288,9 +297,15 @@ nsPop3Sink::BeginMailDelivery(PRBool uidlDownload, nsIMsgWindow *aMsgWindow, PRB
nsCOMPtr <nsISupports> supports = do_QueryInterface(static_cast<nsIPop3Sink*>(this));
m_folder->GetLocked(&isLocked);
if(!isLocked)
{
PR_LOG(POP3LOGMODULE, PR_LOG_MAX, ("BeginMailDelivery acquiring semaphore"));
m_folder->AcquireSemaphore(supports);
}
else
{
PR_LOG(POP3LOGMODULE, PR_LOG_MAX, ("BeginMailDelivery folder locked"));
return NS_MSG_FOLDER_BUSY;
}
nsCOMPtr<nsILocalFile> path;
@ -418,6 +433,7 @@ nsPop3Sink::EndMailDelivery(nsIPop3Protocol *protocol)
if (m_newMailParser)
m_newMailParser->UpdateDBFolderInfo();
PR_LOG(POP3LOGMODULE, PR_LOG_MAX, ("Calling ReleaseFolderLock from EndMailDelivery"));
nsresult rv = ReleaseFolderLock();
NS_ASSERTION(NS_SUCCEEDED(rv),"folder lock not released successfully");
@ -516,6 +532,8 @@ nsPop3Sink::ReleaseFolderLock()
PRBool haveSemaphore;
nsCOMPtr <nsISupports> supports = do_QueryInterface(static_cast<nsIPop3Sink*>(this));
result = m_folder->TestSemaphore(supports, &haveSemaphore);
PR_LOG(POP3LOGMODULE, PR_LOG_MAX, ("ReleaseFolderLock haveSemaphore = %s", haveSemaphore ? "TRUE" : "FALSE"));
if(NS_SUCCEEDED(result) && haveSemaphore)
result = m_folder->ReleaseSemaphore(supports);
return result;
@ -542,6 +560,8 @@ nsPop3Sink::AbortMailDelivery(nsIPop3Protocol *protocol)
we have truncated the inbox, so berkeley mailbox and msf file are in sync*/
if (m_newMailParser)
m_newMailParser->UpdateDBFolderInfo();
PR_LOG(POP3LOGMODULE, PR_LOG_MAX, ("Calling ReleaseFolderLock from AbortMailDelivery"));
nsresult rv = ReleaseFolderLock();
NS_ASSERTION(NS_SUCCEEDED(rv),"folder lock not released successfully");

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

@ -60,21 +60,7 @@ var urlListener =
}
};
function checkBusy() {
// If the server hasn't quite finished, just delay a little longer.
if (incomingServer.serverBusy ||
(incomingServer instanceof Ci.nsIPop3IncomingServer &&
incomingServer.runningProtocol)) {
do_timeout(20, checkBusy);
return;
}
endTest();
}
function endTest() {
incomingServer.closeCachedConnections();
// No more tests, let everything finish
server.stop();
@ -96,10 +82,7 @@ CRAMFail_handler.prototype = {
killConn : function()
{
server._readers.forEach(function (reader) {
//reader.closeSocket(); doesn't close right away
reader._realCloseSocket();
});
this.closing = true;
return "-ERR I don't feel like it";
}
}