Bug 606719 - Browser stalls with connections left hanging in TCP close wait state. Part 1: rename LOG to SOCKET_LOG. r=mcmanus, a=b7+
authorDan Witte <dwitte@mozilla.com>
Thu, 28 Oct 2010 10:09:08 -0700
changeset 56649 fa02ac41c6504a9103e82f0ff50c90e0380a5254
parent 56648 cebb9d72f310e82dabd1778db4d6eebaef031d31
child 56650 16f18e41dcf349bed4dbfbaed141f784eed1fbda
push idunknown
push userunknown
push dateunknown
reviewersmcmanus, b7
bugs606719
milestone2.0b8pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 606719 - Browser stalls with connections left hanging in TCP close wait state. Part 1: rename LOG to SOCKET_LOG. r=mcmanus, a=b7+
netwerk/base/src/nsServerSocket.cpp
netwerk/base/src/nsSocketTransport2.cpp
netwerk/base/src/nsSocketTransportService2.cpp
netwerk/base/src/nsSocketTransportService2.h
--- a/netwerk/base/src/nsServerSocket.cpp
+++ b/netwerk/base/src/nsServerSocket.cpp
@@ -94,34 +94,34 @@ nsServerSocket::~nsServerSocket()
   // release our reference to the STS
   nsSocketTransportService *serv = gSocketTransportService;
   NS_RELEASE(serv);
 }
 
 void
 nsServerSocket::OnMsgClose()
 {
-  LOG(("nsServerSocket::OnMsgClose [this=%p]\n", this));
+  SOCKET_LOG(("nsServerSocket::OnMsgClose [this=%p]\n", this));
 
   if (NS_FAILED(mCondition))
     return;
 
   // tear down socket.  this signals the STS to detach our socket handler.
   mCondition = NS_BINDING_ABORTED;
 
   // if we are attached, then we'll close the socket in our OnSocketDetached.
   // otherwise, call OnSocketDetached from here.
   if (!mAttached)
     OnSocketDetached(mFD);
 }
 
 void
 nsServerSocket::OnMsgAttach()
 {
-  LOG(("nsServerSocket::OnMsgAttach [this=%p]\n", this));
+  SOCKET_LOG(("nsServerSocket::OnMsgAttach [this=%p]\n", this));
 
   if (NS_FAILED(mCondition))
     return;
 
   mCondition = TryAttach();
   
   // if we hit an error while trying to attach then bail...
   if (NS_FAILED(mCondition))
--- a/netwerk/base/src/nsSocketTransport2.cpp
+++ b/netwerk/base/src/nsSocketTransport2.cpp
@@ -135,17 +135,17 @@ static PRErrorCode RandomizeConnectError
             // This error will cause this socket transport to error out;
             // however, if the consumer is HTTP, then the HTTP transaction
             // should be restarted when this error occurs.
             //
             { PR_CONNECT_RESET_ERROR, "PR_CONNECT_RESET_ERROR" },
         };
         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;
 }
 #endif
 
 //-----------------------------------------------------------------------------
 
 static PRBool
