fix for #30775 and #30648. r=mscott,warren. a=phil

we need to call Cancel() to remove the closed nsSocketTransport from the
list of active transports.  if we don't, we quickly reach the max (50)
and pop, smtp, and nntp operation start failing.

also, upon NS_BINDING_ABORTED, do not pop up an alert.  we get
this when we call Cancel() or if the user hits the stop button.
This commit is contained in:
sspitzer%netscape.com 2000-03-12 06:40:25 +00:00
Родитель 299e2bdb1c
Коммит 0487a8b1a3
2 изменённых файлов: 19 добавлений и 3 удалений

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

@ -140,12 +140,19 @@ nsresult nsMsgProtocol::SetupTransportState()
nsresult nsMsgProtocol::CloseSocket() nsresult nsMsgProtocol::CloseSocket()
{ {
nsresult rv = NS_OK;
// release all of our socket state // release all of our socket state
m_socketIsOpen = PR_FALSE; m_socketIsOpen = PR_FALSE;
m_outputStream = null_nsCOMPtr(); m_outputStream = null_nsCOMPtr();
// we need to call Cancel so that we remove the socket transport from the mActiveTransportList. see bug #30648
if (m_channel) {
rv = m_channel->Cancel();
}
m_channel = null_nsCOMPtr(); m_channel = null_nsCOMPtr();
return NS_OK; return rv;
} }
/* /*
@ -218,8 +225,12 @@ NS_IMETHODIMP nsMsgProtocol::OnStopRequest(nsIChannel * aChannel, nsISupports *c
// happens to be using // happens to be using
if (m_channelListener) if (m_channelListener)
rv = m_channelListener->OnStopRequest(this, m_channelContext, aStatus, aMsg); rv = m_channelListener->OnStopRequest(this, m_channelContext, aStatus, aMsg);
if (NS_FAILED(aStatus)) { // !NS_BINDING_ABORTED because we don't want to see an alert if the user
// cancelled the operation. also, we'll get here because we call Cancel()
// to force removal of the nsSocketTransport. see CloseSocket()
// bugs #30775 and #30648 relate to this
if (NS_FAILED(aStatus) && (aStatus != NS_BINDING_ABORTED)) {
NS_WITH_SERVICE(nsIPrompt, dialog, kNetSupportDialogCID, &rv); NS_WITH_SERVICE(nsIPrompt, dialog, kNetSupportDialogCID, &rv);
if (NS_SUCCEEDED(rv) && dialog) { if (NS_SUCCEEDED(rv) && dialog) {
// todo, put this into a string bundle // todo, put this into a string bundle

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

@ -226,6 +226,7 @@ nsresult nsSocketTransportService::ProcessWorkQ(void)
// available in the select set... // available in the select set...
// //
PR_Lock(mThreadLock); PR_Lock(mThreadLock);
NS_ASSERTION(MAX_OPEN_CONNECTIONS > mSelectFDSetCount, "reached max open connections");
while (!PR_CLIST_IS_EMPTY(&mWorkQ) && while (!PR_CLIST_IS_EMPTY(&mWorkQ) &&
(MAX_OPEN_CONNECTIONS > mSelectFDSetCount)) { (MAX_OPEN_CONNECTIONS > mSelectFDSetCount)) {
nsSocketTransport* transport; nsSocketTransport* transport;
@ -270,6 +271,7 @@ nsresult nsSocketTransportService::AddToSelectList(nsSocketTransport* aTransport
{ {
nsresult rv = NS_OK; nsresult rv = NS_OK;
NS_ASSERTION(MAX_OPEN_CONNECTIONS > mSelectFDSetCount, "reached max open connections");
if (aTransport && (MAX_OPEN_CONNECTIONS > mSelectFDSetCount) ) { if (aTransport && (MAX_OPEN_CONNECTIONS > mSelectFDSetCount) ) {
PRPollDesc* pfd; PRPollDesc* pfd;
int i; int i;
@ -338,6 +340,9 @@ nsresult nsSocketTransportService::RemoveFromSelectList(nsSocketTransport* aTran
} }
} }
#ifdef DEBUG_sspitzer
printf("mSelectFDSetCount = %d\n",mSelectFDSetCount);
#endif
return rv; return rv;
} }