mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 14:22:01 +00:00
Bug 606719 - Browser stalls with connections left hanging in TCP close wait state. Part 1: rename LOG to SOCKET_LOG. r=mcmanus, a=b7+
This commit is contained in:
parent
e1dcc97a16
commit
7ba8683bb3
@ -99,7 +99,7 @@ nsServerSocket::~nsServerSocket()
|
||||
void
|
||||
nsServerSocket::OnMsgClose()
|
||||
{
|
||||
LOG(("nsServerSocket::OnMsgClose [this=%p]\n", this));
|
||||
SOCKET_LOG(("nsServerSocket::OnMsgClose [this=%p]\n", this));
|
||||
|
||||
if (NS_FAILED(mCondition))
|
||||
return;
|
||||
@ -116,7 +116,7 @@ nsServerSocket::OnMsgClose()
|
||||
void
|
||||
nsServerSocket::OnMsgAttach()
|
||||
{
|
||||
LOG(("nsServerSocket::OnMsgAttach [this=%p]\n", this));
|
||||
SOCKET_LOG(("nsServerSocket::OnMsgAttach [this=%p]\n", this));
|
||||
|
||||
if (NS_FAILED(mCondition))
|
||||
return;
|
||||
|
@ -140,7 +140,7 @@ static PRErrorCode RandomizeConnectError(PRErrorCode code)
|
||||
};
|
||||
n = n % (sizeof(errors)/sizeof(errors[0]));
|
||||
code = errors[n].err_code;
|
||||
LOG(("simulating NSPR error %d [%s]\n", code, errors[n].err_name));
|
||||
SOCKET_LOG(("simulating NSPR error %d [%s]\n", code, errors[n].err_name));
|
||||
}
|
||||
return code;
|
||||
}
|
||||
@ -202,7 +202,7 @@ ErrorAccordingToNSPR(PRErrorCode errorCode)
|
||||
rv = GetXPCOMFromNSSError(errorCode);
|
||||
break;
|
||||
}
|
||||
LOG(("ErrorAccordingToNSPR [in=%d out=%x]\n", errorCode, rv));
|
||||
SOCKET_LOG(("ErrorAccordingToNSPR [in=%d out=%x]\n", errorCode, rv));
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -230,7 +230,7 @@ nsSocketInputStream::~nsSocketInputStream()
|
||||
void
|
||||
nsSocketInputStream::OnSocketReady(nsresult condition)
|
||||
{
|
||||
LOG(("nsSocketInputStream::OnSocketReady [this=%x cond=%x]\n",
|
||||
SOCKET_LOG(("nsSocketInputStream::OnSocketReady [this=%x cond=%x]\n",
|
||||
this, condition));
|
||||
|
||||
NS_ASSERTION(PR_GetCurrentThread() == gSocketThread, "wrong thread");
|
||||
@ -284,7 +284,7 @@ nsSocketInputStream::Close()
|
||||
NS_IMETHODIMP
|
||||
nsSocketInputStream::Available(PRUint32 *avail)
|
||||
{
|
||||
LOG(("nsSocketInputStream::Available [this=%x]\n", this));
|
||||
SOCKET_LOG(("nsSocketInputStream::Available [this=%x]\n", this));
|
||||
|
||||
*avail = 0;
|
||||
|
||||
@ -329,7 +329,7 @@ nsSocketInputStream::Available(PRUint32 *avail)
|
||||
NS_IMETHODIMP
|
||||
nsSocketInputStream::Read(char *buf, PRUint32 count, PRUint32 *countRead)
|
||||
{
|
||||
LOG(("nsSocketInputStream::Read [this=%x count=%u]\n", this, count));
|
||||
SOCKET_LOG(("nsSocketInputStream::Read [this=%x count=%u]\n", this, count));
|
||||
|
||||
*countRead = 0;
|
||||
|
||||
@ -345,14 +345,14 @@ nsSocketInputStream::Read(char *buf, PRUint32 count, PRUint32 *countRead)
|
||||
return NS_BASE_STREAM_WOULD_BLOCK;
|
||||
}
|
||||
|
||||
LOG((" calling PR_Read [count=%u]\n", count));
|
||||
SOCKET_LOG((" calling PR_Read [count=%u]\n", count));
|
||||
|
||||
// cannot hold lock while calling NSPR. (worried about the fact that PSM
|
||||
// synchronously proxies notifications over to the UI thread, which could
|
||||
// mistakenly try to re-enter this code.)
|
||||
PRInt32 n = PR_Read(fd, buf, count);
|
||||
|
||||
LOG((" PR_Read returned [n=%d]\n", n));
|
||||
SOCKET_LOG((" PR_Read returned [n=%d]\n", n));
|
||||
|
||||
nsresult rv;
|
||||
{
|
||||
@ -403,7 +403,7 @@ nsSocketInputStream::IsNonBlocking(PRBool *nonblocking)
|
||||
NS_IMETHODIMP
|
||||
nsSocketInputStream::CloseWithStatus(nsresult reason)
|
||||
{
|
||||
LOG(("nsSocketInputStream::CloseWithStatus [this=%x reason=%x]\n", this, reason));
|
||||
SOCKET_LOG(("nsSocketInputStream::CloseWithStatus [this=%x reason=%x]\n", this, reason));
|
||||
|
||||
// may be called from any thread
|
||||
|
||||
@ -427,7 +427,7 @@ nsSocketInputStream::AsyncWait(nsIInputStreamCallback *callback,
|
||||
PRUint32 amount,
|
||||
nsIEventTarget *target)
|
||||
{
|
||||
LOG(("nsSocketInputStream::AsyncWait [this=%x]\n", this));
|
||||
SOCKET_LOG(("nsSocketInputStream::AsyncWait [this=%x]\n", this));
|
||||
|
||||
// This variable will be non-null when we want to call the callback
|
||||
// directly from this function, but outside the lock.
|
||||
@ -489,7 +489,7 @@ nsSocketOutputStream::~nsSocketOutputStream()
|
||||
void
|
||||
nsSocketOutputStream::OnSocketReady(nsresult condition)
|
||||
{
|
||||
LOG(("nsSocketOutputStream::OnSocketReady [this=%x cond=%x]\n",
|
||||
SOCKET_LOG(("nsSocketOutputStream::OnSocketReady [this=%x cond=%x]\n",
|
||||
this, condition));
|
||||
|
||||
NS_ASSERTION(PR_GetCurrentThread() == gSocketThread, "wrong thread");
|
||||
@ -549,7 +549,7 @@ nsSocketOutputStream::Flush()
|
||||
NS_IMETHODIMP
|
||||
nsSocketOutputStream::Write(const char *buf, PRUint32 count, PRUint32 *countWritten)
|
||||
{
|
||||
LOG(("nsSocketOutputStream::Write [this=%x count=%u]\n", this, count));
|
||||
SOCKET_LOG(("nsSocketOutputStream::Write [this=%x count=%u]\n", this, count));
|
||||
|
||||
*countWritten = 0;
|
||||
|
||||
@ -568,14 +568,14 @@ nsSocketOutputStream::Write(const char *buf, PRUint32 count, PRUint32 *countWrit
|
||||
return NS_BASE_STREAM_WOULD_BLOCK;
|
||||
}
|
||||
|
||||
LOG((" calling PR_Write [count=%u]\n", count));
|
||||
SOCKET_LOG((" calling PR_Write [count=%u]\n", count));
|
||||
|
||||
// cannot hold lock while calling NSPR. (worried about the fact that PSM
|
||||
// synchronously proxies notifications over to the UI thread, which could
|
||||
// mistakenly try to re-enter this code.)
|
||||
PRInt32 n = PR_Write(fd, buf, count);
|
||||
|
||||
LOG((" PR_Write returned [n=%d]\n", n));
|
||||
SOCKET_LOG((" PR_Write returned [n=%d]\n", n));
|
||||
NS_ASSERTION(n != 0, "unexpected return value");
|
||||
|
||||
nsresult rv;
|
||||
@ -645,7 +645,7 @@ nsSocketOutputStream::IsNonBlocking(PRBool *nonblocking)
|
||||
NS_IMETHODIMP
|
||||
nsSocketOutputStream::CloseWithStatus(nsresult reason)
|
||||
{
|
||||
LOG(("nsSocketOutputStream::CloseWithStatus [this=%x reason=%x]\n", this, reason));
|
||||
SOCKET_LOG(("nsSocketOutputStream::CloseWithStatus [this=%x reason=%x]\n", this, reason));
|
||||
|
||||
// may be called from any thread
|
||||
|
||||
@ -669,7 +669,7 @@ nsSocketOutputStream::AsyncWait(nsIOutputStreamCallback *callback,
|
||||
PRUint32 amount,
|
||||
nsIEventTarget *target)
|
||||
{
|
||||
LOG(("nsSocketOutputStream::AsyncWait [this=%x]\n", this));
|
||||
SOCKET_LOG(("nsSocketOutputStream::AsyncWait [this=%x]\n", this));
|
||||
|
||||
{
|
||||
nsAutoLock lock(mTransport->mLock);
|
||||
@ -721,7 +721,7 @@ nsSocketTransport::nsSocketTransport()
|
||||
, mOutput(this)
|
||||
, mQoSBits(0x00)
|
||||
{
|
||||
LOG(("creating nsSocketTransport @%x\n", this));
|
||||
SOCKET_LOG(("creating nsSocketTransport @%x\n", this));
|
||||
|
||||
NS_ADDREF(gSocketTransportService);
|
||||
|
||||
@ -731,7 +731,7 @@ nsSocketTransport::nsSocketTransport()
|
||||
|
||||
nsSocketTransport::~nsSocketTransport()
|
||||
{
|
||||
LOG(("destroying nsSocketTransport @%x\n", this));
|
||||
SOCKET_LOG(("destroying nsSocketTransport @%x\n", this));
|
||||
|
||||
// cleanup socket type info
|
||||
if (mTypes) {
|
||||
@ -779,7 +779,7 @@ nsSocketTransport::Init(const char **types, PRUint32 typeCount,
|
||||
proxyType = nsnull;
|
||||
}
|
||||
|
||||
LOG(("nsSocketTransport::Init [this=%x host=%s:%hu proxy=%s:%hu]\n",
|
||||
SOCKET_LOG(("nsSocketTransport::Init [this=%x host=%s:%hu proxy=%s:%hu]\n",
|
||||
this, mHost.get(), mPort, mProxyHost.get(), mProxyPort));
|
||||
|
||||
// include proxy type as a socket type if proxy type is not "http"
|
||||
@ -869,7 +869,7 @@ nsSocketTransport::InitWithConnectedSocket(PRFileDesc *fd, const PRNetAddr *addr
|
||||
opt.value.non_blocking = PR_TRUE;
|
||||
PR_SetSocketOption(mFD, &opt);
|
||||
|
||||
LOG(("nsSocketTransport::InitWithConnectedSocket [this=%p addr=%s:%hu]\n",
|
||||
SOCKET_LOG(("nsSocketTransport::InitWithConnectedSocket [this=%p addr=%s:%hu]\n",
|
||||
this, mHost.get(), mPort));
|
||||
|
||||
// jump to InitiateSocket to get ourselves attached to the STS poll list.
|
||||
@ -879,7 +879,7 @@ nsSocketTransport::InitWithConnectedSocket(PRFileDesc *fd, const PRNetAddr *addr
|
||||
nsresult
|
||||
nsSocketTransport::PostEvent(PRUint32 type, nsresult status, nsISupports *param)
|
||||
{
|
||||
LOG(("nsSocketTransport::PostEvent [this=%p type=%u status=%x param=%p]\n",
|
||||
SOCKET_LOG(("nsSocketTransport::PostEvent [this=%p type=%u status=%x param=%p]\n",
|
||||
this, type, status, param));
|
||||
|
||||
nsCOMPtr<nsIRunnable> event = new nsSocketEvent(this, type, status, param);
|
||||
@ -892,7 +892,7 @@ nsSocketTransport::PostEvent(PRUint32 type, nsresult status, nsISupports *param)
|
||||
void
|
||||
nsSocketTransport::SendStatus(nsresult status)
|
||||
{
|
||||
LOG(("nsSocketTransport::SendStatus [this=%x status=%x]\n", this, status));
|
||||
SOCKET_LOG(("nsSocketTransport::SendStatus [this=%x status=%x]\n", this, status));
|
||||
|
||||
nsCOMPtr<nsITransportEventSink> sink;
|
||||
PRUint64 progress;
|
||||
@ -918,7 +918,7 @@ nsSocketTransport::SendStatus(nsresult status)
|
||||
nsresult
|
||||
nsSocketTransport::ResolveHost()
|
||||
{
|
||||
LOG(("nsSocketTransport::ResolveHost [this=%x]\n", this));
|
||||
SOCKET_LOG(("nsSocketTransport::ResolveHost [this=%x]\n", this));
|
||||
|
||||
nsresult rv;
|
||||
|
||||
@ -955,7 +955,7 @@ nsSocketTransport::ResolveHost()
|
||||
rv = dns->AsyncResolve(SocketHost(), dnsFlags, this, nsnull,
|
||||
getter_AddRefs(mDNSRequest));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
LOG((" advancing to STATE_RESOLVING\n"));
|
||||
SOCKET_LOG((" advancing to STATE_RESOLVING\n"));
|
||||
mState = STATE_RESOLVING;
|
||||
// only report that we are resolving if we are still resolving...
|
||||
if (mResolving)
|
||||
@ -967,7 +967,7 @@ nsSocketTransport::ResolveHost()
|
||||
nsresult
|
||||
nsSocketTransport::BuildSocket(PRFileDesc *&fd, PRBool &proxyTransparent, PRBool &usingSSL)
|
||||
{
|
||||
LOG(("nsSocketTransport::BuildSocket [this=%x]\n", this));
|
||||
SOCKET_LOG(("nsSocketTransport::BuildSocket [this=%x]\n", this));
|
||||
|
||||
nsresult rv;
|
||||
|
||||
@ -995,7 +995,7 @@ nsSocketTransport::BuildSocket(PRFileDesc *&fd, PRBool &proxyTransparent, PRBool
|
||||
for (i=0; i<mTypeCount; ++i) {
|
||||
nsCOMPtr<nsISocketProvider> provider;
|
||||
|
||||
LOG((" pushing io layer [%u:%s]\n", i, mTypes[i]));
|
||||
SOCKET_LOG((" pushing io layer [%u:%s]\n", i, mTypes[i]));
|
||||
|
||||
rv = spserv->GetSocketProvider(mTypes[i], getter_AddRefs(provider));
|
||||
if (NS_FAILED(rv))
|
||||
@ -1043,7 +1043,7 @@ nsSocketTransport::BuildSocket(PRFileDesc *&fd, PRBool &proxyTransparent, PRBool
|
||||
nsAutoLock lock(mLock);
|
||||
mSecInfo = secinfo;
|
||||
callbacks = mCallbacks;
|
||||
LOG((" [secinfo=%x callbacks=%x]\n", mSecInfo.get(), mCallbacks.get()));
|
||||
SOCKET_LOG((" [secinfo=%x callbacks=%x]\n", mSecInfo.get(), mCallbacks.get()));
|
||||
}
|
||||
// don't call into PSM while holding mLock!!
|
||||
nsCOMPtr<nsISSLSocketControl> secCtrl(do_QueryInterface(secinfo));
|
||||
@ -1063,7 +1063,7 @@ nsSocketTransport::BuildSocket(PRFileDesc *&fd, PRBool &proxyTransparent, PRBool
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
LOG((" error pushing io layer [%u:%s rv=%x]\n", i, mTypes[i], rv));
|
||||
SOCKET_LOG((" error pushing io layer [%u:%s rv=%x]\n", i, mTypes[i], rv));
|
||||
if (fd)
|
||||
PR_Close(fd);
|
||||
}
|
||||
@ -1075,7 +1075,7 @@ nsSocketTransport::BuildSocket(PRFileDesc *&fd, PRBool &proxyTransparent, PRBool
|
||||
nsresult
|
||||
nsSocketTransport::InitiateSocket()
|
||||
{
|
||||
LOG(("nsSocketTransport::InitiateSocket [this=%x]\n", this));
|
||||
SOCKET_LOG(("nsSocketTransport::InitiateSocket [this=%x]\n", this));
|
||||
|
||||
nsresult rv;
|
||||
|
||||
@ -1118,7 +1118,7 @@ nsSocketTransport::InitiateSocket()
|
||||
|
||||
rv = BuildSocket(fd, proxyTransparent, usingSSL);
|
||||
if (NS_FAILED(rv)) {
|
||||
LOG((" BuildSocket failed [rv=%x]\n", rv));
|
||||
SOCKET_LOG((" BuildSocket failed [rv=%x]\n", rv));
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -1165,16 +1165,16 @@ nsSocketTransport::InitiateSocket()
|
||||
mFDconnected = PR_FALSE;
|
||||
}
|
||||
|
||||
LOG((" advancing to STATE_CONNECTING\n"));
|
||||
SOCKET_LOG((" advancing to STATE_CONNECTING\n"));
|
||||
mState = STATE_CONNECTING;
|
||||
mPollTimeout = mTimeouts[TIMEOUT_CONNECT];
|
||||
SendStatus(STATUS_CONNECTING_TO);
|
||||
|
||||
#if defined(PR_LOGGING)
|
||||
if (LOG_ENABLED()) {
|
||||
if (SOCKET_LOG_ENABLED()) {
|
||||
char buf[64];
|
||||
PR_NetAddrToString(&mNetAddr, buf, sizeof(buf));
|
||||
LOG((" trying address: %s\n", buf));
|
||||
SOCKET_LOG((" trying address: %s\n", buf));
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1215,7 +1215,7 @@ nsSocketTransport::InitiateSocket()
|
||||
nsCOMPtr<nsISSLSocketControl> secCtrl =
|
||||
do_QueryInterface(mSecInfo);
|
||||
if (secCtrl) {
|
||||
LOG((" calling ProxyStartSSL()\n"));
|
||||
SOCKET_LOG((" calling ProxyStartSSL()\n"));
|
||||
secCtrl->ProxyStartSSL();
|
||||
}
|
||||
// XXX what if we were forced to poll on the socket for a successful
|
||||
@ -1243,7 +1243,7 @@ nsSocketTransport::RecoverFromError()
|
||||
{
|
||||
NS_ASSERTION(NS_FAILED(mCondition), "there should be something wrong");
|
||||
|
||||
LOG(("nsSocketTransport::RecoverFromError [this=%x state=%x cond=%x]\n",
|
||||
SOCKET_LOG(("nsSocketTransport::RecoverFromError [this=%x state=%x cond=%x]\n",
|
||||
this, mState, mCondition));
|
||||
|
||||
// can only recover from errors in these states
|
||||
@ -1267,7 +1267,7 @@ nsSocketTransport::RecoverFromError()
|
||||
if (mState == STATE_CONNECTING && mDNSRecord) {
|
||||
nsresult rv = mDNSRecord->GetNextAddr(SocketPort(), &mNetAddr);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
LOG((" trying again with next ip address\n"));
|
||||
SOCKET_LOG((" trying again with next ip address\n"));
|
||||
tryAgain = PR_TRUE;
|
||||
}
|
||||
}
|
||||
@ -1311,7 +1311,7 @@ nsSocketTransport::RecoverFromError()
|
||||
void
|
||||
nsSocketTransport::OnMsgInputClosed(nsresult reason)
|
||||
{
|
||||
LOG(("nsSocketTransport::OnMsgInputClosed [this=%x reason=%x]\n",
|
||||
SOCKET_LOG(("nsSocketTransport::OnMsgInputClosed [this=%x reason=%x]\n",
|
||||
this, reason));
|
||||
|
||||
NS_ASSERTION(PR_GetCurrentThread() == gSocketThread, "wrong thread");
|
||||
@ -1333,7 +1333,7 @@ nsSocketTransport::OnMsgInputClosed(nsresult reason)
|
||||
void
|
||||
nsSocketTransport::OnMsgOutputClosed(nsresult reason)
|
||||
{
|
||||
LOG(("nsSocketTransport::OnMsgOutputClosed [this=%x reason=%x]\n",
|
||||
SOCKET_LOG(("nsSocketTransport::OnMsgOutputClosed [this=%x reason=%x]\n",
|
||||
this, reason));
|
||||
|
||||
NS_ASSERTION(PR_GetCurrentThread() == gSocketThread, "wrong thread");
|
||||
@ -1354,7 +1354,7 @@ nsSocketTransport::OnMsgOutputClosed(nsresult reason)
|
||||
void
|
||||
nsSocketTransport::OnSocketConnected()
|
||||
{
|
||||
LOG((" advancing to STATE_TRANSFERRING\n"));
|
||||
SOCKET_LOG((" advancing to STATE_TRANSFERRING\n"));
|
||||
|
||||
mPollFlags = (PR_POLL_READ | PR_POLL_WRITE | PR_POLL_EXCEPT);
|
||||
mPollTimeout = mTimeouts[TIMEOUT_READ_WRITE];
|
||||
@ -1391,7 +1391,7 @@ nsSocketTransport::ReleaseFD_Locked(PRFileDesc *fd)
|
||||
NS_ASSERTION(mFD == fd, "wrong fd");
|
||||
|
||||
if (--mFDref == 0) {
|
||||
LOG(("nsSocketTransport: calling PR_Close [this=%x]\n", this));
|
||||
SOCKET_LOG(("nsSocketTransport: calling PR_Close [this=%x]\n", this));
|
||||
PR_Close(mFD);
|
||||
mFD = nsnull;
|
||||
}
|
||||
@ -1403,12 +1403,12 @@ nsSocketTransport::ReleaseFD_Locked(PRFileDesc *fd)
|
||||
void
|
||||
nsSocketTransport::OnSocketEvent(PRUint32 type, nsresult status, nsISupports *param)
|
||||
{
|
||||
LOG(("nsSocketTransport::OnSocketEvent [this=%p type=%u status=%x param=%p]\n",
|
||||
SOCKET_LOG(("nsSocketTransport::OnSocketEvent [this=%p type=%u status=%x param=%p]\n",
|
||||
this, type, status, param));
|
||||
|
||||
if (NS_FAILED(mCondition)) {
|
||||
// block event since we're apparently already dead.
|
||||
LOG((" blocking event [condition=%x]\n", mCondition));
|
||||
SOCKET_LOG((" blocking event [condition=%x]\n", mCondition));
|
||||
//
|
||||
// notify input/output streams in case either has a pending notify.
|
||||
//
|
||||
@ -1419,7 +1419,7 @@ nsSocketTransport::OnSocketEvent(PRUint32 type, nsresult status, nsISupports *pa
|
||||
|
||||
switch (type) {
|
||||
case MSG_ENSURE_CONNECT:
|
||||
LOG((" MSG_ENSURE_CONNECT\n"));
|
||||
SOCKET_LOG((" MSG_ENSURE_CONNECT\n"));
|
||||
//
|
||||
// ensure that we have created a socket, attached it, and have a
|
||||
// connection.
|
||||
@ -1427,11 +1427,11 @@ nsSocketTransport::OnSocketEvent(PRUint32 type, nsresult status, nsISupports *pa
|
||||
if (mState == STATE_CLOSED)
|
||||
mCondition = ResolveHost();
|
||||
else
|
||||
LOG((" ignoring redundant event\n"));
|
||||
SOCKET_LOG((" ignoring redundant event\n"));
|
||||
break;
|
||||
|
||||
case MSG_DNS_LOOKUP_COMPLETE:
|
||||
LOG((" MSG_DNS_LOOKUP_COMPLETE\n"));
|
||||
SOCKET_LOG((" MSG_DNS_LOOKUP_COMPLETE\n"));
|
||||
mDNSRequest = 0;
|
||||
if (param) {
|
||||
mDNSRecord = static_cast<nsIDNSRecord *>(param);
|
||||
@ -1459,35 +1459,35 @@ nsSocketTransport::OnSocketEvent(PRUint32 type, nsresult status, nsISupports *pa
|
||||
break;
|
||||
|
||||
case MSG_INPUT_CLOSED:
|
||||
LOG((" MSG_INPUT_CLOSED\n"));
|
||||
SOCKET_LOG((" MSG_INPUT_CLOSED\n"));
|
||||
OnMsgInputClosed(status);
|
||||
break;
|
||||
|
||||
case MSG_INPUT_PENDING:
|
||||
LOG((" MSG_INPUT_PENDING\n"));
|
||||
SOCKET_LOG((" MSG_INPUT_PENDING\n"));
|
||||
OnMsgInputPending();
|
||||
break;
|
||||
|
||||
case MSG_OUTPUT_CLOSED:
|
||||
LOG((" MSG_OUTPUT_CLOSED\n"));
|
||||
SOCKET_LOG((" MSG_OUTPUT_CLOSED\n"));
|
||||
OnMsgOutputClosed(status);
|
||||
break;
|
||||
|
||||
case MSG_OUTPUT_PENDING:
|
||||
LOG((" MSG_OUTPUT_PENDING\n"));
|
||||
SOCKET_LOG((" MSG_OUTPUT_PENDING\n"));
|
||||
OnMsgOutputPending();
|
||||
break;
|
||||
case MSG_TIMEOUT_CHANGED:
|
||||
LOG((" MSG_TIMEOUT_CHANGED\n"));
|
||||
SOCKET_LOG((" MSG_TIMEOUT_CHANGED\n"));
|
||||
mPollTimeout = mTimeouts[(mState == STATE_TRANSFERRING)
|
||||
? TIMEOUT_READ_WRITE : TIMEOUT_CONNECT];
|
||||
break;
|
||||
default:
|
||||
LOG((" unhandled event!\n"));
|
||||
SOCKET_LOG((" unhandled event!\n"));
|
||||
}
|
||||
|
||||
if (NS_FAILED(mCondition)) {
|
||||
LOG((" after event [this=%x cond=%x]\n", this, mCondition));
|
||||
SOCKET_LOG((" after event [this=%x cond=%x]\n", this, mCondition));
|
||||
if (!mAttached) // need to process this error ourselves...
|
||||
OnSocketDetached(nsnull);
|
||||
}
|
||||
@ -1501,11 +1501,11 @@ nsSocketTransport::OnSocketEvent(PRUint32 type, nsresult status, nsISupports *pa
|
||||
void
|
||||
nsSocketTransport::OnSocketReady(PRFileDesc *fd, PRInt16 outFlags)
|
||||
{
|
||||
LOG(("nsSocketTransport::OnSocketReady [this=%x outFlags=%hd]\n",
|
||||
SOCKET_LOG(("nsSocketTransport::OnSocketReady [this=%x outFlags=%hd]\n",
|
||||
this, outFlags));
|
||||
|
||||
if (outFlags == -1) {
|
||||
LOG(("socket timeout expired\n"));
|
||||
SOCKET_LOG(("socket timeout expired\n"));
|
||||
mCondition = NS_ERROR_NET_TIMEOUT;
|
||||
return;
|
||||
}
|
||||
@ -1557,7 +1557,7 @@ nsSocketTransport::OnSocketReady(PRFileDesc *fd, PRInt16 outFlags)
|
||||
mCondition = ErrorAccordingToNSPR(code);
|
||||
if ((mCondition == NS_ERROR_CONNECTION_REFUSED) && !mProxyHost.IsEmpty())
|
||||
mCondition = NS_ERROR_PROXY_CONNECTION_REFUSED;
|
||||
LOG((" connection failed! [reason=%x]\n", mCondition));
|
||||
SOCKET_LOG((" connection failed! [reason=%x]\n", mCondition));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1574,7 +1574,7 @@ nsSocketTransport::OnSocketReady(PRFileDesc *fd, PRInt16 outFlags)
|
||||
void
|
||||
nsSocketTransport::OnSocketDetached(PRFileDesc *fd)
|
||||
{
|
||||
LOG(("nsSocketTransport::OnSocketDetached [this=%x cond=%x]\n",
|
||||
SOCKET_LOG(("nsSocketTransport::OnSocketDetached [this=%x cond=%x]\n",
|
||||
this, mCondition));
|
||||
|
||||
NS_ASSERTION(PR_GetCurrentThread() == gSocketThread, "wrong thread");
|
||||
@ -1651,7 +1651,7 @@ nsSocketTransport::OpenInputStream(PRUint32 flags,
|
||||
PRUint32 segcount,
|
||||
nsIInputStream **result)
|
||||
{
|
||||
LOG(("nsSocketTransport::OpenInputStream [this=%x flags=%x]\n",
|
||||
SOCKET_LOG(("nsSocketTransport::OpenInputStream [this=%x flags=%x]\n",
|
||||
this, flags));
|
||||
|
||||
NS_ENSURE_TRUE(!mInput.IsReferenced(), NS_ERROR_UNEXPECTED);
|
||||
@ -1699,7 +1699,7 @@ nsSocketTransport::OpenOutputStream(PRUint32 flags,
|
||||
PRUint32 segcount,
|
||||
nsIOutputStream **result)
|
||||
{
|
||||
LOG(("nsSocketTransport::OpenOutputStream [this=%x flags=%x]\n",
|
||||
SOCKET_LOG(("nsSocketTransport::OpenOutputStream [this=%x flags=%x]\n",
|
||||
this, flags));
|
||||
|
||||
NS_ENSURE_TRUE(!mOutput.IsReferenced(), NS_ERROR_UNEXPECTED);
|
||||
|
@ -117,7 +117,7 @@ nsSocketTransportService::GetThreadSafely()
|
||||
NS_IMETHODIMP
|
||||
nsSocketTransportService::Dispatch(nsIRunnable *event, PRUint32 flags)
|
||||
{
|
||||
LOG(("STS dispatch [%p]\n", event));
|
||||
SOCKET_LOG(("STS dispatch [%p]\n", event));
|
||||
|
||||
nsCOMPtr<nsIThread> thread = GetThreadSafely();
|
||||
NS_ENSURE_TRUE(thread, NS_ERROR_NOT_INITIALIZED);
|
||||
@ -144,7 +144,7 @@ nsSocketTransportService::IsOnCurrentThread(PRBool *result)
|
||||
NS_IMETHODIMP
|
||||
nsSocketTransportService::NotifyWhenCanAttachSocket(nsIRunnable *event)
|
||||
{
|
||||
LOG(("nsSocketTransportService::NotifyWhenCanAttachSocket\n"));
|
||||
SOCKET_LOG(("nsSocketTransportService::NotifyWhenCanAttachSocket\n"));
|
||||
|
||||
NS_ASSERTION(PR_GetCurrentThread() == gSocketThread, "wrong thread");
|
||||
|
||||
@ -159,7 +159,7 @@ nsSocketTransportService::NotifyWhenCanAttachSocket(nsIRunnable *event)
|
||||
NS_IMETHODIMP
|
||||
nsSocketTransportService::AttachSocket(PRFileDesc *fd, nsASocketHandler *handler)
|
||||
{
|
||||
LOG(("nsSocketTransportService::AttachSocket [handler=%x]\n", handler));
|
||||
SOCKET_LOG(("nsSocketTransportService::AttachSocket [handler=%x]\n", handler));
|
||||
|
||||
NS_ASSERTION(PR_GetCurrentThread() == gSocketThread, "wrong thread");
|
||||
|
||||
@ -181,7 +181,7 @@ nsSocketTransportService::AttachSocket(PRFileDesc *fd, nsASocketHandler *handler
|
||||
nsresult
|
||||
nsSocketTransportService::DetachSocket(SocketContext *sock)
|
||||
{
|
||||
LOG(("nsSocketTransportService::DetachSocket [handler=%x]\n", sock->mHandler));
|
||||
SOCKET_LOG(("nsSocketTransportService::DetachSocket [handler=%x]\n", sock->mHandler));
|
||||
|
||||
// inform the handler that this socket is going away
|
||||
sock->mHandler->OnSocketDetached(sock->mFD);
|
||||
@ -213,7 +213,7 @@ nsSocketTransportService::DetachSocket(SocketContext *sock)
|
||||
nsresult
|
||||
nsSocketTransportService::AddToPollList(SocketContext *sock)
|
||||
{
|
||||
LOG(("nsSocketTransportService::AddToPollList [handler=%x]\n", sock->mHandler));
|
||||
SOCKET_LOG(("nsSocketTransportService::AddToPollList [handler=%x]\n", sock->mHandler));
|
||||
|
||||
if (mActiveCount == NS_SOCKET_MAX_COUNT) {
|
||||
NS_ERROR("too many active sockets");
|
||||
@ -227,19 +227,19 @@ nsSocketTransportService::AddToPollList(SocketContext *sock)
|
||||
mPollList[mActiveCount].in_flags = sock->mHandler->mPollFlags;
|
||||
mPollList[mActiveCount].out_flags = 0;
|
||||
|
||||
LOG((" active=%u idle=%u\n", mActiveCount, mIdleCount));
|
||||
SOCKET_LOG((" active=%u idle=%u\n", mActiveCount, mIdleCount));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsSocketTransportService::RemoveFromPollList(SocketContext *sock)
|
||||
{
|
||||
LOG(("nsSocketTransportService::RemoveFromPollList [handler=%x]\n", sock->mHandler));
|
||||
SOCKET_LOG(("nsSocketTransportService::RemoveFromPollList [handler=%x]\n", sock->mHandler));
|
||||
|
||||
PRUint32 index = sock - mActiveList;
|
||||
NS_ASSERTION(index < NS_SOCKET_MAX_COUNT, "invalid index");
|
||||
|
||||
LOG((" index=%u mActiveCount=%u\n", index, mActiveCount));
|
||||
SOCKET_LOG((" index=%u mActiveCount=%u\n", index, mActiveCount));
|
||||
|
||||
if (index != mActiveCount-1) {
|
||||
mActiveList[index] = mActiveList[mActiveCount-1];
|
||||
@ -247,13 +247,13 @@ nsSocketTransportService::RemoveFromPollList(SocketContext *sock)
|
||||
}
|
||||
mActiveCount--;
|
||||
|
||||
LOG((" active=%u idle=%u\n", mActiveCount, mIdleCount));
|
||||
SOCKET_LOG((" active=%u idle=%u\n", mActiveCount, mIdleCount));
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsSocketTransportService::AddToIdleList(SocketContext *sock)
|
||||
{
|
||||
LOG(("nsSocketTransportService::AddToIdleList [handler=%x]\n", sock->mHandler));
|
||||
SOCKET_LOG(("nsSocketTransportService::AddToIdleList [handler=%x]\n", sock->mHandler));
|
||||
|
||||
if (mIdleCount == NS_SOCKET_MAX_COUNT) {
|
||||
NS_ERROR("too many idle sockets");
|
||||
@ -263,14 +263,14 @@ nsSocketTransportService::AddToIdleList(SocketContext *sock)
|
||||
mIdleList[mIdleCount] = *sock;
|
||||
mIdleCount++;
|
||||
|
||||
LOG((" active=%u idle=%u\n", mActiveCount, mIdleCount));
|
||||
SOCKET_LOG((" active=%u idle=%u\n", mActiveCount, mIdleCount));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsSocketTransportService::RemoveFromIdleList(SocketContext *sock)
|
||||
{
|
||||
LOG(("nsSocketTransportService::RemoveFromIdleList [handler=%x]\n", sock->mHandler));
|
||||
SOCKET_LOG(("nsSocketTransportService::RemoveFromIdleList [handler=%x]\n", sock->mHandler));
|
||||
|
||||
PRUint32 index = sock - &mIdleList[0];
|
||||
NS_ASSERTION(index < NS_SOCKET_MAX_COUNT, "invalid index");
|
||||
@ -279,7 +279,7 @@ nsSocketTransportService::RemoveFromIdleList(SocketContext *sock)
|
||||
mIdleList[index] = mIdleList[mIdleCount-1];
|
||||
mIdleCount--;
|
||||
|
||||
LOG((" active=%u idle=%u\n", mActiveCount, mIdleCount));
|
||||
SOCKET_LOG((" active=%u idle=%u\n", mActiveCount, mIdleCount));
|
||||
}
|
||||
|
||||
void
|
||||
@ -320,7 +320,7 @@ nsSocketTransportService::PollTimeout()
|
||||
if (r < minR)
|
||||
minR = r;
|
||||
}
|
||||
LOG(("poll timeout: %lu\n", minR));
|
||||
SOCKET_LOG(("poll timeout: %lu\n", minR));
|
||||
return PR_SecondsToInterval(minR);
|
||||
}
|
||||
|
||||
@ -352,13 +352,13 @@ nsSocketTransportService::Poll(PRBool wait, PRUint32 *interval)
|
||||
|
||||
PRIntervalTime ts = PR_IntervalNow();
|
||||
|
||||
LOG((" timeout = %i milliseconds\n",
|
||||
SOCKET_LOG((" timeout = %i milliseconds\n",
|
||||
PR_IntervalToMilliseconds(pollTimeout)));
|
||||
PRInt32 rv = PR_Poll(pollList, pollCount, pollTimeout);
|
||||
|
||||
PRIntervalTime passedInterval = PR_IntervalNow() - ts;
|
||||
|
||||
LOG((" ...returned after %i milliseconds\n",
|
||||
SOCKET_LOG((" ...returned after %i milliseconds\n",
|
||||
PR_IntervalToMilliseconds(passedInterval)));
|
||||
|
||||
*interval = PR_IntervalToSeconds(passedInterval);
|
||||
@ -409,7 +409,7 @@ nsSocketTransportService::Init()
|
||||
//
|
||||
if (!mThreadEvent) {
|
||||
NS_WARNING("running socket transport thread without a pollable event");
|
||||
LOG(("running socket transport thread without a pollable event"));
|
||||
SOCKET_LOG(("running socket transport thread without a pollable event"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -440,7 +440,7 @@ nsSocketTransportService::Init()
|
||||
NS_IMETHODIMP
|
||||
nsSocketTransportService::Shutdown()
|
||||
{
|
||||
LOG(("nsSocketTransportService::Shutdown\n"));
|
||||
SOCKET_LOG(("nsSocketTransportService::Shutdown\n"));
|
||||
|
||||
NS_ENSURE_STATE(NS_IsMainThread());
|
||||
|
||||
@ -559,7 +559,7 @@ nsSocketTransportService::AfterProcessNextEvent(nsIThreadInternal* thread,
|
||||
NS_IMETHODIMP
|
||||
nsSocketTransportService::Run()
|
||||
{
|
||||
LOG(("STS thread init\n"));
|
||||
SOCKET_LOG(("STS thread init\n"));
|
||||
|
||||
gSocketThread = PR_GetCurrentThread();
|
||||
|
||||
@ -589,7 +589,7 @@ nsSocketTransportService::Run()
|
||||
NS_ProcessNextEvent(thread);
|
||||
}
|
||||
|
||||
LOG(("STS shutting down thread\n"));
|
||||
SOCKET_LOG(("STS shutting down thread\n"));
|
||||
|
||||
// detach any sockets
|
||||
PRInt32 i;
|
||||
@ -604,14 +604,14 @@ nsSocketTransportService::Run()
|
||||
|
||||
gSocketThread = nsnull;
|
||||
|
||||
LOG(("STS thread exit\n"));
|
||||
SOCKET_LOG(("STS thread exit\n"));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsSocketTransportService::DoPollIteration(PRBool wait)
|
||||
{
|
||||
LOG(("STS poll iter [%d]\n", wait));
|
||||
SOCKET_LOG(("STS poll iter [%d]\n", wait));
|
||||
|
||||
PRInt32 i, count;
|
||||
|
||||
@ -629,7 +629,7 @@ nsSocketTransportService::DoPollIteration(PRBool wait)
|
||||
count = mIdleCount;
|
||||
for (i=mActiveCount-1; i>=0; --i) {
|
||||
//---
|
||||
LOG((" active [%u] { handler=%x condition=%x pollflags=%hu }\n", i,
|
||||
SOCKET_LOG((" active [%u] { handler=%x condition=%x pollflags=%hu }\n", i,
|
||||
mActiveList[i].mHandler,
|
||||
mActiveList[i].mHandler->mCondition,
|
||||
mActiveList[i].mHandler->mPollFlags));
|
||||
@ -649,7 +649,7 @@ nsSocketTransportService::DoPollIteration(PRBool wait)
|
||||
}
|
||||
for (i=count-1; i>=0; --i) {
|
||||
//---
|
||||
LOG((" idle [%u] { handler=%x condition=%x pollflags=%hu }\n", i,
|
||||
SOCKET_LOG((" idle [%u] { handler=%x condition=%x pollflags=%hu }\n", i,
|
||||
mIdleList[i].mHandler,
|
||||
mIdleList[i].mHandler->mCondition,
|
||||
mIdleList[i].mHandler->mPollFlags));
|
||||
@ -660,14 +660,14 @@ nsSocketTransportService::DoPollIteration(PRBool wait)
|
||||
MoveToPollList(&mIdleList[i]);
|
||||
}
|
||||
|
||||
LOG((" calling PR_Poll [active=%u idle=%u]\n", mActiveCount, mIdleCount));
|
||||
SOCKET_LOG((" calling PR_Poll [active=%u idle=%u]\n", mActiveCount, mIdleCount));
|
||||
|
||||
// Measures seconds spent while blocked on PR_Poll
|
||||
PRUint32 pollInterval;
|
||||
|
||||
PRInt32 n = Poll(wait, &pollInterval);
|
||||
if (n < 0) {
|
||||
LOG((" PR_Poll error [%d]\n", PR_GetError()));
|
||||
SOCKET_LOG((" PR_Poll error [%d]\n", PR_GetError()));
|
||||
pollError = PR_TRUE;
|
||||
}
|
||||
else {
|
||||
@ -722,7 +722,7 @@ nsSocketTransportService::DoPollIteration(PRBool wait)
|
||||
if (!mThreadEvent) {
|
||||
NS_WARNING("running socket transport thread without "
|
||||
"a pollable event");
|
||||
LOG(("running socket transport thread without "
|
||||
SOCKET_LOG(("running socket transport thread without "
|
||||
"a pollable event"));
|
||||
}
|
||||
mPollList[0].fd = mThreadEvent;
|
||||
|
@ -59,8 +59,8 @@
|
||||
//
|
||||
extern PRLogModuleInfo *gSocketTransportLog;
|
||||
#endif
|
||||
#define LOG(args) PR_LOG(gSocketTransportLog, PR_LOG_DEBUG, args)
|
||||
#define LOG_ENABLED() PR_LOG_TEST(gSocketTransportLog, PR_LOG_DEBUG)
|
||||
#define SOCKET_LOG(args) PR_LOG(gSocketTransportLog, PR_LOG_DEBUG, args)
|
||||
#define SOCKET_LOG_ENABLED() PR_LOG_TEST(gSocketTransportLog, PR_LOG_DEBUG)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user