@@ -197,17 +197,17 @@ ErrorAccordingToNSPR(PRErrorCode errorCo
     case PR_CONNECT_TIMEOUT_ERROR:
         rv = NS_ERROR_NET_TIMEOUT;
         break;
     default:
         if (IsNSSErrorCode(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;
 }
 
 //-----------------------------------------------------------------------------
 // socket input stream impl 
 //-----------------------------------------------------------------------------
 
 nsSocketInputStream::nsSocketInputStream(nsSocketTransport *trans)
@@ -225,17 +225,17 @@ nsSocketInputStream::~nsSocketInputStrea
 
 // called on the socket transport thread...
 //
 //   condition : failure code if socket has been closed
 //
 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");
 
     nsCOMPtr<nsIInputStreamCallback> callback;
     {
         nsAutoLock lock(mTransport->mLock);
 
@@ -279,17 +279,17 @@ NS_IMETHODIMP
 nsSocketInputStream::Close()
 {
     return CloseWithStatus(NS_BASE_STREAM_CLOSED);
 }
 
 NS_IMETHODIMP
 nsSocketInputStream::Available(PRUint32 *avail)
 {
-    LOG(("nsSocketInputStream::Available [this=%x]\n", this));
+    SOCKET_LOG(("nsSocketInputStream::Available [this=%x]\n", this));
 
     *avail = 0;
 
     PRFileDesc *fd;
     {
         nsAutoLock lock(mTransport->mLock);
 
         if (NS_FAILED(mCondition))
@@ -324,40 +324,40 @@ nsSocketInputStream::Available(PRUint32 
     if (NS_FAILED(rv))
         mTransport->OnInputClosed(rv);
     return rv;
 }
 
 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;
 
     PRFileDesc *fd;
     {
         nsAutoLock lock(mTransport->mLock);
 
         if (NS_FAILED(mCondition))
             return (mCondition == NS_BASE_STREAM_CLOSED) ? NS_OK : mCondition;
 
         fd = mTransport->GetFD_Locked();
         if (!fd)
             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;
     {
         nsAutoLock lock(mTransport->mLock);
 
 #ifdef ENABLE_SOCKET_TRACING
         if (n > 0)
             mTransport->TraceInBuf(buf, n);
@@ -398,17 +398,17 @@ nsSocketInputStream::IsNonBlocking(PRBoo
 {
     *nonblocking = PR_TRUE;
     return NS_OK;
 }
 
 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
  
     nsresult rv;
     {
         nsAutoLock lock(mTransport->mLock);
 
         if (NS_SUCCEEDED(mCondition))
@@ -422,17 +422,17 @@ nsSocketInputStream::CloseWithStatus(nsr
 }
 
 NS_IMETHODIMP
 nsSocketInputStream::AsyncWait(nsIInputStreamCallback *callback,
                                PRUint32 flags,
                                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.
     // (different from callback when target is not null)
     nsCOMPtr<nsIInputStreamCallback> directCallback;
     {
         nsAutoLock lock(mTransport->mLock);
 
@@ -484,17 +484,17 @@ nsSocketOutputStream::~nsSocketOutputStr
 
 // called on the socket transport thread...
 //
 //   condition : failure code if socket has been closed
 //
 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");
 
     nsCOMPtr<nsIOutputStreamCallback> callback;
     {
         nsAutoLock lock(mTransport->mLock);
 
@@ -544,17 +544,17 @@ NS_IMETHODIMP
 nsSocketOutputStream::Flush()
 {
     return NS_OK;
 }
 
 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;
 
     if (count == 0)
         return NS_OK;
 
     PRFileDesc *fd;
     {
@@ -563,24 +563,24 @@ nsSocketOutputStream::Write(const char *
         if (NS_FAILED(mCondition))
             return mCondition;
         
         fd = mTransport->GetFD_Locked();
         if (!fd)
             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;
     {
         nsAutoLock lock(mTransport->mLock);
 
 #ifdef ENABLE_SOCKET_TRACING
     if (n > 0)
@@ -640,17 +640,17 @@ nsSocketOutputStream::IsNonBlocking(PRBo
 {
     *nonblocking = PR_TRUE;
     return NS_OK;
 }
 
 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
  
     nsresult rv;
     {
         nsAutoLock lock(mTransport->mLock);
 
         if (NS_SUCCEEDED(mCondition))
@@ -664,17 +664,17 @@ nsSocketOutputStream::CloseWithStatus(ns
 }
 
 NS_IMETHODIMP
 nsSocketOutputStream::AsyncWait(nsIOutputStreamCallback *callback,
                                 PRUint32 flags,
                                 PRUint32 amount,
                                 nsIEventTarget *target)
 {
-    LOG(("nsSocketOutputStream::AsyncWait [this=%x]\n", this));
+    SOCKET_LOG(("nsSocketOutputStream::AsyncWait [this=%x]\n", this));
 
     {
         nsAutoLock lock(mTransport->mLock);
 
         if (callback && target) {
             //
             // build event proxy
             //
@@ -716,27 +716,27 @@ nsSocketTransport::nsSocketTransport()
     , mLock(PR_NewLock())
     , mFD(nsnull)
     , mFDref(0)
     , mFDconnected(PR_FALSE)
     , mInput(this)
     , mOutput(this)
     , mQoSBits(0x00)
 {
-    LOG(("creating nsSocketTransport @%x\n", this));
+    SOCKET_LOG(("creating nsSocketTransport @%x\n", this));
 
     NS_ADDREF(gSocketTransportService);
 
     mTimeouts[TIMEOUT_CONNECT]    = PR_UINT16_MAX; // no timeout
     mTimeouts[TIMEOUT_READ_WRITE] = PR_UINT16_MAX; // no timeout
 }
 
 nsSocketTransport::~nsSocketTransport()
 {
-    LOG(("destroying nsSocketTransport @%x\n", this));
+    SOCKET_LOG(("destroying nsSocketTransport @%x\n", this));
 
     // cleanup socket type info
     if (mTypes) {
         PRUint32 i;
         for (i=0; i<mTypeCount; ++i)
             PL_strfree(mTypes[i]);
         free(mTypes);
     }
@@ -774,17 +774,17 @@ nsSocketTransport::Init(const char **typ
         // grab proxy type (looking for "socks" for example)
         proxyType = proxyInfo->Type();
         if (proxyType && (strcmp(proxyType, "http") == 0 ||
                           strcmp(proxyType, "direct") == 0 ||
                           strcmp(proxyType, "unknown") == 0))
             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"
     mTypeCount = typeCount + (proxyType != nsnull);
     if (!mTypeCount)
         return NS_OK;
 
     // if we have socket types, then the socket provider service had
@@ -864,40 +864,40 @@ nsSocketTransport::InitWithConnectedSock
     mFDconnected = 1;
 
     // make sure new socket is non-blocking
     PRSocketOptionData opt;
     opt.option = PR_SockOpt_Nonblocking;
     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.
     return PostEvent(MSG_RETRY_INIT_SOCKET);
 }
 
 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);
     if (!event)
         return NS_ERROR_OUT_OF_MEMORY;
 
     return gSocketTransportService->Dispatch(event, NS_DISPATCH_NORMAL);
 }
 
 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;
     {
         nsAutoLock lock(mLock);
         sink = mEventSink;
         switch (status) {
         case STATUS_SENDING_TO:
@@ -913,17 +913,17 @@ nsSocketTransport::SendStatus(nsresult s
     }
     if (sink)
         sink->OnTransportStatus(this, status, progress, LL_MAXUINT);
 }
 
 nsresult
 nsSocketTransport::ResolveHost()
 {
-    LOG(("nsSocketTransport::ResolveHost [this=%x]\n", this));
+    SOCKET_LOG(("nsSocketTransport::ResolveHost [this=%x]\n", this));
 
     nsresult rv;
 
     if (!mProxyHost.IsEmpty()) {
         if (!mProxyTransparent || mProxyTransparentResolvesHost) {
             // When not resolving mHost locally, we still want to ensure that
             // it only contains valid characters.  See bug 304904 for details.
             if (!net_IsValidHostName(mHost))
@@ -950,29 +950,29 @@ nsSocketTransport::ResolveHost()
 
     PRUint32 dnsFlags = 0;
     if (mConnectionFlags & nsSocketTransport::BYPASS_CACHE)
         dnsFlags = nsIDNSService::RESOLVE_BYPASS_CACHE;
 
     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)
             SendStatus(STATUS_RESOLVING);
     }
     return rv;
 }
 
 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;
 
     proxyTransparent = PR_FALSE;
     usingSSL = PR_FALSE;
 
     if (mTypeCount == 0) {
         fd = PR_OpenTCPSocket(mNetAddr.raw.family);
@@ -990,17 +990,17 @@ nsSocketTransport::BuildSocket(PRFileDes
         const char *proxyHost  = mProxyHost.IsEmpty() ? nsnull : mProxyHost.get();
         PRInt32     proxyPort  = (PRInt32) mProxyPort;
         PRUint32    proxyFlags = 0;
 
         PRUint32 i;
         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))
                 break;
 
             if (mProxyTransparentResolvesHost)
                 proxyFlags |= nsISocketProvider::PROXY_RESOLVES_HOST;
             
@@ -1038,17 +1038,17 @@ nsSocketTransport::BuildSocket(PRFileDes
             PRBool isSSL = (strcmp(mTypes[i], "ssl") == 0);
             if (isSSL || (strcmp(mTypes[i], "starttls") == 0)) {
                 // remember security info and give notification callbacks to PSM...
                 nsCOMPtr<nsIInterfaceRequestor> callbacks;
                 {
                     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));
                 if (secCtrl)
                     secCtrl->SetNotificationCallbacks(callbacks);
                 // remember if socket type is SSL so we can ProxyStartSSL if need be.
                 usingSSL = isSSL;
             }
@@ -1058,29 +1058,29 @@ nsSocketTransport::BuildSocket(PRFileDes
                 // it do not have to worry about proxy stuff
                 proxyHost = nsnull;
                 proxyPort = -1;
                 proxyTransparent = PR_TRUE;
             }
         }
 
         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);
         }
     }
 
     return rv;
 }
 
 nsresult
 nsSocketTransport::InitiateSocket()
 {
-    LOG(("nsSocketTransport::InitiateSocket [this=%x]\n", this));
+    SOCKET_LOG(("nsSocketTransport::InitiateSocket [this=%x]\n", this));
 
     nsresult rv;
 
     //
     // find out if it is going to be ok to attach another socket to the STS.
     // if not then we have to wait for the STS to tell us that it is ok.
     // the notification is asynchronous, which means that when we could be
     // in a race to call AttachSocket once notified.  for this reason, when
@@ -1113,17 +1113,17 @@ nsSocketTransport::InitiateSocket()
     // create new socket fd, push io layers, etc.
     //
     PRFileDesc *fd;
     PRBool proxyTransparent;
     PRBool usingSSL;
 
     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;
     }
 
     PRStatus status;
 
     // Make the socket non-blocking...
     PRSocketOptionData opt;
     opt.option = PR_SockOpt_Nonblocking;
@@ -1160,26 +1160,26 @@ nsSocketTransport::InitiateSocket()
     // established a connection.
     {
         nsAutoLock lock(mLock);
         mFD = fd;
         mFDref = 1;
         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
 
     // 
     // Initiate the connect() to the host...  
     //
     status = PR_Connect(fd, &mNetAddr, NS_SOCKET_CONNECT_TIMEOUT);
     if (status == PR_SUCCESS) {
@@ -1210,17 +1210,17 @@ nsSocketTransport::InitiateSocket()
             if (mSecInfo && !mProxyHost.IsEmpty() && proxyTransparent && usingSSL) {
                 // if the connection phase is finished, and the ssl layer has
                 // been pushed, and we were proxying (transparently; ie. nothing
                 // has to happen in the protocol layer above us), it's time for
                 // the ssl to start doing it's thing.
                 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
                 // connection... wouldn't we need to call ProxyStartSSL after a call
                 // to PR_ConnectContinue indicates that we are connected?
                 //
                 // XXX this appears to be what the old socket transport did.  why
                 // isn't this broken?
@@ -1238,17 +1238,17 @@ nsSocketTransport::InitiateSocket()
     return rv;
 }
 
 PRBool
 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
     if (mState != STATE_RESOLVING && mState != STATE_CONNECTING)
         return PR_FALSE;
 
     // OK to check this outside mLock
     NS_ASSERTION(!mFDconnected, "socket should not be connected");
@@ -1262,17 +1262,17 @@ nsSocketTransport::RecoverFromError()
         return PR_FALSE;
 
     PRBool tryAgain = PR_FALSE;
 
     // try next ip address only if past the resolver stage...
     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;
         }
     }
 
 #if defined(XP_WIN) || defined(MOZ_PLATFORM_MAEMO)
     // If not trying next address, try to make a connection using dialup. 
     // Retry if that connection is made.
     if (!tryAgain) {
@@ -1306,17 +1306,17 @@ nsSocketTransport::RecoverFromError()
 
     return tryAgain;
 }
 
 // called on the socket thread only
 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");
 
     mInputClosed = PR_TRUE;
     // check if event should affect entire transport
     if (NS_FAILED(reason) && (reason != NS_BASE_STREAM_CLOSED))
         mCondition = reason;                // XXX except if NS_FAILED(mCondition), right??
@@ -1328,17 +1328,17 @@ nsSocketTransport::OnMsgInputClosed(nsre
         mInput.OnSocketReady(reason);
     }
 }
 
 // called on the socket thread only
 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");
 
     mOutputClosed = PR_TRUE;
     // check if event should affect entire transport
     if (NS_FAILED(reason) && (reason != NS_BASE_STREAM_CLOSED))
         mCondition = reason;                // XXX except if NS_FAILED(mCondition), right??
@@ -1349,17 +1349,17 @@ nsSocketTransport::OnMsgOutputClosed(nsr
             mPollFlags &= ~PR_POLL_WRITE;
         mOutput.OnSocketReady(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];
     mState = STATE_TRANSFERRING;
 
     // assign mFD (must do this within the transport lock), but take care not
     // to trample over mFDref if mFD is already set.
     {
@@ -1386,57 +1386,57 @@ nsSocketTransport::GetFD_Locked()
 }
 
 void
 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;
     }
 }
 
 //-----------------------------------------------------------------------------
 // socket event handler impl
 
 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.
         //
         mInput.OnSocketReady(mCondition);
         mOutput.OnSocketReady(mCondition);
         return;
     }
 
     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.
         //
         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);
             mDNSRecord->GetNextAddr(SocketPort(), &mNetAddr);
         }
         // status contains DNS lookup status
         if (NS_FAILED(status)) {
             // When using a HTTP proxy, NS_ERROR_UNKNOWN_HOST means the HTTP 
@@ -1454,63 +1454,63 @@ nsSocketTransport::OnSocketEvent(PRUint3
             mCondition = InitiateSocket();
         break;
 
     case MSG_RETRY_INIT_SOCKET:
         mCondition = InitiateSocket();
         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);
     }
     else if (mPollFlags == PR_POLL_EXCEPT)
         mPollFlags = 0; // make idle
 }
 
 //-----------------------------------------------------------------------------
 // socket handler impl
 
 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;
     }
 
     if (mState == STATE_TRANSFERRING) {
         // if waiting to write and socket is writable or hit an exception.
         if ((mPollFlags & PR_POLL_WRITE) && (outFlags & ~PR_POLL_READ)) {
             // assume that we won't need to poll any longer (the stream will
@@ -1552,34 +1552,34 @@ nsSocketTransport::OnSocketReady(PRFileD
             } 
             else {
                 //
                 // else, the connection failed...
                 //
                 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));
             }
         }
     }
     else {
         NS_ERROR("unexpected socket state");
         mCondition = NS_ERROR_UNEXPECTED;
     }
 
     if (mPollFlags == PR_POLL_EXCEPT)
         mPollFlags = 0; // make idle
 }
 
 // called on the socket thread only
 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");
 
     // if we didn't initiate this detach, then be sure to pass an error
     // condition up to our consumers.  (e.g., STS is shutting down.)
     if (NS_SUCCEEDED(mCondition))
         mCondition = NS_ERROR_ABORT;
@@ -1646,17 +1646,17 @@ NS_IMPL_CI_INTERFACE_GETTER3(nsSocketTra
                              nsIDNSListener)
 
 NS_IMETHODIMP
 nsSocketTransport::OpenInputStream(PRUint32 flags,
                                    PRUint32 segsize,
                                    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);
 
     nsresult rv;
     nsCOMPtr<nsIAsyncInputStream> pipeIn;
 
     if (!(flags & OPEN_UNBUFFERED) || (flags & OPEN_BLOCKING)) {
@@ -1694,17 +1694,17 @@ nsSocketTransport::OpenInputStream(PRUin
 }
 
 NS_IMETHODIMP
 nsSocketTransport::OpenOutputStream(PRUint32 flags,
                                     PRUint32 segsize,
                                     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);
 
     nsresult rv;
     nsCOMPtr<nsIAsyncOutputStream> pipeOut;
     if (!(flags & OPEN_UNBUFFERED) || (flags & OPEN_BLOCKING)) {
         // XXX if the caller wants blocking, then the caller also gets buffered!
--- a/netwerk/base/src/nsSocketTransportService2.cpp
+++ b/netwerk/base/src/nsSocketTransportService2.cpp
@@ -112,17 +112,17 @@ nsSocketTransportService::GetThreadSafel
     nsIThread* result = mThread;
     NS_IF_ADDREF(result);
     return result;
 }
 
 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);
     nsresult rv = thread->Dispatch(event, flags);
     if (rv == NS_ERROR_UNEXPECTED) {
         // Thread is no longer accepting events. We must have just shut it
         // down on the main thread. Pretend we never saw it.
         rv = NS_ERROR_NOT_INITIALIZED;
@@ -139,32 +139,32 @@ nsSocketTransportService::IsOnCurrentThr
 }
 
 //-----------------------------------------------------------------------------
 // socket api (socket thread only)
 
 NS_IMETHODIMP
 nsSocketTransportService::NotifyWhenCanAttachSocket(nsIRunnable *event)
 {
-    LOG(("nsSocketTransportService::NotifyWhenCanAttachSocket\n"));
+    SOCKET_LOG(("nsSocketTransportService::NotifyWhenCanAttachSocket\n"));
 
     NS_ASSERTION(PR_GetCurrentThread() == gSocketThread, "wrong thread");
 
     if (CanAttachSocket()) {
         return Dispatch(event, NS_DISPATCH_NORMAL);
     }
 
     mPendingSocketQ.PutEvent(event);
     return NS_OK;
 }
 
 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");
 
     if (!CanAttachSocket()) {
         return NS_ERROR_NOT_AVAILABLE;
     }
 
     SocketContext sock;
@@ -176,17 +176,17 @@ nsSocketTransportService::AttachSocket(P
     if (NS_SUCCEEDED(rv))
         NS_ADDREF(handler);
     return rv;
 }
 
 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);
 
     // cleanup
     sock->mFD = nsnull;
     NS_RELEASE(sock->mHandler);
 
@@ -208,83 +208,83 @@ nsSocketTransportService::DetachSocket(S
         return Dispatch(event, NS_DISPATCH_NORMAL);
     }
     return NS_OK;
 }
 
 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");
         return NS_ERROR_UNEXPECTED;
     }
 
     mActiveList[mActiveCount] = *sock;
     mActiveCount++;
 
     mPollList[mActiveCount].fd = sock->mFD;
     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];
         mPollList[index+1] = mPollList[mActiveCount];
     }
     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");
         return NS_ERROR_UNEXPECTED;
     }
 
     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");
 
     if (index != mIdleCount-1)
         mIdleList[index] = mIdleList[mIdleCount-1];
     mIdleCount--;
 
