b=106188 Fix SSL freezing Mozilla on connect problems

r=darin r=javi r=wtc sr=jag a=blizzard
This commit is contained in:
kaie%netscape.com 2002-01-18 20:20:02 +00:00
Родитель e6881a2a8f
Коммит b4d6580c08
2 изменённых файлов: 37 добавлений и 42 удалений

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

@ -866,27 +866,42 @@ nsresult nsSocketTransport::doConnection(PRInt16 aSelectFlags)
}
//
// Step 3:
// Process the flags returned by PR_Poll() if any...
// Process the flags returned by PR_Poll() if any...
//
else if (aSelectFlags) {
if (PR_POLL_EXCEPT & aSelectFlags) {
LOG(("nsSocketTransport: Connection Refused via PR_POLL_EXCEPT. [%s:%d %x].\n",
mHostName, mPort, this));
rv = NS_ERROR_CONNECTION_REFUSED;
}
else if (PR_POLL_HUP & aSelectFlags) {
LOG(("nsSocketTransport: Connection Refused via PR_POLL_HUP. [%s:%d %x].\n",
mHostName, mPort, this));
rv = NS_ERROR_CONNECTION_REFUSED;
}
//
// The connection was successful...
//
// PR_Poll(...) returns PR_POLL_WRITE to indicate that the connection is
// established...
//
else if (PR_POLL_WRITE & aSelectFlags)
rv = NS_OK;
status = PR_ConnectContinue(mSocketFD, aSelectFlags);
LOG(("nsSocketTransport: PR_ConnectContinue\n"));
if (status == PR_SUCCESS) {
//
// We are connected.
//
rv = NS_OK;
}
else {
PRErrorCode code = PR_GetError();
//
// If the connect is still not ready, then return WOULD_BLOCK...
// It is the callers responsibility to place the transport on the
// select list of the transport thread...
//
if (PR_IN_PROGRESS_ERROR == code) {
// Set up the select flags for connect...
mSelectFlags = (PR_POLL_READ | PR_POLL_EXCEPT | PR_POLL_WRITE);
rv = NS_BASE_STREAM_WOULD_BLOCK;
}
//
// The connection failed...
//
else {
LOG(("nsSocketTransport: Connection Failed [%s:%d %x]. PRErrorCode = %x\n",
mHostName, mPort, this, code));
// FIXME: "Connection refused" is just one of the possible
// errors. Other possible errors are "Connection timed out"
// and "No route to host". 'rv' should be based on 'code',
// the error code provided by NSPR.
rv = NS_ERROR_CONNECTION_REFUSED;
}
}
} else
rv = NS_BASE_STREAM_WOULD_BLOCK;

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

@ -800,27 +800,15 @@ nsSSLIOLayerConnect(PRFileDesc* fd, const PRNetAddr* addr,
return PR_FAILURE;
PRStatus status = PR_SUCCESS;
// Due to limitations in NSPR 4.0, we must execute this entire connect
// as a blocking operation.
PRSocketOptionData sockopt;
sockopt.option = PR_SockOpt_Nonblocking;
PR_GetSocketOption(fd, &sockopt);
PRBool oldBlockVal = sockopt.value.non_blocking;
nsNSSSocketInfo *infoObject = (nsNSSSocketInfo*)fd->secret;
sockopt.option = PR_SockOpt_Nonblocking;
sockopt.value.non_blocking = PR_FALSE;
PR_SetSocketOption(fd, &sockopt);
status = fd->lower->methods->connect(fd->lower, addr,
PR_INTERVAL_NO_TIMEOUT);
timeout);
if (status != PR_SUCCESS) {
PR_LOG(gPIPNSSLog, PR_LOG_ERROR, ("[%p] Lower layer connect error: %d\n",
(void*)fd, PR_GetError()));
goto loser;
return status;
}
PRBool forceHandshake, forTLSStepUp;
@ -841,14 +829,6 @@ nsSSLIOLayerConnect(PRFileDesc* fd, const PRNetAddr* addr,
}
}
loser:
// We put the Nonblocking bit back to the value it was when
// we entered this function.
NS_ASSERTION(sockopt.option == PR_SockOpt_Nonblocking,
"sockopt.option was re-set to an unexpected value");
sockopt.value.non_blocking = oldBlockVal;
PR_SetSocketOption(fd, &sockopt);
return status;
}