зеркало из https://github.com/mozilla/gecko-dev.git
bug 658580 revert isalive() from 654201 to fix an alternate way r=honzab
This commit is contained in:
Родитель
f5541b7e73
Коммит
e32fb82ff7
|
@ -51,7 +51,7 @@ native PRNetAddr(union PRNetAddr);
|
|||
* NOTE: This is a free-threaded interface, meaning that the methods on
|
||||
* this interface may be called from any thread.
|
||||
*/
|
||||
[scriptable, uuid(bbee8fef-6ac2-4819-9089-61169bdf5074)]
|
||||
[scriptable, uuid(19c37caa-fb41-4c32-bbf1-c6b31b75d789)]
|
||||
interface nsISocketTransport : nsITransport
|
||||
{
|
||||
/**
|
||||
|
@ -95,12 +95,8 @@ interface nsISocketTransport : nsITransport
|
|||
|
||||
/**
|
||||
* Test if this socket transport is (still) connected.
|
||||
*
|
||||
* @param aPassive indicates that the IsAlive() method should not
|
||||
* read, even non-destructively, from the network.
|
||||
* SSL based transports may deadlock if called without this.
|
||||
*/
|
||||
boolean isAlive(in boolean aPassive);
|
||||
boolean isAlive();
|
||||
|
||||
/**
|
||||
* Socket timeouts in seconds. To specify no timeout, pass PR_UINT32_MAX
|
||||
|
|
|
@ -1833,7 +1833,7 @@ nsSocketTransport::SetEventSink(nsITransportEventSink *sink,
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSocketTransport::IsAlive(PRBool aPassive, PRBool *result)
|
||||
nsSocketTransport::IsAlive(PRBool *result)
|
||||
{
|
||||
*result = PR_FALSE;
|
||||
|
||||
|
@ -1849,32 +1849,12 @@ nsSocketTransport::IsAlive(PRBool aPassive, PRBool *result)
|
|||
|
||||
// XXX do some idle-time based checks??
|
||||
|
||||
if (aPassive) {
|
||||
*result = PR_TRUE; /* presume true */
|
||||
char c;
|
||||
PRInt32 rval = PR_Recv(fd, &c, 1, PR_MSG_PEEK, 0);
|
||||
|
||||
PRPollDesc desc;
|
||||
desc.fd = mFD;
|
||||
if ((rval > 0) || (rval < 0 && PR_GetError() == PR_WOULD_BLOCK_ERROR))
|
||||
*result = PR_TRUE;
|
||||
|
||||
// include POLL_READ in the in_flags in order to take
|
||||
// conditions PK11LoggedOut / AlreadyShutDown into account on SSL
|
||||
// sockets as a workaround for bug 658138
|
||||
desc.in_flags = PR_POLL_READ | PR_POLL_EXCEPT;
|
||||
desc.out_flags = 0;
|
||||
|
||||
if ((PR_Poll(&desc, 1, 0) == 1) &&
|
||||
(desc.out_flags &
|
||||
(PR_POLL_EXCEPT | PR_POLL_ERR | PR_POLL_NVAL | PR_POLL_HUP))) {
|
||||
*result = PR_FALSE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
char c;
|
||||
PRInt32 rval = PR_Recv(fd, &c, 1, PR_MSG_PEEK, 0);
|
||||
|
||||
if ((rval > 0) || (rval < 0 && PR_GetError() == PR_WOULD_BLOCK_ERROR))
|
||||
*result = PR_TRUE;
|
||||
}
|
||||
|
||||
{
|
||||
MutexAutoLock lock(mLock);
|
||||
ReleaseFD_Locked(fd);
|
||||
|
|
|
@ -1428,8 +1428,7 @@ nsFtpState::R_pasv() {
|
|||
if (NS_SUCCEEDED(rv)) {
|
||||
if (oldPort == port) {
|
||||
PRBool isAlive;
|
||||
if (NS_SUCCEEDED(strans->IsAlive(PR_FALSE, &isAlive)) &&
|
||||
isAlive)
|
||||
if (NS_SUCCEEDED(strans->IsAlive(&isAlive)) && isAlive)
|
||||
newDataConn = PR_FALSE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -116,7 +116,7 @@ nsFtpControlConnection::IsAlive()
|
|||
return PR_FALSE;
|
||||
|
||||
PRBool isAlive = PR_FALSE;
|
||||
mSocket->IsAlive(PR_FALSE, &isAlive);
|
||||
mSocket->IsAlive(&isAlive);
|
||||
return isAlive;
|
||||
}
|
||||
nsresult
|
||||
|
|
|
@ -79,7 +79,6 @@ nsHttpConnection::nsHttpConnection()
|
|||
, mKeepAliveMask(PR_TRUE)
|
||||
, mSupportsPipelining(PR_FALSE) // assume low-grade server
|
||||
, mIsReused(PR_FALSE)
|
||||
, mIsActivated(PR_FALSE)
|
||||
, mCompletedProxyConnect(PR_FALSE)
|
||||
, mLastTransactionExpectedNoContent(PR_FALSE)
|
||||
, mIdleMonitoring(PR_FALSE)
|
||||
|
@ -169,7 +168,6 @@ nsHttpConnection::Activate(nsAHttpTransaction *trans, PRUint8 caps)
|
|||
|
||||
// take ownership of the transaction
|
||||
mTransaction = trans;
|
||||
mIsActivated = PR_TRUE;
|
||||
|
||||
NS_ABORT_IF_FALSE(!mIdleMonitoring,
|
||||
"Activating a connection with an Idle Monitor");
|
||||
|
@ -278,15 +276,8 @@ nsHttpConnection::IsAlive()
|
|||
if (!mSocketTransport)
|
||||
return PR_FALSE;
|
||||
|
||||
// Calling IsAlive() non passively on an SSL socket transport that has
|
||||
// not yet completed the SSL handshake can result
|
||||
// in the event loop being run. All code that calls
|
||||
// nsHttpConnection::IsAlive() is not re-entrant so we need to avoid
|
||||
// having IsAlive() trigger a real SSL read in that circumstance.
|
||||
|
||||
PRBool alive;
|
||||
PRBool passiveRead = mConnInfo->UsingSSL() && !mIsActivated;
|
||||
nsresult rv = mSocketTransport->IsAlive(passiveRead, &alive);
|
||||
nsresult rv = mSocketTransport->IsAlive(&alive);
|
||||
if (NS_FAILED(rv))
|
||||
alive = PR_FALSE;
|
||||
|
||||
|
|
|
@ -200,7 +200,6 @@ private:
|
|||
PRPackedBool mKeepAliveMask;
|
||||
PRPackedBool mSupportsPipelining;
|
||||
PRPackedBool mIsReused;
|
||||
PRPackedBool mIsActivated;
|
||||
PRPackedBool mCompletedProxyConnect;
|
||||
PRPackedBool mLastTransactionExpectedNoContent;
|
||||
PRPackedBool mIdleMonitoring;
|
||||
|
|
Загрузка…
Ссылка в новой задаче