-    LOG(("  active=%u idle=%u\n", mActiveCount, mIdleCount));
+    SOCKET_LOG(("  active=%u idle=%u\n", mActiveCount, mIdleCount));
 }
 
 void
 nsSocketTransportService::MoveToIdleList(SocketContext *sock)
 {
     nsresult rv = AddToIdleList(sock);
     if (NS_FAILED(rv))
         DetachSocket(sock);
@@ -315,17 +315,17 @@ nsSocketTransportService::PollTimeout()
         // mPollTimeout could be less than mElapsedTime if setTimeout
         // was called with a value smaller than mElapsedTime.
         PRUint32 r = (s.mElapsedTime < s.mHandler->mPollTimeout)
           ? s.mHandler->mPollTimeout - s.mElapsedTime
           : 0;
         if (r < minR)
             minR = r;
     }
-    LOG(("poll timeout: %lu\n", minR));
+    SOCKET_LOG(("poll timeout: %lu\n", minR));
     return PR_SecondsToInterval(minR);
 }
 
 PRInt32
 nsSocketTransportService::Poll(PRBool wait, PRUint32 *interval)
 {
     PRPollDesc *pollList;
     PRUint32 pollCount;
@@ -347,23 +347,23 @@ nsSocketTransportService::Poll(PRBool wa
         pollTimeout = PR_MillisecondsToInterval(25);
     }
 
     if (!wait)
         pollTimeout = PR_INTERVAL_NO_WAIT;
 
     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);
     return rv;
 }
 
 //-----------------------------------------------------------------------------
 // xpcom api
@@ -404,17 +404,17 @@ nsSocketTransportService::Init()
         // NOTE: per bug 191739, this failure could also be caused by lack
         // of a loopback device on Windows and OS/2 platforms (NSPR creates
         // a loopback socket pair on these platforms to implement a pollable
         // event object).  if we can't create a pollable event, then we'll
         // have to "busy wait" to implement the socket event queue :-(
         //
         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"));
         }
     }
     
     NS_TIME_FUNCTION_MARK("Created thread");
 
     nsCOMPtr<nsIThread> thread;
     nsresult rv = NS_NewThread(getter_AddRefs(thread), this);
     if (NS_FAILED(rv)) return rv;
@@ -435,17 +435,17 @@ nsSocketTransportService::Init()
     mInitialized = PR_TRUE;
     return NS_OK;
 }
 
 // called from main thread only
 NS_IMETHODIMP
 nsSocketTransportService::Shutdown()
 {
-    LOG(("nsSocketTransportService::Shutdown\n"));
+    SOCKET_LOG(("nsSocketTransportService::Shutdown\n"));
 
     NS_ENSURE_STATE(NS_IsMainThread());
 
     if (!mInitialized)
         return NS_OK;
 
     if (mShuttingDown)
         return NS_ERROR_UNEXPECTED;
@@ -554,17 +554,17 @@ nsSocketTransportService::AfterProcessNe
                                                 PRUint32 depth)
 {
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsSocketTransportService::Run()
 {
-    LOG(("STS thread init\n"));
+    SOCKET_LOG(("STS thread init\n"));
 
     gSocketThread = PR_GetCurrentThread();
 
     // add thread event to poll list (mThreadEvent may be NULL)
     mPollList[0].fd = mThreadEvent;
     mPollList[0].in_flags = PR_POLL_READ;
     mPollList[0].out_flags = 0;
 
@@ -584,39 +584,39 @@ nsSocketTransportService::Run()
             if (mShuttingDown)
                 break;
         }
 
         // wait for and process the next pending event
         NS_ProcessNextEvent(thread);
     }
 
-    LOG(("STS shutting down thread\n"));
+    SOCKET_LOG(("STS shutting down thread\n"));
 
     // detach any sockets
     PRInt32 i;
     for (i=mActiveCount-1; i>=0; --i)
         DetachSocket(&mActiveList[i]);
     for (i=mIdleCount-1; i>=0; --i)
         DetachSocket(&mIdleList[i]);
 
     // Final pass over the event queue. This makes sure that events posted by
     // socket detach handlers get processed.
     NS_ProcessPendingEvents(thread);
 
     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;
 
     //
     // poll loop
     //
     PRBool pollError = PR_FALSE;
 
@@ -624,17 +624,17 @@ nsSocketTransportService::DoPollIteratio
     // walk active list backwards to see if any sockets should actually be
     // idle, then walk the idle list backwards to see if any idle sockets
     // should become active.  take care to check only idle sockets that
     // were idle to begin with ;-)
     //
     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));
         //---
         if (NS_FAILED(mActiveList[i].mHandler->mCondition))
             DetachSocket(&mActiveList[i]);
         else {
             PRUint16 in_flags = mActiveList[i].mHandler->mPollFlags;
@@ -644,35 +644,35 @@ nsSocketTransportService::DoPollIteratio
                 // update poll flags
                 mPollList[i+1].in_flags = in_flags;
                 mPollList[i+1].out_flags = 0;
             }
         }
     }
     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));
         //---
         if (NS_FAILED(mIdleList[i].mHandler->mCondition))
             DetachSocket(&mIdleList[i]);
         else if (mIdleList[i].mHandler->mPollFlags != 0)
             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 {
         //
         // service "active" sockets...
         //
         for (i=0; i<PRInt32(mActiveCount); ++i) {
             PRPollDesc &desc = mPollList[i+1];
@@ -717,17 +717,17 @@ nsSocketTransportService::DoPollIteratio
                 {
                     nsAutoLock lock(mLock);
                     PR_DestroyPollableEvent(mThreadEvent);
                     mThreadEvent = PR_NewPollableEvent();
                 }
                 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;
                 // mPollList[0].in_flags was already set to PR_POLL_READ
                 // in Run().
                 mPollList[0].out_flags = 0;
             }
         }
--- a/netwerk/base/src/nsSocketTransportService2.h
+++ b/netwerk/base/src/nsSocketTransportService2.h
@@ -54,18 +54,18 @@
 //-----------------------------------------------------------------------------
 
 #if defined(PR_LOGGING)
 //
 // set NSPR_LOG_MODULES=nsSocketTransport:5
 //
 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)
 
 //-----------------------------------------------------------------------------
 
 #define NS_SOCKET_MAX_COUNT    50
 #define NS_SOCKET_POLL_TIMEOUT PR_INTERVAL_NO_TIMEOUT
 
 //-----------------------------------------------------------------------------