From 28c02e1e6df61fb630efc1411cc091a87c779e37 Mon Sep 17 00:00:00 2001 From: Wes Kocher Date: Thu, 7 May 2015 11:13:24 -0700 Subject: [PATCH] Backed out 2 changesets (bug 1162336) for breaking at least windows builds Backed out changeset 8952a7fa4050 (bug 1162336) Backed out changeset 0170a6c2a5be (bug 1162336) --- netwerk/base/BackgroundFileSaver.cpp | 7 +++ netwerk/base/Predictor.cpp | 6 +++ netwerk/base/nsAsyncRedirectVerifyHelper.cpp | 4 ++ netwerk/base/nsAsyncStreamCopier.cpp | 4 ++ netwerk/base/nsAutodialWin.cpp | 4 ++ netwerk/base/nsChannelClassifier.cpp | 4 ++ netwerk/base/nsDirectoryIndexStream.cpp | 8 +++ netwerk/base/nsInputStreamPump.cpp | 4 ++ netwerk/base/nsLoadGroup.cpp | 53 ++++++++++++------- netwerk/base/nsPACMan.cpp | 2 + netwerk/base/nsProtocolProxyService.cpp | 2 + netwerk/base/nsRequestObserverProxy.cpp | 4 ++ netwerk/base/nsSocketTransport2.cpp | 8 ++- netwerk/base/nsSocketTransportService2.cpp | 4 ++ netwerk/base/nsSocketTransportService2.h | 2 + netwerk/base/nsStandardURL.cpp | 8 +++ netwerk/cache/nsCache.cpp | 3 ++ netwerk/cache/nsCache.h | 9 ++++ netwerk/cache/nsCacheService.cpp | 18 ++++--- netwerk/cache/nsCacheService.h | 2 + netwerk/cache/nsDiskCacheDevice.cpp | 2 + netwerk/cache/nsDiskCacheDeviceSQL.cpp | 10 ++-- netwerk/cache2/CacheFile.cpp | 3 ++ netwerk/cache2/CacheFileContextEvictor.cpp | 4 ++ netwerk/cache2/CacheFileIOManager.cpp | 29 +++++----- netwerk/cache2/CacheIndex.cpp | 2 + netwerk/cache2/CacheIndex.h | 2 + netwerk/cache2/CacheLog.cpp | 2 + netwerk/cache2/CacheLog.h | 5 +- netwerk/cache2/CacheStorageService.cpp | 14 ++--- netwerk/cookie/nsCookieService.cpp | 32 +++++++---- netwerk/dns/GetAddrInfo.cpp | 5 ++ netwerk/dns/nsHostResolver.cpp | 10 +++- netwerk/protocol/ftp/nsFTPChannel.cpp | 2 + .../protocol/ftp/nsFtpConnectionThread.cpp | 2 + .../protocol/ftp/nsFtpControlConnection.cpp | 2 + netwerk/protocol/ftp/nsFtpProtocolHandler.cpp | 5 +- netwerk/protocol/ftp/nsFtpProtocolHandler.h | 2 + netwerk/protocol/http/HttpBaseChannel.cpp | 19 ++++--- netwerk/protocol/http/HttpLog.h | 2 + netwerk/protocol/http/nsHttp.cpp | 2 + netwerk/protocol/http/nsHttpChannel.cpp | 19 ++++--- netwerk/protocol/http/nsHttpHandler.cpp | 2 + netwerk/protocol/http/nsHttpNTLMAuth.cpp | 2 + netwerk/protocol/http/nsHttpTransaction.cpp | 9 +++- netwerk/protocol/res/nsResProtocolHandler.cpp | 6 +++ .../rtsp/controller/RtspControllerChild.cpp | 2 + .../rtsp/controller/RtspControllerParent.cpp | 2 + .../websocket/BaseWebSocketChannel.cpp | 4 ++ .../websocket/WebSocketChannelParent.cpp | 2 + netwerk/protocol/websocket/WebSocketLog.h | 2 + .../protocol/wyciwyg/WyciwygChannelParent.cpp | 2 + netwerk/protocol/wyciwyg/nsWyciwyg.cpp | 2 + netwerk/protocol/wyciwyg/nsWyciwyg.h | 2 + .../wyciwyg/nsWyciwygProtocolHandler.cpp | 2 + netwerk/sctp/datachannel/DataChannel.cpp | 19 ++++++- netwerk/sctp/datachannel/DataChannelLog.h | 2 + netwerk/socket/nsSOCKSIOLayer.cpp | 22 +++++--- .../converters/nsFTPDirListingConv.cpp | 4 ++ .../linux/nsNotifyAddrListener_Linux.cpp | 6 +++ netwerk/system/win32/nsNotifyAddrListener.cpp | 6 +++ netwerk/test/TestBlockingSocket.cpp | 6 +++ netwerk/test/TestIOThreads.cpp | 4 ++ netwerk/test/TestOverlappedIO.cpp | 6 +++ netwerk/test/TestProtocols.cpp | 4 ++ netwerk/test/TestServ.cpp | 4 ++ netwerk/test/TestSocketIO.cpp | 6 +++ netwerk/test/TestSocketTransport.cpp | 4 ++ netwerk/test/TestStreamChannel.cpp | 6 +++ netwerk/test/TestStreamLoader.cpp | 4 ++ netwerk/test/TestStreamPump.cpp | 6 +++ netwerk/test/TestStreamTransport.cpp | 4 ++ netwerk/test/TestUpload.cpp | 4 ++ netwerk/wifi/nsWifiAccessPoint.cpp | 2 + netwerk/wifi/nsWifiMonitor.cpp | 4 ++ netwerk/wifi/nsWifiMonitor.h | 2 + netwerk/wifi/nsWifiMonitorGonk.cpp | 4 ++ 77 files changed, 405 insertions(+), 94 deletions(-) diff --git a/netwerk/base/BackgroundFileSaver.cpp b/netwerk/base/BackgroundFileSaver.cpp index c77f41f8c720..a3985996abc2 100644 --- a/netwerk/base/BackgroundFileSaver.cpp +++ b/netwerk/base/BackgroundFileSaver.cpp @@ -33,9 +33,14 @@ namespace mozilla { namespace net { // NSPR_LOG_MODULES=BackgroundFileSaver:5 +#if defined(PR_LOGGING) PRLogModuleInfo *BackgroundFileSaver::prlog = nullptr; #define LOG(args) PR_LOG(BackgroundFileSaver::prlog, PR_LOG_DEBUG, args) #define LOG_ENABLED() PR_LOG_TEST(BackgroundFileSaver::prlog, 4) +#else +#define LOG(args) +#define LOG_ENABLED() (false) +#endif //////////////////////////////////////////////////////////////////////////////// //// Globals @@ -110,8 +115,10 @@ BackgroundFileSaver::BackgroundFileSaver() , mActualTargetKeepPartial(false) , mDigestContext(nullptr) { +#if defined(PR_LOGGING) if (!prlog) prlog = PR_NewLogModule("BackgroundFileSaver"); +#endif LOG(("Created BackgroundFileSaver [this = %p]", this)); } diff --git a/netwerk/base/Predictor.cpp b/netwerk/base/Predictor.cpp index 9e750d295468..a5d4de80e67f 100644 --- a/netwerk/base/Predictor.cpp +++ b/netwerk/base/Predictor.cpp @@ -53,8 +53,12 @@ namespace net { Predictor *Predictor::sSelf = nullptr; +#if defined(PR_LOGGING) static PRLogModuleInfo *gPredictorLog = nullptr; #define PREDICTOR_LOG(args) PR_LOG(gPredictorLog, 4, args) +#else +#define PREDICTOR_LOG(args) +#endif #define RETURN_IF_FAILED(_rv) \ do { \ @@ -311,7 +315,9 @@ Predictor::Predictor() ,mMaxResourcesPerEntry(PREDICTOR_MAX_RESOURCES_DEFAULT) ,mStartupCount(1) { +#if defined(PR_LOGGING) gPredictorLog = PR_NewLogModule("NetworkPredictor"); +#endif MOZ_ASSERT(!sSelf, "multiple Predictor instances!"); sSelf = this; diff --git a/netwerk/base/nsAsyncRedirectVerifyHelper.cpp b/netwerk/base/nsAsyncRedirectVerifyHelper.cpp index 6a61a6910cc9..3858864bdf59 100644 --- a/netwerk/base/nsAsyncRedirectVerifyHelper.cpp +++ b/netwerk/base/nsAsyncRedirectVerifyHelper.cpp @@ -14,6 +14,7 @@ #include "nsIAsyncVerifyRedirectCallback.h" #undef LOG +#ifdef PR_LOGGING static PRLogModuleInfo * GetRedirectLog() { @@ -23,6 +24,9 @@ GetRedirectLog() return sLog; } #define LOG(args) PR_LOG(GetRedirectLog(), PR_LOG_DEBUG, args) +#else +#define LOG(args) +#endif NS_IMPL_ISUPPORTS(nsAsyncRedirectVerifyHelper, nsIAsyncVerifyRedirectCallback, diff --git a/netwerk/base/nsAsyncStreamCopier.cpp b/netwerk/base/nsAsyncStreamCopier.cpp index ad8584383c08..7287c53788aa 100644 --- a/netwerk/base/nsAsyncStreamCopier.cpp +++ b/netwerk/base/nsAsyncStreamCopier.cpp @@ -13,10 +13,12 @@ using namespace mozilla; #undef LOG +#if defined(PR_LOGGING) // // NSPR_LOG_MODULES=nsStreamCopier:5 // static PRLogModuleInfo *gStreamCopierLog = nullptr; +#endif #define LOG(args) PR_LOG(gStreamCopierLog, PR_LOG_DEBUG, args) /** @@ -67,8 +69,10 @@ nsAsyncStreamCopier::nsAsyncStreamCopier() , mIsPending(false) , mShouldSniffBuffering(false) { +#if defined(PR_LOGGING) if (!gStreamCopierLog) gStreamCopierLog = PR_NewLogModule("nsStreamCopier"); +#endif LOG(("Creating nsAsyncStreamCopier @%x\n", this)); } diff --git a/netwerk/base/nsAutodialWin.cpp b/netwerk/base/nsAutodialWin.cpp index e34c27a30c0f..d5a083565aeb 100644 --- a/netwerk/base/nsAutodialWin.cpp +++ b/netwerk/base/nsAutodialWin.cpp @@ -29,7 +29,9 @@ // the file nspr.log // +#ifdef PR_LOGGING static PRLogModuleInfo* gLog = nullptr; +#endif #undef LOGD #undef LOGE @@ -62,8 +64,10 @@ nsAutodial::~nsAutodial() // Returns NS_ERROR_FAILURE if error or NS_OK if success. nsresult nsAutodial::Init() { +#ifdef PR_LOGGING if (!gLog) gLog = PR_NewLogModule("Autodial"); +#endif mDefaultEntryName[0] = '\0'; mNumRASConnectionEntries = 0; diff --git a/netwerk/base/nsChannelClassifier.cpp b/netwerk/base/nsChannelClassifier.cpp index 7859e1abe1ab..5c7a36db352f 100644 --- a/netwerk/base/nsChannelClassifier.cpp +++ b/netwerk/base/nsChannelClassifier.cpp @@ -36,10 +36,12 @@ using mozilla::ArrayLength; using mozilla::Preferences; +#if defined(PR_LOGGING) // // NSPR_LOG_MODULES=nsChannelClassifier:5 // static PRLogModuleInfo *gChannelClassifierLog; +#endif #undef LOG #define LOG(args) PR_LOG(gChannelClassifierLog, PR_LOG_DEBUG, args) @@ -50,8 +52,10 @@ nsChannelClassifier::nsChannelClassifier() : mIsAllowListed(false), mSuspendedChannel(false) { +#if defined(PR_LOGGING) if (!gChannelClassifierLog) gChannelClassifierLog = PR_NewLogModule("nsChannelClassifier"); +#endif } nsresult diff --git a/netwerk/base/nsDirectoryIndexStream.cpp b/netwerk/base/nsDirectoryIndexStream.cpp index 2748892b16d7..f7560f6b48d0 100644 --- a/netwerk/base/nsDirectoryIndexStream.cpp +++ b/netwerk/base/nsDirectoryIndexStream.cpp @@ -18,7 +18,9 @@ #include "nsDirectoryIndexStream.h" #include "prlog.h" #include "prtime.h" +#ifdef PR_LOGGING static PRLogModuleInfo* gLog; +#endif #include "nsISimpleEnumerator.h" #ifdef THREADSAFE_I18N @@ -44,8 +46,10 @@ static PRLogModuleInfo* gLog; nsDirectoryIndexStream::nsDirectoryIndexStream() : mOffset(0), mStatus(NS_OK), mPos(0) { +#ifdef PR_LOGGING if (! gLog) gLog = PR_NewLogModule("nsDirectoryIndexStream"); +#endif PR_LOG(gLog, PR_LOG_DEBUG, ("nsDirectoryIndexStream[%p]: created", this)); @@ -92,6 +96,7 @@ nsDirectoryIndexStream::Init(nsIFile* aDir) if (!isDir) return NS_ERROR_ILLEGAL_VALUE; +#ifdef PR_LOGGING if (PR_LOG_TEST(gLog, PR_LOG_DEBUG)) { nsAutoCString path; aDir->GetNativePath(path); @@ -99,6 +104,7 @@ nsDirectoryIndexStream::Init(nsIFile* aDir) ("nsDirectoryIndexStream[%p]: initialized on %s", this, path.get())); } +#endif // Sigh. We have to allocate on the heap because there are no // assignment operators defined. @@ -239,6 +245,7 @@ nsDirectoryIndexStream::Read(char* aBuf, uint32_t aCount, uint32_t* aReadCount) nsIFile* current = mArray.ObjectAt(mPos); ++mPos; +#ifdef PR_LOGGING if (PR_LOG_TEST(gLog, PR_LOG_DEBUG)) { nsAutoCString path; current->GetNativePath(path); @@ -246,6 +253,7 @@ nsDirectoryIndexStream::Read(char* aBuf, uint32_t aCount, uint32_t* aReadCount) ("nsDirectoryIndexStream[%p]: iterated %s", this, path.get())); } +#endif // rjc: don't return hidden files/directories! // bbaetz: why not? diff --git a/netwerk/base/nsInputStreamPump.cpp b/netwerk/base/nsInputStreamPump.cpp index 8feb0bc564f4..83e789401e76 100644 --- a/netwerk/base/nsInputStreamPump.cpp +++ b/netwerk/base/nsInputStreamPump.cpp @@ -21,10 +21,12 @@ static NS_DEFINE_CID(kStreamTransportServiceCID, NS_STREAMTRANSPORTSERVICE_CID); +#if defined(PR_LOGGING) // // NSPR_LOG_MODULES=nsStreamPump:5 // static PRLogModuleInfo *gStreamPumpLog = nullptr; +#endif #undef LOG #define LOG(args) PR_LOG(gStreamPumpLog, PR_LOG_DEBUG, args) @@ -45,8 +47,10 @@ nsInputStreamPump::nsInputStreamPump() , mRetargeting(false) , mMonitor("nsInputStreamPump") { +#if defined(PR_LOGGING) if (!gStreamPumpLog) gStreamPumpLog = PR_NewLogModule("nsStreamPump"); +#endif } nsInputStreamPump::~nsInputStreamPump() diff --git a/netwerk/base/nsLoadGroup.cpp b/netwerk/base/nsLoadGroup.cpp index e334312991c2..8047f6407dac 100644 --- a/netwerk/base/nsLoadGroup.cpp +++ b/netwerk/base/nsLoadGroup.cpp @@ -27,6 +27,7 @@ using namespace mozilla; using namespace mozilla::net; +#if defined(PR_LOGGING) // // Log module for nsILoadGroup logging... // @@ -39,6 +40,7 @@ using namespace mozilla::net; // the file nspr.log // static PRLogModuleInfo* gLoadGroupLog = nullptr; +#endif #undef LOG #define LOG(args) PR_LOG(gLoadGroupLog, PR_LOG_DEBUG, args) @@ -121,9 +123,11 @@ nsLoadGroup::nsLoadGroup(nsISupports* outer) { NS_INIT_AGGREGATED(outer); +#if defined(PR_LOGGING) // Initialize the global PRLogModule for nsILoadGroup logging if (nullptr == gLoadGroupLog) gLoadGroupLog = PR_NewLogModule("LoadGroup"); +#endif LOG(("LOADGROUP [%x]: Created.\n", this)); } @@ -257,12 +261,12 @@ nsLoadGroup::Cancel(nsresult status) continue; } - if (PR_LOG_TEST(gLoadGroupLog, PR_LOG_DEBUG)) { - nsAutoCString nameStr; - request->GetName(nameStr); - LOG(("LOADGROUP [%x]: Canceling request %x %s.\n", - this, request, nameStr.get())); - } +#if defined(PR_LOGGING) + nsAutoCString nameStr; + request->GetName(nameStr); + LOG(("LOADGROUP [%x]: Canceling request %x %s.\n", + this, request, nameStr.get())); +#endif // // Remove the request from the load group... This may cause @@ -325,12 +329,12 @@ nsLoadGroup::Suspend() if (!request) continue; - if (PR_LOG_TEST(gLoadGroupLog, PR_LOG_DEBUG)) { - nsAutoCString nameStr; - request->GetName(nameStr); - LOG(("LOADGROUP [%x]: Suspending request %x %s.\n", - this, request, nameStr.get())); - } +#if defined(PR_LOGGING) + nsAutoCString nameStr; + request->GetName(nameStr); + LOG(("LOADGROUP [%x]: Suspending request %x %s.\n", + this, request, nameStr.get())); +#endif // Suspend the request... rv = request->Suspend(); @@ -377,12 +381,12 @@ nsLoadGroup::Resume() if (!request) continue; - if (PR_LOG_TEST(gLoadGroupLog, PR_LOG_DEBUG)) { - nsAutoCString nameStr; - request->GetName(nameStr); - LOG(("LOADGROUP [%x]: Resuming request %x %s.\n", - this, request, nameStr.get())); - } +#if defined(PR_LOGGING) + nsAutoCString nameStr; + request->GetName(nameStr); + LOG(("LOADGROUP [%x]: Resuming request %x %s.\n", + this, request, nameStr.get())); +#endif // Resume the request... rv = request->Resume(); @@ -466,12 +470,14 @@ nsLoadGroup::AddRequest(nsIRequest *request, nsISupports* ctxt) { nsresult rv; - if (PR_LOG_TEST(gLoadGroupLog, PR_LOG_DEBUG)) { +#if defined(PR_LOGGING) + { nsAutoCString nameStr; request->GetName(nameStr); LOG(("LOADGROUP [%x]: Adding request %x %s (count=%d).\n", this, request, nameStr.get(), mRequests.EntryCount())); } +#endif /* PR_LOGGING */ NS_ASSERTION(!PL_DHashTableSearch(&mRequests, request), "Entry added to loadgroup twice, don't do that"); @@ -480,8 +486,11 @@ nsLoadGroup::AddRequest(nsIRequest *request, nsISupports* ctxt) // Do not add the channel, if the loadgroup is being canceled... // if (mIsCanceling) { + +#if defined(PR_LOGGING) LOG(("LOADGROUP [%x]: AddChannel() ABORTED because LoadGroup is" " being canceled!!\n", this)); +#endif /* PR_LOGGING */ return NS_BINDING_ABORTED; } @@ -563,12 +572,14 @@ nsLoadGroup::RemoveRequest(nsIRequest *request, nsISupports* ctxt, NS_ENSURE_ARG_POINTER(request); nsresult rv; - if (PR_LOG_TEST(gLoadGroupLog, PR_LOG_DEBUG)) { +#if defined(PR_LOGGING) + { nsAutoCString nameStr; request->GetName(nameStr); LOG(("LOADGROUP [%x]: Removing request %x %s status %x (count=%d).\n", this, request, nameStr.get(), aStatus, mRequests.EntryCount() - 1)); } +#endif // Make sure we have a owning reference to the request we're about // to remove. @@ -651,10 +662,12 @@ nsLoadGroup::RemoveRequest(nsIRequest *request, nsISupports* ctxt, rv = observer->OnStopRequest(request, ctxt, aStatus); +#if defined(PR_LOGGING) if (NS_FAILED(rv)) { LOG(("LOADGROUP [%x]: OnStopRequest for request %x FAILED.\n", this, request)); } +#endif } // If that was the last request -> remove ourselves from loadgroup diff --git a/netwerk/base/nsPACMan.cpp b/netwerk/base/nsPACMan.cpp index ba0826e85971..31546b092078 100644 --- a/netwerk/base/nsPACMan.cpp +++ b/netwerk/base/nsPACMan.cpp @@ -25,6 +25,8 @@ using namespace mozilla; using namespace mozilla::net; +#if defined(PR_LOGGING) +#endif #undef LOG #define LOG(args) PR_LOG(GetProxyLog(), PR_LOG_DEBUG, args) diff --git a/netwerk/base/nsProtocolProxyService.cpp b/netwerk/base/nsProtocolProxyService.cpp index 91099c5a8819..2ee1de6f77b9 100644 --- a/netwerk/base/nsProtocolProxyService.cpp +++ b/netwerk/base/nsProtocolProxyService.cpp @@ -48,6 +48,8 @@ namespace mozilla { using namespace mozilla; #include "prlog.h" +#if defined(PR_LOGGING) +#endif #undef LOG #define LOG(args) PR_LOG(net::GetProxyLog(), PR_LOG_DEBUG, args) diff --git a/netwerk/base/nsRequestObserverProxy.cpp b/netwerk/base/nsRequestObserverProxy.cpp index af0c46cf3644..0ffbba46bdb4 100644 --- a/netwerk/base/nsRequestObserverProxy.cpp +++ b/netwerk/base/nsRequestObserverProxy.cpp @@ -13,7 +13,9 @@ using namespace mozilla; +#if defined(PR_LOGGING) static PRLogModuleInfo *gRequestObserverProxyLog; +#endif #undef LOG #define LOG(args) PR_LOG(gRequestObserverProxyLog, PR_LOG_DEBUG, args) @@ -174,8 +176,10 @@ nsRequestObserverProxy::Init(nsIRequestObserver *observer, nsISupports *context) { NS_ENSURE_ARG_POINTER(observer); +#if defined(PR_LOGGING) if (!gRequestObserverProxyLog) gRequestObserverProxyLog = PR_NewLogModule("nsRequestObserverProxy"); +#endif mObserver = new nsMainThreadPtrHolder(observer); mContext = new nsMainThreadPtrHolder(context); diff --git a/netwerk/base/nsSocketTransport2.cpp b/netwerk/base/nsSocketTransport2.cpp index aeebb3a6069c..d8c3405cc0c7 100644 --- a/netwerk/base/nsSocketTransport2.cpp +++ b/netwerk/base/nsSocketTransport2.cpp @@ -1251,6 +1251,7 @@ nsSocketTransport::InitiateSocket() // connected - Bug 853423. if (mConnectionFlags & nsISocketTransport::DISABLE_RFC1918 && IsIPAddrLocal(&mNetAddr)) { +#ifdef PR_LOGGING if (SOCKET_LOG_ENABLED()) { nsAutoCString netAddrCString; netAddrCString.SetCapacity(kIPv6CStrBufSize); @@ -1264,6 +1265,7 @@ nsSocketTransport::InitiateSocket() mHost.get(), mPort, mProxyHost.get(), mProxyPort, netAddrCString.get())); } +#endif mCondition = NS_ERROR_CONNECTION_REFUSED; OnSocketDetached(nullptr); return mCondition; @@ -1370,11 +1372,13 @@ nsSocketTransport::InitiateSocket() mPollTimeout = mTimeouts[TIMEOUT_CONNECT]; SendStatus(NS_NET_STATUS_CONNECTING_TO); +#if defined(PR_LOGGING) if (SOCKET_LOG_ENABLED()) { char buf[kNetAddrMaxCStrBufSize]; NetAddrToString(&mNetAddr, buf, sizeof(buf)); SOCKET_LOG((" trying address: %s\n", buf)); } +#endif // // Initiate the connect() to the host... @@ -2803,7 +2807,7 @@ nsSocketTransport::TraceOutBuf(const char *buf, int32_t n) static void LogNSPRError(const char* aPrefix, const void *aObjPtr) { -#if defined(DEBUG) +#if defined(PR_LOGGING) && defined(DEBUG) PRErrorCode errCode = PR_GetError(); int errLen = PR_GetErrorTextLength(); nsAutoCString errStr; @@ -2843,7 +2847,7 @@ nsSocketTransport::PRFileDescAutoLock::SetKeepaliveEnabled(bool aEnable) static void LogOSError(const char *aPrefix, const void *aObjPtr) { -#if defined(DEBUG) +#if defined(PR_LOGGING) && defined(DEBUG) MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread, "wrong thread"); #ifdef XP_WIN diff --git a/netwerk/base/nsSocketTransportService2.cpp b/netwerk/base/nsSocketTransportService2.cpp index 0c4d4b9f6853..959ee0f558d9 100644 --- a/netwerk/base/nsSocketTransportService2.cpp +++ b/netwerk/base/nsSocketTransportService2.cpp @@ -29,7 +29,9 @@ using namespace mozilla; using namespace mozilla::net; +#if defined(PR_LOGGING) PRLogModuleInfo *gSocketTransportLog = nullptr; +#endif nsSocketTransportService *gSocketTransportService = nullptr; PRThread *gSocketThread = nullptr; @@ -78,7 +80,9 @@ nsSocketTransportService::nsSocketTransportService() , mTelemetryEnabledPref(false) , mProbedMaxCount(false) { +#if defined(PR_LOGGING) gSocketTransportLog = PR_NewLogModule("nsSocketTransport"); +#endif NS_ASSERTION(NS_IsMainThread(), "wrong thread"); diff --git a/netwerk/base/nsSocketTransportService2.h b/netwerk/base/nsSocketTransportService2.h index a20f669318e2..777de4d5d1ff 100644 --- a/netwerk/base/nsSocketTransportService2.h +++ b/netwerk/base/nsSocketTransportService2.h @@ -25,10 +25,12 @@ struct PRPollDesc; //----------------------------------------------------------------------------- +#if defined(PR_LOGGING) // // set NSPR_LOG_MODULES=nsSocketTransport:5 // extern PRLogModuleInfo *gSocketTransportLog; +#endif #define SOCKET_LOG(args) PR_LOG(gSocketTransportLog, PR_LOG_DEBUG, args) #define SOCKET_LOG_ENABLED() PR_LOG_TEST(gSocketTransportLog, PR_LOG_DEBUG) diff --git a/netwerk/base/nsStandardURL.cpp b/netwerk/base/nsStandardURL.cpp index 4c736c5099df..b4a7bf3f3d32 100644 --- a/netwerk/base/nsStandardURL.cpp +++ b/netwerk/base/nsStandardURL.cpp @@ -37,10 +37,12 @@ bool nsStandardURL::gEscapeUTF8 = true; bool nsStandardURL::gAlwaysEncodeInUTF8 = true; char nsStandardURL::gHostLimitDigits[] = { '/', '\\', '?', '#', 0 }; +#if defined(PR_LOGGING) // // setenv NSPR_LOG_MODULES nsStandardURL:5 // static PRLogModuleInfo *gStandardURLLog; +#endif // The Chromium code defines its own LOG macro which we don't want #undef LOG @@ -252,8 +254,10 @@ nsStandardURL::nsStandardURL(bool aSupportsFileURL, bool aTrackURL) , mMutable(true) , mSupportsFileURL(aSupportsFileURL) { +#if defined(PR_LOGGING) if (!gStandardURLLog) gStandardURLLog = PR_NewLogModule("nsStandardURL"); +#endif LOG(("Creating nsStandardURL @%p\n", this)); @@ -1202,6 +1206,7 @@ nsStandardURL::SetSpec(const nsACString &input) return rv; } +#if defined(PR_LOGGING) if (LOG_ENABLED()) { LOG((" spec = %s\n", mSpec.get())); LOG((" port = %d\n", mPort)); @@ -1218,6 +1223,7 @@ nsStandardURL::SetSpec(const nsACString &input) LOG((" query = (%u,%d)\n", mQuery.mPos, mQuery.mLen)); LOG((" ref = (%u,%d)\n", mRef.mPos, mRef.mLen)); } +#endif return rv; } @@ -2704,12 +2710,14 @@ nsStandardURL::GetFile(nsIFile **result) if (NS_FAILED(rv)) return rv; +#if defined(PR_LOGGING) if (LOG_ENABLED()) { nsAutoCString path; mFile->GetNativePath(path); LOG(("nsStandardURL::GetFile [this=%p spec=%s resulting_path=%s]\n", this, mSpec.get(), path.get())); } +#endif // clone the file, so the caller can modify it. // XXX nsIFileURL.idl specifies that the consumer must _not_ modify the diff --git a/netwerk/cache/nsCache.cpp b/netwerk/cache/nsCache.cpp index 9b05d2205af9..d8ee2f1ffe1c 100644 --- a/netwerk/cache/nsCache.cpp +++ b/netwerk/cache/nsCache.cpp @@ -14,6 +14,7 @@ * Cache Service Utility Functions */ +#if defined(PR_LOGGING) PRLogModuleInfo * gCacheLog = nullptr; @@ -38,6 +39,8 @@ CacheLogPrintPath(PRLogModuleLevel level, const char * format, nsIFile * item) } } +#endif + uint32_t SecondsFromPRTime(PRTime prTime) diff --git a/netwerk/cache/nsCache.h b/netwerk/cache/nsCache.h index 3744331b2630..1c733dd7f1aa 100644 --- a/netwerk/cache/nsCache.h +++ b/netwerk/cache/nsCache.h @@ -19,6 +19,7 @@ #include "nsError.h" // PR_LOG args = "format string", arg, arg, ... +#if defined(PR_LOGGING) extern PRLogModuleInfo * gCacheLog; void CacheLogInit(); void CacheLogPrintPath(PRLogModuleLevel level, @@ -31,6 +32,14 @@ void CacheLogPrintPath(PRLogModuleLevel level, #define CACHE_LOG_DEBUG(args) PR_LOG(gCacheLog, PR_LOG_DEBUG, args) #define CACHE_LOG_PATH(level, format, item) \ CacheLogPrintPath(level, format, item) +#else +#define CACHE_LOG_INIT() {} +#define CACHE_LOG_ALWAYS(args) {} +#define CACHE_LOG_ERROR(args) {} +#define CACHE_LOG_WARNING(args) {} +#define CACHE_LOG_DEBUG(args) {} +#define CACHE_LOG_PATH(level, format, item) {} +#endif extern uint32_t SecondsFromPRTime(PRTime prTime); diff --git a/netwerk/cache/nsCacheService.cpp b/netwerk/cache/nsCacheService.cpp index 54250a1df09f..0dabb15369ee 100644 --- a/netwerk/cache/nsCacheService.cpp +++ b/netwerk/cache/nsCacheService.cpp @@ -296,7 +296,9 @@ public: NS_IMETHOD Run() { nsCacheServiceAutoLock autoLock(LOCK_TELEM(NSBLOCKONCACHETHREADEVENT_RUN)); +#ifdef PR_LOGGING CACHE_LOG_DEBUG(("nsBlockOnCacheThreadEvent [%p]\n", this)); +#endif nsCacheService::gService->mCondVar.Notify(); return NS_OK; } @@ -1250,7 +1252,9 @@ nsCacheService::Shutdown() mCustomOfflineDevices.Enumerate(&nsCacheService::ShutdownCustomCacheDeviceEnum, nullptr); +#ifdef PR_LOGGING LogCacheStatistics(); +#endif mClearingEntries = false; mCacheIOThread.swap(cacheIOThread); @@ -1767,12 +1771,12 @@ nsCacheService::CreateCustomOfflineDevice(nsIFile *aProfileDir, { NS_ENSURE_ARG(aProfileDir); - if (PR_LOG_TEST(gCacheLog, PR_LOG_ALWAYS)) { - nsAutoCString profilePath; - aProfileDir->GetNativePath(profilePath); - CACHE_LOG_ALWAYS(("Creating custom offline device, %s, %d", - profilePath.BeginReading(), aQuota)); - } +#if defined(PR_LOGGING) + nsAutoCString profilePath; + aProfileDir->GetNativePath(profilePath); + CACHE_LOG_ALWAYS(("Creating custom offline device, %s, %d", + profilePath.BeginReading(), aQuota)); +#endif if (!mInitialized) return NS_ERROR_NOT_AVAILABLE; if (!mEnableOfflineDevice) return NS_ERROR_NOT_AVAILABLE; @@ -3113,6 +3117,7 @@ void nsCacheService::GetAppCacheDirectory(nsIFile ** result) } +#if defined(PR_LOGGING) void nsCacheService::LogCacheStatistics() { @@ -3132,6 +3137,7 @@ nsCacheService::LogCacheStatistics() CACHE_LOG_ALWAYS((" Deactivated Unbound Entries = %d\n", mDeactivatedUnboundEntries)); } +#endif nsresult nsCacheService::SetDiskSmartSize() diff --git a/netwerk/cache/nsCacheService.h b/netwerk/cache/nsCacheService.h index 81c9e312d312..e6234e35b859 100644 --- a/netwerk/cache/nsCacheService.h +++ b/netwerk/cache/nsCacheService.h @@ -325,7 +325,9 @@ private: PLDHashOperator ShutdownCustomCacheDeviceEnum(const nsAString& aProfileDir, nsRefPtr& aDevice, void* aUserArg); +#if defined(PR_LOGGING) void LogCacheStatistics(); +#endif nsresult SetDiskSmartSize_Locked(); diff --git a/netwerk/cache/nsDiskCacheDevice.cpp b/netwerk/cache/nsDiskCacheDevice.cpp index 04debdb8100e..771414107f9f 100644 --- a/netwerk/cache/nsDiskCacheDevice.cpp +++ b/netwerk/cache/nsDiskCacheDevice.cpp @@ -65,7 +65,9 @@ public: NS_IMETHOD Run() { nsCacheServiceAutoLock lock(LOCK_TELEM(NSDISKCACHEDEVICEDEACTIVATEENTRYEVENT_RUN)); +#ifdef PR_LOGGING CACHE_LOG_DEBUG(("nsDiskCacheDeviceDeactivateEntryEvent[%p]\n", this)); +#endif if (!mCanceled) { (void) mDevice->DeactivateEntry_Private(mEntry, mBinding); } diff --git a/netwerk/cache/nsDiskCacheDeviceSQL.cpp b/netwerk/cache/nsDiskCacheDeviceSQL.cpp index bef126fa2fe0..a2b9e16adf19 100644 --- a/netwerk/cache/nsDiskCacheDeviceSQL.cpp +++ b/netwerk/cache/nsDiskCacheDeviceSQL.cpp @@ -225,11 +225,11 @@ nsOfflineCacheEvictionFunction::Apply() LOG(("nsOfflineCacheEvictionFunction::Apply\n")); for (int32_t i = 0; i < mItems.Count(); i++) { - if (PR_LOG_TEST(gCacheLog, PR_LOG_DEBUG)) { - nsAutoCString path; - mItems[i]->GetNativePath(path); - LOG((" removing %s\n", path.get())); - } +#if defined(PR_LOGGING) + nsAutoCString path; + mItems[i]->GetNativePath(path); + LOG((" removing %s\n", path.get())); +#endif mItems[i]->Remove(false); } diff --git a/netwerk/cache2/CacheFile.cpp b/netwerk/cache2/CacheFile.cpp index 6f2e58d34cd9..afea2c18fb74 100644 --- a/netwerk/cache2/CacheFile.cpp +++ b/netwerk/cache2/CacheFile.cpp @@ -1877,7 +1877,10 @@ CacheFile::FailUpdateListeners( nsRefPtr& aChunk, void* aClosure) { +#ifdef PR_LOGGING CacheFile *file = static_cast(aClosure); +#endif + LOG(("CacheFile::FailUpdateListeners() [this=%p, idx=%u]", file, aIdx)); diff --git a/netwerk/cache2/CacheFileContextEvictor.cpp b/netwerk/cache2/CacheFileContextEvictor.cpp index ad04d4dbf826..c4980f07c14b 100644 --- a/netwerk/cache2/CacheFileContextEvictor.cpp +++ b/netwerk/cache2/CacheFileContextEvictor.cpp @@ -246,8 +246,10 @@ CacheFileContextEvictor::PersistEvictionInfoToDisk( return rv; } +#ifdef PR_LOGGING nsAutoCString path; file->GetNativePath(path); +#endif PRFileDesc *fd; rv = file->OpenNSPRFileDesc(PR_RDWR | PR_CREATE_FILE | PR_TRUNCATE, 0600, @@ -283,8 +285,10 @@ CacheFileContextEvictor::RemoveEvictInfoFromDisk( return rv; } +#ifdef PR_LOGGING nsAutoCString path; file->GetNativePath(path); +#endif rv = file->Remove(false); if (NS_WARN_IF(NS_FAILED(rv))) { diff --git a/netwerk/cache2/CacheFileIOManager.cpp b/netwerk/cache2/CacheFileIOManager.cpp index cfcf50a64025..eb764921fb44 100644 --- a/netwerk/cache2/CacheFileIOManager.cpp +++ b/netwerk/cache2/CacheFileIOManager.cpp @@ -2968,8 +2968,10 @@ CacheFileIOManager::CacheIndexStateChangedInternal() nsresult CacheFileIOManager::TrashDirectory(nsIFile *aFile) { +#ifdef PR_LOGGING nsAutoCString path; aFile->GetNativePath(path); +#endif LOG(("CacheFileIOManager::TrashDirectory() [file=%s]", path.get())); nsresult rv; @@ -3199,13 +3201,13 @@ CacheFileIOManager::RemoveTrashInternal() if (isDir) { NS_WARNING("Found a directory in a trash directory! It will be removed " "recursively, but this can block IO thread for a while!"); - if (LOG_ENABLED()) { - nsAutoCString path; - file->GetNativePath(path); - LOG(("CacheFileIOManager::RemoveTrashInternal() - Found a directory in a trash " - "directory! It will be removed recursively, but this can block IO " - "thread for a while! [file=%s]", path.get())); - } +#ifdef PR_LOGGING + nsAutoCString path; + file->GetNativePath(path); +#endif + LOG(("CacheFileIOManager::RemoveTrashInternal() - Found a directory in a trash " + "directory! It will be removed recursively, but this can block IO " + "thread for a while! [file=%s]", path.get())); } file->Remove(isDir); } @@ -3759,12 +3761,13 @@ CacheFileIOManager::SyncRemoveDir(nsIFile *aFile, const char *aDir) } } - if (LOG_ENABLED()) { - nsAutoCString path; - file->GetNativePath(path); - LOG(("CacheFileIOManager::SyncRemoveDir() - Removing directory %s", - path.get())); - } +#ifdef PR_LOGGING + nsAutoCString path; + file->GetNativePath(path); +#endif + + LOG(("CacheFileIOManager::SyncRemoveDir() - Removing directory %s", + path.get())); rv = file->Remove(true); if (NS_WARN_IF(NS_FAILED(rv))) { diff --git a/netwerk/cache2/CacheIndex.cpp b/netwerk/cache2/CacheIndex.cpp index cc8454072ff0..71ad1611b522 100644 --- a/netwerk/cache2/CacheIndex.cpp +++ b/netwerk/cache2/CacheIndex.cpp @@ -3082,6 +3082,7 @@ CacheIndex::RemoveNonFreshEntries(CacheIndexEntry *aEntry, void* aClosure) return PL_DHASH_REMOVE; } +#ifdef PR_LOGGING // static char const * CacheIndex::StateString(EState aState) @@ -3099,6 +3100,7 @@ CacheIndex::StateString(EState aState) MOZ_ASSERT(false, "Unexpected state!"); return "?"; } +#endif void CacheIndex::ChangeState(EState aNewState) diff --git a/netwerk/cache2/CacheIndex.h b/netwerk/cache2/CacheIndex.h index 4e6ac3d525de..5b9b3442818e 100644 --- a/netwerk/cache2/CacheIndex.h +++ b/netwerk/cache2/CacheIndex.h @@ -906,7 +906,9 @@ private: SHUTDOWN = 6 }; +#ifdef PR_LOGGING static char const * StateString(EState aState); +#endif void ChangeState(EState aNewState); // Allocates and releases buffer used for reading and writing index. diff --git a/netwerk/cache2/CacheLog.cpp b/netwerk/cache2/CacheLog.cpp index e7710b5af5b8..85741b48f8fa 100644 --- a/netwerk/cache2/CacheLog.cpp +++ b/netwerk/cache2/CacheLog.cpp @@ -7,6 +7,7 @@ namespace mozilla { namespace net { +#if defined(PR_LOGGING) // Log module for cache2 (2013) cache implementation logging... // // To enable logging (see prlog.h for full details): @@ -23,6 +24,7 @@ PRLogModuleInfo* GetCache2Log() sLog = PR_NewLogModule("cache2"); return sLog; } +#endif } // net } // mozilla diff --git a/netwerk/cache2/CacheLog.h b/netwerk/cache2/CacheLog.h index d11fc0d8fe7d..b6046b1ebab2 100644 --- a/netwerk/cache2/CacheLog.h +++ b/netwerk/cache2/CacheLog.h @@ -10,9 +10,12 @@ namespace mozilla { namespace net { +#if defined(PR_LOGGING) extern PRLogModuleInfo* GetCache2Log(); #define LOG(x) PR_LOG(GetCache2Log(), PR_LOG_DEBUG, x) -#define LOG_ENABLED() PR_LOG_TEST(GetCache2Log(), PR_LOG_DEBUG) +#else +#define LOG(x) +#endif /* PR_LOGGING */ } // net } // mozilla diff --git a/netwerk/cache2/CacheStorageService.cpp b/netwerk/cache2/CacheStorageService.cpp index 20682c9932b2..c80de37c11cf 100644 --- a/netwerk/cache2/CacheStorageService.cpp +++ b/netwerk/cache2/CacheStorageService.cpp @@ -1206,7 +1206,9 @@ CacheStorageService::PurgeOverMemoryLimit() void CacheStorageService::MemoryPool::PurgeOverMemoryLimit() { +#ifdef PR_LOGGING TimeStamp start(TimeStamp::Now()); +#endif uint32_t const memoryLimit = Limit(); if (mMemorySize > memoryLimit) { @@ -1442,12 +1444,12 @@ CacheStorageService::CheckStorageEntry(CacheStorage const* aStorage, AppendMemoryStorageID(contextKey); } - if (LOG_ENABLED()) { - nsAutoCString uriSpec; - aURI->GetAsciiSpec(uriSpec); - LOG(("CacheStorageService::CheckStorageEntry [uri=%s, eid=%s, contextKey=%s]", - uriSpec.get(), aIdExtension.BeginReading(), contextKey.get())); - } +#ifdef PR_LOGGING + nsAutoCString uriSpec; + aURI->GetAsciiSpec(uriSpec); + LOG(("CacheStorageService::CheckStorageEntry [uri=%s, eid=%s, contextKey=%s]", + uriSpec.get(), aIdExtension.BeginReading(), contextKey.get())); +#endif { mozilla::MutexAutoLock lock(mLock); diff --git a/netwerk/cookie/nsCookieService.cpp b/netwerk/cookie/nsCookieService.cpp index 42335055df92..e9aac403f9e6 100644 --- a/netwerk/cookie/nsCookieService.cpp +++ b/netwerk/cookie/nsCookieService.cpp @@ -190,6 +190,7 @@ struct nsListIter #define SET_COOKIE true #define GET_COOKIE false +#ifdef PR_LOGGING static PRLogModuleInfo * GetCookieLog() { @@ -321,6 +322,13 @@ LogSuccess(bool aSetCookie, nsIURI *aHostURI, const nsAFlatCString &aCookieStrin LogSuccess(aSetCookie, aHostURI, aCookieString.get(), aCookie, aReplacing); } +#else +#define COOKIE_LOGFAILURE(a, b, c, d) PR_BEGIN_MACRO /* nothing */ PR_END_MACRO +#define COOKIE_LOGSUCCESS(a, b, c, d, e) PR_BEGIN_MACRO /* nothing */ PR_END_MACRO +#define COOKIE_LOGEVICTED(a, b) PR_BEGIN_MACRO /* nothing */ PR_END_MACRO +#define COOKIE_LOGSTRING(a, b) PR_BEGIN_MACRO /* nothing */ PR_END_MACRO +#endif + #ifdef DEBUG #define NS_ASSERT_SUCCESS(res) \ PR_BEGIN_MACRO \ @@ -351,17 +359,17 @@ protected: public: NS_IMETHOD HandleError(mozIStorageError* aError) override { - if (PR_LOG_TEST(GetCookieLog(), PR_LOG_WARNING)) { - int32_t result = -1; - aError->GetResult(&result); + int32_t result = -1; + aError->GetResult(&result); - nsAutoCString message; - aError->GetMessage(message); - COOKIE_LOGSTRING(PR_LOG_WARNING, - ("DBListenerErrorHandler::HandleError(): Error %d occurred while " - "performing operation '%s' with message '%s'; rebuilding database.", - result, GetOpType(), message.get())); - } +#ifdef PR_LOGGING + nsAutoCString message; + aError->GetMessage(message); + COOKIE_LOGSTRING(PR_LOG_WARNING, + ("DBListenerErrorHandler::HandleError(): Error %d occurred while " + "performing operation '%s' with message '%s'; rebuilding database.", + result, GetOpType(), message.get())); +#endif // Rebuild the database. gCookieService->HandleCorruptDB(mDBState); @@ -3770,10 +3778,12 @@ nsCookieService::PurgeCookies(int64_t aCurrentTimeInUsec) NS_ASSERTION(mDBState->hostTable.Count() > 0, "table is empty"); EnsureReadComplete(); +#ifdef PR_LOGGING uint32_t initialCookieCount = mDBState->cookieCount; COOKIE_LOGSTRING(PR_LOG_DEBUG, ("PurgeCookies(): beginning purge with %ld cookies and %lld oldest age", mDBState->cookieCount, aCurrentTimeInUsec - mDBState->cookieOldestTime)); +#endif nsAutoTArray purgeList; @@ -3791,7 +3801,9 @@ nsCookieService::PurgeCookies(int64_t aCurrentTimeInUsec) aCurrentTimeInUsec - mCookiePurgeAge, purgeList, removedList, paramsArray); mDBState->hostTable.EnumerateEntries(purgeCookiesCallback, &data); +#ifdef PR_LOGGING uint32_t postExpiryCookieCount = mDBState->cookieCount; +#endif // now we have a list of iterators for cookies over the age limit. // sort them by age, and then we'll see how many to remove... diff --git a/netwerk/dns/GetAddrInfo.cpp b/netwerk/dns/GetAddrInfo.cpp index 1a3346758642..c17f9f54ab05 100644 --- a/netwerk/dns/GetAddrInfo.cpp +++ b/netwerk/dns/GetAddrInfo.cpp @@ -23,11 +23,16 @@ #endif #include "prlog.h" +#if defined(PR_LOGGING) static PRLogModuleInfo *gGetAddrInfoLog = PR_NewLogModule("GetAddrInfo"); #define LOG(msg, ...) \ PR_LOG(gGetAddrInfoLog, PR_LOG_DEBUG, ("[DNS]: " msg, ##__VA_ARGS__)) #define LOG_WARNING(msg, ...) \ PR_LOG(gGetAddrInfoLog, PR_LOG_WARNING, ("[DNS]: " msg, ##__VA_ARGS__)) +#else +#define LOG(args) +#define LOG_WARNING(args) +#endif #if DNSQUERY_AVAILABLE // There is a bug in windns.h where the type of parameter ppQueryResultsSet for diff --git a/netwerk/dns/nsHostResolver.cpp b/netwerk/dns/nsHostResolver.cpp index 6c85a415b250..54ebfdd94083 100644 --- a/netwerk/dns/nsHostResolver.cpp +++ b/netwerk/dns/nsHostResolver.cpp @@ -69,8 +69,12 @@ PR_STATIC_ASSERT (HighThreadThreshold <= MAX_RESOLVER_THREADS); //---------------------------------------------------------------------------- +#if defined(PR_LOGGING) static PRLogModuleInfo *gHostResolverLog = nullptr; #define LOG(args) PR_LOG(gHostResolverLog, PR_LOG_DEBUG, args) +#else +#define LOG(args) +#endif #define LOG_HOST(host, interface) host, \ (interface && interface[0] != '\0') ? " on interface " : "", \ @@ -439,7 +443,7 @@ HostDB_ClearEntry(PLDHashTable *table, LOG(("Clearing cache db entry for host [%s%s%s].\n", LOG_HOST(hr->host, hr->netInterface))); -#if defined(DEBUG) +#if defined(DEBUG) && defined(PR_LOGGING) { MutexAutoLock lock(hr->addr_info_lock); if (!hr->addr_info) { @@ -1048,10 +1052,12 @@ nsHostResolver::ConditionallyCreateThread(nsHostRecord *rec) return NS_ERROR_OUT_OF_MEMORY; } } +#if defined(PR_LOGGING) else { LOG((" Unable to find a thread for looking up host [%s%s%s].\n", LOG_HOST(rec->host, rec->netInterface))); } +#endif return NS_OK; } @@ -1491,8 +1497,10 @@ nsHostResolver::Create(uint32_t maxCacheEntries, uint32_t defaultGracePeriod, nsHostResolver **result) { +#if defined(PR_LOGGING) if (!gHostResolverLog) gHostResolverLog = PR_NewLogModule("nsHostResolver"); +#endif nsHostResolver *res = new nsHostResolver(maxCacheEntries, defaultCacheEntryLifetime, defaultGracePeriod); diff --git a/netwerk/protocol/ftp/nsFTPChannel.cpp b/netwerk/protocol/ftp/nsFTPChannel.cpp index 75e58dbf2805..984dc0d1a99e 100644 --- a/netwerk/protocol/ftp/nsFTPChannel.cpp +++ b/netwerk/protocol/ftp/nsFTPChannel.cpp @@ -10,7 +10,9 @@ #include "nsThreadUtils.h" #include "mozilla/Attributes.h" +#if defined(PR_LOGGING) extern PRLogModuleInfo* gFTPLog; +#endif /* PR_LOGGING */ // There are two transport connections established for an // ftp connection. One is used for the command channel , and diff --git a/netwerk/protocol/ftp/nsFtpConnectionThread.cpp b/netwerk/protocol/ftp/nsFtpConnectionThread.cpp index 95816280f949..5ec4cd8d20fa 100644 --- a/netwerk/protocol/ftp/nsFtpConnectionThread.cpp +++ b/netwerk/protocol/ftp/nsFtpConnectionThread.cpp @@ -45,7 +45,9 @@ #include "NetStatistics.h" #endif +#if defined(PR_LOGGING) extern PRLogModuleInfo* gFTPLog; +#endif #define LOG(args) PR_LOG(gFTPLog, PR_LOG_DEBUG, args) #define LOG_ALWAYS(args) PR_LOG(gFTPLog, PR_LOG_ALWAYS, args) diff --git a/netwerk/protocol/ftp/nsFtpControlConnection.cpp b/netwerk/protocol/ftp/nsFtpControlConnection.cpp index 43f6a4f19467..7f35df2a2375 100644 --- a/netwerk/protocol/ftp/nsFtpControlConnection.cpp +++ b/netwerk/protocol/ftp/nsFtpControlConnection.cpp @@ -15,7 +15,9 @@ #include "nsNetCID.h" #include +#if defined(PR_LOGGING) extern PRLogModuleInfo* gFTPLog; +#endif #define LOG(args) PR_LOG(gFTPLog, PR_LOG_DEBUG, args) #define LOG_ALWAYS(args) PR_LOG(gFTPLog, PR_LOG_ALWAYS, args) diff --git a/netwerk/protocol/ftp/nsFtpProtocolHandler.cpp b/netwerk/protocol/ftp/nsFtpProtocolHandler.cpp index ee13366aa910..f471be71fb5b 100644 --- a/netwerk/protocol/ftp/nsFtpProtocolHandler.cpp +++ b/netwerk/protocol/ftp/nsFtpProtocolHandler.cpp @@ -34,6 +34,7 @@ using namespace mozilla::net; //----------------------------------------------------------------------------- +#if defined(PR_LOGGING) // // Log module for FTP Protocol logging... // @@ -46,6 +47,7 @@ using namespace mozilla::net; // the file nspr.log // PRLogModuleInfo* gFTPLog = nullptr; +#endif #undef LOG #define LOG(args) PR_LOG(gFTPLog, PR_LOG_DEBUG, args) @@ -67,9 +69,10 @@ nsFtpProtocolHandler::nsFtpProtocolHandler() , mControlQoSBits(0x00) , mDataQoSBits(0x00) { +#if defined(PR_LOGGING) if (!gFTPLog) gFTPLog = PR_NewLogModule("nsFtp"); - +#endif LOG(("FTP:creating handler @%x\n", this)); gFtpHandler = this; diff --git a/netwerk/protocol/ftp/nsFtpProtocolHandler.h b/netwerk/protocol/ftp/nsFtpProtocolHandler.h index 6e00ae850b40..7972e1538f3a 100644 --- a/netwerk/protocol/ftp/nsFtpProtocolHandler.h +++ b/netwerk/protocol/ftp/nsFtpProtocolHandler.h @@ -82,6 +82,8 @@ private: extern nsFtpProtocolHandler *gFtpHandler; +#ifdef PR_LOGGING extern PRLogModuleInfo* gFTPLog; +#endif #endif // !nsFtpProtocolHandler_h__ diff --git a/netwerk/protocol/http/HttpBaseChannel.cpp b/netwerk/protocol/http/HttpBaseChannel.cpp index c46d1e7e7850..1c61d9ef0b6d 100644 --- a/netwerk/protocol/http/HttpBaseChannel.cpp +++ b/netwerk/protocol/http/HttpBaseChannel.cpp @@ -2356,17 +2356,16 @@ HttpBaseChannel::SetupReplacementChannel(nsIURI *newURI, // Transfer existing redirect information. Add all of our existing // redirects to the new channel. for (int32_t i = 0; i < mRedirects.Count(); ++i) { - if (LOG_ENABLED()) { - nsCOMPtr uri; - mRedirects[i]->GetURI(getter_AddRefs(uri)); - nsCString spec; - if (uri) { - uri->GetSpec(spec); - } - LOG(("HttpBaseChannel::SetupReplacementChannel adding redirect \'%s\' " - "[this=%p]", spec.get(), this)); +#ifdef PR_LOGGING + nsCOMPtr uri; + mRedirects[i]->GetURI(getter_AddRefs(uri)); + nsCString spec; + if (uri) { + uri->GetSpec(spec); } - + LOG(("HttpBaseChannel::SetupReplacementChannel adding redirect \'%s\' " + "[this=%p]", spec.get(), this)); +#endif httpInternal->AddRedirect(mRedirects[i]); } diff --git a/netwerk/protocol/http/HttpLog.h b/netwerk/protocol/http/HttpLog.h index cb5f17276885..e750f9dc4cbc 100644 --- a/netwerk/protocol/http/HttpLog.h +++ b/netwerk/protocol/http/HttpLog.h @@ -23,6 +23,7 @@ // Get rid of Chromium's LOG definition #undef LOG +#if defined(PR_LOGGING) // // Log module for HTTP Protocol logging... // @@ -35,6 +36,7 @@ // the file http.log // extern PRLogModuleInfo *gHttpLog; +#endif // http logging #define LOG1(args) PR_LOG(gHttpLog, 1, args) diff --git a/netwerk/protocol/http/nsHttp.cpp b/netwerk/protocol/http/nsHttp.cpp index b61630eac6ba..43f014ab0c62 100644 --- a/netwerk/protocol/http/nsHttp.cpp +++ b/netwerk/protocol/http/nsHttp.cpp @@ -13,7 +13,9 @@ #include "mozilla/HashFunctions.h" #include "nsCRT.h" +#if defined(PR_LOGGING) PRLogModuleInfo *gHttpLog = nullptr; +#endif namespace mozilla { namespace net { diff --git a/netwerk/protocol/http/nsHttpChannel.cpp b/netwerk/protocol/http/nsHttpChannel.cpp index 631829aacf44..e364fa20e1f5 100644 --- a/netwerk/protocol/http/nsHttpChannel.cpp +++ b/netwerk/protocol/http/nsHttpChannel.cpp @@ -6558,12 +6558,12 @@ nsHttpChannel::MaybeInvalidateCacheEntryForSubsequentGet() } // Invalidate the request-uri. - if (LOG_ENABLED()) { - nsAutoCString key; - mURI->GetAsciiSpec(key); - LOG(("MaybeInvalidateCacheEntryForSubsequentGet [this=%p uri=%s]\n", - this, key.get())); - } +#ifdef PR_LOGGING + nsAutoCString key; + mURI->GetAsciiSpec(key); + LOG(("MaybeInvalidateCacheEntryForSubsequentGet [this=%p uri=%s]\n", + this, key.get())); +#endif DoInvalidateCacheEntry(mURI); @@ -6606,12 +6606,11 @@ nsHttpChannel::DoInvalidateCacheEntry(nsIURI* aURI) nsresult rv; +#ifdef PR_LOGGING nsAutoCString key; - if (LOG_ENABLED()) { - aURI->GetAsciiSpec(key); - } - + aURI->GetAsciiSpec(key); LOG(("DoInvalidateCacheEntry [channel=%p key=%s]", this, key.get())); +#endif nsCOMPtr cacheStorageService = do_GetService("@mozilla.org/netwerk/cache-storage-service;1", &rv); diff --git a/netwerk/protocol/http/nsHttpHandler.cpp b/netwerk/protocol/http/nsHttpHandler.cpp index 37a0e562c85c..8943c2306fd8 100644 --- a/netwerk/protocol/http/nsHttpHandler.cpp +++ b/netwerk/protocol/http/nsHttpHandler.cpp @@ -214,7 +214,9 @@ nsHttpHandler::nsHttpHandler() , mTCPKeepaliveLongLivedIdleTimeS(600) , mEnforceH1Framing(FRAMECHECK_BARELY) { +#if defined(PR_LOGGING) gHttpLog = PR_NewLogModule("nsHttp"); +#endif LOG(("Creating nsHttpHandler [this=%p].\n", this)); diff --git a/netwerk/protocol/http/nsHttpNTLMAuth.cpp b/netwerk/protocol/http/nsHttpNTLMAuth.cpp index 4b5a703dfe44..2e26d870f0fd 100644 --- a/netwerk/protocol/http/nsHttpNTLMAuth.cpp +++ b/netwerk/protocol/http/nsHttpNTLMAuth.cpp @@ -274,8 +274,10 @@ nsHttpNTLMAuth::ChallengeReceived(nsIHttpAuthenticableChannel *channel, *identityInvalid = true; } #endif // XP_WIN +#ifdef PR_LOGGING if (!module) LOG(("Native sys-ntlm auth module not found.\n")); +#endif } #ifdef XP_WIN diff --git a/netwerk/protocol/http/nsHttpTransaction.cpp b/netwerk/protocol/http/nsHttpTransaction.cpp index 0321ded49ff9..8721608662b8 100644 --- a/netwerk/protocol/http/nsHttpTransaction.cpp +++ b/netwerk/protocol/http/nsHttpTransaction.cpp @@ -63,6 +63,7 @@ namespace net { // helpers //----------------------------------------------------------------------------- +#if defined(PR_LOGGING) static void LogHeaders(const char *lineStart) { @@ -80,6 +81,7 @@ LogHeaders(const char *lineStart) lineStart = endOfLine + 2; } } +#endif //----------------------------------------------------------------------------- // nsHttpTransaction @@ -318,11 +320,13 @@ nsHttpTransaction::Init(uint32_t caps, mReqHeaderBuf.Truncate(); requestHead->Flatten(mReqHeaderBuf, pruneProxyHeaders); +#if defined(PR_LOGGING) if (LOG3_ENABLED()) { LOG3(("http request [\n")); LogHeaders(mReqHeaderBuf.get()); LOG3(("]\n")); } +#endif // If the request body does not include headers or if there is no request // body, then we must add the header/body separator manually. @@ -1470,6 +1474,7 @@ nsHttpTransaction::HandleContentStart() MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread); if (mResponseHead) { +#if defined(PR_LOGGING) if (LOG3_ENABLED()) { LOG3(("http response [\n")); nsAutoCString headers; @@ -1477,7 +1482,7 @@ nsHttpTransaction::HandleContentStart() LogHeaders(headers.get()); LOG3(("]\n")); } - +#endif // Save http version, mResponseHead isn't available anymore after // TakeResponseHead() is called mHttpVersion = mResponseHead->Version(); @@ -1556,8 +1561,10 @@ nsHttpTransaction::HandleContentStart() // Ignore server specified Content-Length. mContentLength = -1; } +#if defined(PR_LOGGING) else if (mContentLength == int64_t(-1)) LOG(("waiting for the server to close the connection.\n")); +#endif } if (mRestartInProgressVerifier.IsSetup() && !mRestartInProgressVerifier.Verify(mContentLength, mResponseHead)) { diff --git a/netwerk/protocol/res/nsResProtocolHandler.cpp b/netwerk/protocol/res/nsResProtocolHandler.cpp index 231366eb136a..ec1bddca224f 100644 --- a/netwerk/protocol/res/nsResProtocolHandler.cpp +++ b/netwerk/protocol/res/nsResProtocolHandler.cpp @@ -23,6 +23,7 @@ static NS_DEFINE_CID(kResURLCID, NS_RESURL_CID); static nsResProtocolHandler *gResHandler = nullptr; +#if defined(PR_LOGGING) // // Log module for Resource Protocol logging... // @@ -35,6 +36,7 @@ static nsResProtocolHandler *gResHandler = nullptr; // the file log.txt // static PRLogModuleInfo *gResLog; +#endif #define kAPP NS_LITERAL_CSTRING("app") #define kGRE NS_LITERAL_CSTRING("gre") @@ -102,7 +104,9 @@ nsResURL::GetClassIDNoAlloc(nsCID *aClassIDNoAlloc) nsResProtocolHandler::nsResProtocolHandler() : mSubstitutions(16) { +#if defined(PR_LOGGING) gResLog = PR_NewLogModule("nsResProtocol"); +#endif NS_ASSERTION(!gResHandler, "res handler already created!"); gResHandler = this; @@ -447,11 +451,13 @@ nsResProtocolHandler::ResolveURI(nsIURI *uri, nsACString &result) rv = baseURI->Resolve(nsDependentCString(p, path.Length()-1), result); +#if defined(PR_LOGGING) if (PR_LOG_TEST(gResLog, PR_LOG_DEBUG)) { nsAutoCString spec; uri->GetAsciiSpec(spec); PR_LOG(gResLog, PR_LOG_DEBUG, ("%s\n -> %s\n", spec.get(), PromiseFlatCString(result).get())); } +#endif return rv; } diff --git a/netwerk/protocol/rtsp/controller/RtspControllerChild.cpp b/netwerk/protocol/rtsp/controller/RtspControllerChild.cpp index f0ee73897c56..22db46251465 100644 --- a/netwerk/protocol/rtsp/controller/RtspControllerChild.cpp +++ b/netwerk/protocol/rtsp/controller/RtspControllerChild.cpp @@ -70,8 +70,10 @@ RtspControllerChild::RtspControllerChild(nsIChannel *channel) , mPlayTimer(nullptr) , mPauseTimer(nullptr) { +#if defined(PR_LOGGING) if (!gRtspChildLog) gRtspChildLog = PR_NewLogModule("nsRtspChild"); +#endif AddIPDLReference(); gNeckoChild->SendPRtspControllerConstructor(this); } diff --git a/netwerk/protocol/rtsp/controller/RtspControllerParent.cpp b/netwerk/protocol/rtsp/controller/RtspControllerParent.cpp index 22eacc279e09..0c8d7ed58694 100644 --- a/netwerk/protocol/rtsp/controller/RtspControllerParent.cpp +++ b/netwerk/protocol/rtsp/controller/RtspControllerParent.cpp @@ -62,8 +62,10 @@ RtspControllerParent::RtspControllerParent() : mIPCOpen(true) , mTotalTracks(0) { +#if defined(PR_LOGGING) if (!gRtspLog) gRtspLog = PR_NewLogModule("nsRtsp"); +#endif } RtspControllerParent::~RtspControllerParent() diff --git a/netwerk/protocol/websocket/BaseWebSocketChannel.cpp b/netwerk/protocol/websocket/BaseWebSocketChannel.cpp index 010f45eae522..9880d80a0a43 100644 --- a/netwerk/protocol/websocket/BaseWebSocketChannel.cpp +++ b/netwerk/protocol/websocket/BaseWebSocketChannel.cpp @@ -13,7 +13,9 @@ #include "nsProxyRelease.h" #include "nsStandardURL.h" +#if defined(PR_LOGGING) PRLogModuleInfo *webSocketLog = nullptr; +#endif namespace mozilla { namespace net { @@ -27,8 +29,10 @@ BaseWebSocketChannel::BaseWebSocketChannel() , mPingInterval(0) , mPingResponseTimeout(10000) { +#if defined(PR_LOGGING) if (!webSocketLog) webSocketLog = PR_NewLogModule("nsWebSocket"); +#endif } //----------------------------------------------------------------------------- diff --git a/netwerk/protocol/websocket/WebSocketChannelParent.cpp b/netwerk/protocol/websocket/WebSocketChannelParent.cpp index dbbb944f4677..2c92b8221478 100644 --- a/netwerk/protocol/websocket/WebSocketChannelParent.cpp +++ b/netwerk/protocol/websocket/WebSocketChannelParent.cpp @@ -33,8 +33,10 @@ WebSocketChannelParent::WebSocketChannelParent(nsIAuthPromptProvider* aAuthProvi { // Websocket channels can't have a private browsing override MOZ_ASSERT_IF(!aLoadContext, aOverrideStatus == kPBOverride_Unset); +#if defined(PR_LOGGING) if (!webSocketLog) webSocketLog = PR_NewLogModule("nsWebSocket"); +#endif mObserver = new OfflineObserver(this); } diff --git a/netwerk/protocol/websocket/WebSocketLog.h b/netwerk/protocol/websocket/WebSocketLog.h index 6e5008be113d..b0730acba130 100644 --- a/netwerk/protocol/websocket/WebSocketLog.h +++ b/netwerk/protocol/websocket/WebSocketLog.h @@ -11,7 +11,9 @@ #include "prlog.h" #include "mozilla/net/NeckoChild.h" +#ifdef PR_LOGGING extern PRLogModuleInfo* webSocketLog; +#endif #undef LOG #define LOG(args) PR_LOG(webSocketLog, PR_LOG_DEBUG, args) diff --git a/netwerk/protocol/wyciwyg/WyciwygChannelParent.cpp b/netwerk/protocol/wyciwyg/WyciwygChannelParent.cpp index 023f4396af17..9f0b4f6bc2eb 100644 --- a/netwerk/protocol/wyciwyg/WyciwygChannelParent.cpp +++ b/netwerk/protocol/wyciwyg/WyciwygChannelParent.cpp @@ -25,8 +25,10 @@ WyciwygChannelParent::WyciwygChannelParent() : mIPCClosed(false) , mReceivedAppData(false) { +#if defined(PR_LOGGING) if (!gWyciwygLog) gWyciwygLog = PR_NewLogModule("nsWyciwygChannel"); +#endif } WyciwygChannelParent::~WyciwygChannelParent() diff --git a/netwerk/protocol/wyciwyg/nsWyciwyg.cpp b/netwerk/protocol/wyciwyg/nsWyciwyg.cpp index bc3179e11697..32449fdc50a1 100644 --- a/netwerk/protocol/wyciwyg/nsWyciwyg.cpp +++ b/netwerk/protocol/wyciwyg/nsWyciwyg.cpp @@ -5,5 +5,7 @@ #include "nsWyciwyg.h" #include "nscore.h" +#if defined(PR_LOGGING) PRLogModuleInfo *gWyciwygLog = nullptr; +#endif diff --git a/netwerk/protocol/wyciwyg/nsWyciwyg.h b/netwerk/protocol/wyciwyg/nsWyciwyg.h index a2849df0ffa1..60b3b4509151 100644 --- a/netwerk/protocol/wyciwyg/nsWyciwyg.h +++ b/netwerk/protocol/wyciwyg/nsWyciwyg.h @@ -12,6 +12,7 @@ #include "prlog.h" +#if defined(PR_LOGGING) // // Log module for HTTP Protocol logging... // @@ -24,6 +25,7 @@ // the file wyciwyg.log // extern PRLogModuleInfo *gWyciwygLog; +#endif // http logging #define LOG1(args) PR_LOG(gWyciwygLog, 1, args) diff --git a/netwerk/protocol/wyciwyg/nsWyciwygProtocolHandler.cpp b/netwerk/protocol/wyciwyg/nsWyciwygProtocolHandler.cpp index 7aaa89575cf8..8e0fc769fa0b 100644 --- a/netwerk/protocol/wyciwyg/nsWyciwygProtocolHandler.cpp +++ b/netwerk/protocol/wyciwyg/nsWyciwygProtocolHandler.cpp @@ -23,8 +23,10 @@ using namespace mozilla::net; nsWyciwygProtocolHandler::nsWyciwygProtocolHandler() { +#if defined(PR_LOGGING) if (!gWyciwygLog) gWyciwygLog = PR_NewLogModule("nsWyciwygChannel"); +#endif LOG(("Creating nsWyciwygProtocolHandler [this=%p].\n", this)); } diff --git a/netwerk/sctp/datachannel/DataChannel.cpp b/netwerk/sctp/datachannel/DataChannel.cpp index e1e4f5f4113d..0e8b9ea114a9 100644 --- a/netwerk/sctp/datachannel/DataChannel.cpp +++ b/netwerk/sctp/datachannel/DataChannel.cpp @@ -50,6 +50,7 @@ #include "DataChannel.h" #include "DataChannelProtocol.h" +#ifdef PR_LOGGING PRLogModuleInfo* GetDataChannelLog() { @@ -67,6 +68,7 @@ GetSCTPLog() sLog = PR_NewLogModule("SCTP"); return sLog; } +#endif // Let us turn on and off important assertions in non-debug builds #ifdef DEBUG @@ -172,6 +174,7 @@ receive_cb(struct socket* sock, union sctp_sockstore addr, return connection->ReceiveCallback(sock, data, datalen, rcv, flags); } +#ifdef PR_LOGGING static void debug_printf(const char *format, ...) { @@ -190,6 +193,7 @@ debug_printf(const char *format, ...) va_end(ap); } } +#endif DataChannelConnection::DataChannelConnection(DataConnectionListener *listener) : mLock("netwerk::sctp::DataChannelConnection") @@ -321,7 +325,11 @@ DataChannelConnection::Init(unsigned short aPort, uint16_t aNumStreams, bool aUs #ifdef MOZ_PEERCONNECTION usrsctp_init(0, DataChannelConnection::SctpDtlsOutput, +#ifdef PR_LOGGING debug_printf +#else + nullptr +#endif ); #else NS_ASSERTION(!aUsingDtls, "Trying to use SCTP/DTLS without mtransport"); @@ -330,15 +338,20 @@ DataChannelConnection::Init(unsigned short aPort, uint16_t aNumStreams, bool aUs LOG(("sctp_init(%u)", aPort)); usrsctp_init(aPort, nullptr, +#ifdef PR_LOGGING debug_printf +#else + nullptr +#endif ); } +#ifdef PR_LOGGING // Set logging to SCTP:PR_LOG_DEBUG to get SCTP debugs if (PR_LOG_TEST(GetSCTPLog(), PR_LOG_ALWAYS)) { usrsctp_sysctl_set_sctp_debug_on(SCTP_DEBUG_ALL); } - +#endif usrsctp_sysctl_set_sctp_blackhole(2); // ECN is currently not supported by the Firefox code usrsctp_sysctl_set_sctp_ecn_enable(0); @@ -653,6 +666,7 @@ void DataChannelConnection::SctpDtlsInput(TransportFlow *flow, const unsigned char *data, size_t len) { +#ifdef PR_LOGGING if (PR_LOG_TEST(GetSCTPLog(), PR_LOG_DEBUG)) { char *buf; @@ -661,6 +675,7 @@ DataChannelConnection::SctpDtlsInput(TransportFlow *flow, usrsctp_freedumpbuffer(buf); } } +#endif // Pass the data to SCTP usrsctp_conninput(static_cast(this), data, len, 0); } @@ -683,6 +698,7 @@ DataChannelConnection::SctpDtlsOutput(void *addr, void *buffer, size_t length, DataChannelConnection *peer = static_cast(addr); int res; +#ifdef PR_LOGGING if (PR_LOG_TEST(GetSCTPLog(), PR_LOG_DEBUG)) { char *buf; @@ -691,6 +707,7 @@ DataChannelConnection::SctpDtlsOutput(void *addr, void *buffer, size_t length, usrsctp_freedumpbuffer(buf); } } +#endif // We're async proxying even if on the STSThread because this is called // with internal SCTP locks held in some cases (such as in usrsctp_connect()). // SCTP has an option for Apple, on IP connections only, to release at least diff --git a/netwerk/sctp/datachannel/DataChannelLog.h b/netwerk/sctp/datachannel/DataChannelLog.h index 1fb1b3861747..447a948b24d4 100644 --- a/netwerk/sctp/datachannel/DataChannelLog.h +++ b/netwerk/sctp/datachannel/DataChannelLog.h @@ -10,8 +10,10 @@ #include "base/basictypes.h" #include "prlog.h" +#ifdef PR_LOGGING extern PRLogModuleInfo* GetDataChannelLog(); extern PRLogModuleInfo* GetSCTPLog(); +#endif #undef LOG #define LOG(args) PR_LOG(GetDataChannelLog(), PR_LOG_DEBUG, args) diff --git a/netwerk/socket/nsSOCKSIOLayer.cpp b/netwerk/socket/nsSOCKSIOLayer.cpp index 2b9e25b16173..d07df13ecf27 100644 --- a/netwerk/socket/nsSOCKSIOLayer.cpp +++ b/netwerk/socket/nsSOCKSIOLayer.cpp @@ -28,10 +28,16 @@ static PRIOMethods nsSOCKSIOLayerMethods; static bool firstTime = true; static bool ipv6Supported = true; +#if defined(PR_LOGGING) static PRLogModuleInfo *gSOCKSLog; #define LOGDEBUG(args) PR_LOG(gSOCKSLog, PR_LOG_DEBUG, args) #define LOGERROR(args) PR_LOG(gSOCKSLog, PR_LOG_ERROR , args) +#else +#define LOGDEBUG(args) +#define LOGERROR(args) +#endif + class nsSOCKSSocketInfo : public nsISOCKSSocketInfo , public nsIDNSListener { @@ -423,13 +429,12 @@ nsSOCKSSocketInfo::ConnectToProxy(PRFileDesc *fd) return PR_FAILURE; } - if (PR_LOG_TEST(gSOCKSLog, PR_LOG_DEBUG)) { - char buf[kIPv6CStrBufSize]; - NetAddrToString(&mInternalProxyAddr, buf, sizeof(buf)); - LOGDEBUG(("socks: trying proxy server, %s:%hu", - buf, ntohs(mInternalProxyAddr.inet.port))); - } - +#if defined(PR_LOGGING) + char buf[kIPv6CStrBufSize]; + NetAddrToString(&mInternalProxyAddr, buf, sizeof(buf)); + LOGDEBUG(("socks: trying proxy server, %s:%hu", + buf, ntohs(mInternalProxyAddr.inet.port))); +#endif NetAddr proxy = mInternalProxyAddr; FixupAddressFamily(fd, &proxy); PRNetAddr prProxy; @@ -1306,7 +1311,10 @@ nsSOCKSIOLayerAddToSocket(int32_t family, firstTime = false; +#if defined(PR_LOGGING) gSOCKSLog = PR_NewLogModule("SOCKS"); +#endif + } LOGDEBUG(("Entering nsSOCKSIOLayerAddToSocket().")); diff --git a/netwerk/streamconv/converters/nsFTPDirListingConv.cpp b/netwerk/streamconv/converters/nsFTPDirListingConv.cpp index 2aa0dae50a69..9c4df3b9e89c 100644 --- a/netwerk/streamconv/converters/nsFTPDirListingConv.cpp +++ b/netwerk/streamconv/converters/nsFTPDirListingConv.cpp @@ -19,6 +19,7 @@ #include "ParseFTPList.h" #include +#if defined(PR_LOGGING) // // Log module for FTP dir listing stream converter logging... // @@ -32,6 +33,7 @@ // PRLogModuleInfo* gFTPDirListConvLog = nullptr; +#endif /* PR_LOGGING */ // nsISupports implementation NS_IMPL_ISUPPORTS(nsFTPDirListingConv, @@ -191,6 +193,7 @@ nsFTPDirListingConv::~nsFTPDirListingConv() { nsresult nsFTPDirListingConv::Init() { +#if defined(PR_LOGGING) // // Initialize the global PRLogModule for FTP Protocol logging // if necessary... @@ -198,6 +201,7 @@ nsFTPDirListingConv::Init() { if (nullptr == gFTPDirListConvLog) { gFTPDirListConvLog = PR_NewLogModule("nsFTPDirListingConv"); } +#endif /* PR_LOGGING */ return NS_OK; } diff --git a/netwerk/system/linux/nsNotifyAddrListener_Linux.cpp b/netwerk/system/linux/nsNotifyAddrListener_Linux.cpp index 00adcb773f7c..912327f526d2 100644 --- a/netwerk/system/linux/nsNotifyAddrListener_Linux.cpp +++ b/netwerk/system/linux/nsNotifyAddrListener_Linux.cpp @@ -38,8 +38,12 @@ using namespace mozilla; +#if defined(PR_LOGGING) static PRLogModuleInfo *gNotifyAddrLog = nullptr; #define LOG(args) PR_LOG(gNotifyAddrLog, PR_LOG_DEBUG, args) +#else +#define LOG(args) +#endif #define NETWORK_NOTIFY_CHANGED_PREF "network.notify.changed" @@ -299,8 +303,10 @@ class NuwaMarkLinkMonitorThreadRunner : public nsRunnable nsresult nsNotifyAddrListener::Init(void) { +#if defined(PR_LOGGING) if (!gNotifyAddrLog) gNotifyAddrLog = PR_NewLogModule("nsNotifyAddr"); +#endif nsCOMPtr observerService = mozilla::services::GetObserverService(); diff --git a/netwerk/system/win32/nsNotifyAddrListener.cpp b/netwerk/system/win32/nsNotifyAddrListener.cpp index 8c09b00f52ed..4f8c7f525319 100644 --- a/netwerk/system/win32/nsNotifyAddrListener.cpp +++ b/netwerk/system/win32/nsNotifyAddrListener.cpp @@ -34,8 +34,12 @@ using namespace mozilla; +#if defined(PR_LOGGING) static PRLogModuleInfo *gNotifyAddrLog = nullptr; #define LOG(args) PR_LOG(gNotifyAddrLog, PR_LOG_DEBUG, args) +#else +#define LOG(args) +#endif static HMODULE sNetshell; static decltype(NcFreeNetconProperties)* sNcFreeNetconProperties; @@ -215,8 +219,10 @@ nsNotifyAddrListener::Observe(nsISupports *subject, nsresult nsNotifyAddrListener::Init(void) { +#if defined(PR_LOGGING) if (!gNotifyAddrLog) gNotifyAddrLog = PR_NewLogModule("nsNotifyAddr"); +#endif nsCOMPtr observerService = mozilla::services::GetObserverService(); diff --git a/netwerk/test/TestBlockingSocket.cpp b/netwerk/test/TestBlockingSocket.cpp index 2830dbc903b2..e4812faf61f0 100644 --- a/netwerk/test/TestBlockingSocket.cpp +++ b/netwerk/test/TestBlockingSocket.cpp @@ -19,10 +19,12 @@ //////////////////////////////////////////////////////////////////////////////// +#if defined(PR_LOGGING) // // set NSPR_LOG_MODULES=Test:5 // static PRLogModuleInfo *gTestLog = nullptr; +#endif #define LOG(args) PR_LOG(gTestLog, PR_LOG_DEBUG, args) //////////////////////////////////////////////////////////////////////////////// @@ -102,15 +104,19 @@ main(int argc, char* argv[]) nsCOMPtr servMan; NS_InitXPCOM2(getter_AddRefs(servMan), nullptr, nullptr); +#if defined(PR_LOGGING) gTestLog = PR_NewLogModule("Test"); +#endif nsCOMPtr file; rv = NS_NewNativeLocalFile(nsDependentCString(fileName), false, getter_AddRefs(file)); if (NS_FAILED(rv)) return -1; rv = RunBlockingTest(nsDependentCString(hostName), port, file); +#if defined(PR_LOGGING) if (NS_FAILED(rv)) LOG(("RunBlockingTest failed [rv=%x]\n", rv)); +#endif // give background threads a chance to finish whatever work they may // be doing. diff --git a/netwerk/test/TestIOThreads.cpp b/netwerk/test/TestIOThreads.cpp index 20daefe8ff9a..f2ca8aeb6934 100644 --- a/netwerk/test/TestIOThreads.cpp +++ b/netwerk/test/TestIOThreads.cpp @@ -11,10 +11,12 @@ #include "nsNetCID.h" #include "prlog.h" +#if defined(PR_LOGGING) // // set NSPR_LOG_MODULES=Test:5 // static PRLogModuleInfo *gTestLog = nullptr; +#endif #define LOG(args) PR_LOG(gTestLog, PR_LOG_DEBUG, args) class nsIOEvent : public nsIRunnable { @@ -57,7 +59,9 @@ int main(int argc, char **argv) nsresult rv; +#if defined(PR_LOGGING) gTestLog = PR_NewLogModule("Test"); +#endif rv = NS_InitXPCOM2(nullptr, nullptr, nullptr); if (NS_FAILED(rv)) diff --git a/netwerk/test/TestOverlappedIO.cpp b/netwerk/test/TestOverlappedIO.cpp index a09897dcb230..98012c962596 100644 --- a/netwerk/test/TestOverlappedIO.cpp +++ b/netwerk/test/TestOverlappedIO.cpp @@ -26,8 +26,12 @@ #include "nsCOMPtr.h" #include "nsIByteArrayInputStream.h" +#if defined(PR_LOGGING) static PRLogModuleInfo *gTestSocketIOLog; #define LOG(args) PR_LOG(gTestSocketIOLog, PR_LOG_DEBUG, args) +#else +#define LOG(args) +#endif static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID); static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID); @@ -229,7 +233,9 @@ main(int argc, char* argv[]) signal(SIGSEGV, sighandler); +#if defined(PR_LOGGING) gTestSocketIOLog = PR_NewLogModule("TestSocketIO"); +#endif if (argc < 3) usage(argv); diff --git a/netwerk/test/TestProtocols.cpp b/netwerk/test/TestProtocols.cpp index ecce8a20c6d9..92222ed9805d 100644 --- a/netwerk/test/TestProtocols.cpp +++ b/netwerk/test/TestProtocols.cpp @@ -61,10 +61,12 @@ using namespace mozilla; namespace TestProtocols { +#if defined(PR_LOGGING) // // set NSPR_LOG_MODULES=Test:5 // static PRLogModuleInfo *gTestLog = nullptr; +#endif #define LOG(args) PR_LOG(gTestLog, PR_LOG_DEBUG, args) static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); @@ -833,7 +835,9 @@ main(int argc, char* argv[]) return -1; } +#if defined(PR_LOGGING) gTestLog = PR_NewLogModule("Test"); +#endif /* The following code only deals with XPCOM registration stuff. and setting diff --git a/netwerk/test/TestServ.cpp b/netwerk/test/TestServ.cpp index aed92f26c3a9..2a8e705051f4 100644 --- a/netwerk/test/TestServ.cpp +++ b/netwerk/test/TestServ.cpp @@ -13,10 +13,12 @@ #include "nsCOMPtr.h" #include "prlog.h" +#if defined(PR_LOGGING) // // set NSPR_LOG_MODULES=Test:5 // static PRLogModuleInfo *gTestLog = nullptr; +#endif #define LOG(args) PR_LOG(gTestLog, PR_LOG_DEBUG, args) class MySocketListener : public nsIServerSocketListener @@ -117,7 +119,9 @@ main(int argc, char* argv[]) return -1; } +#if defined(PR_LOGGING) gTestLog = PR_NewLogModule("Test"); +#endif /* * The following code only deals with XPCOM registration stuff. and setting diff --git a/netwerk/test/TestSocketIO.cpp b/netwerk/test/TestSocketIO.cpp index 61d2f7b423f8..bbeb2d055995 100644 --- a/netwerk/test/TestSocketIO.cpp +++ b/netwerk/test/TestSocketIO.cpp @@ -25,8 +25,12 @@ #include "nsCOMPtr.h" #include "nsIByteArrayInputStream.h" +#if defined(PR_LOGGING) static PRLogModuleInfo *gTestSocketIOLog; #define LOG(args) PR_LOG(gTestSocketIOLog, PR_LOG_DEBUG, args) +#else +#define LOG(args) +#endif static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID); static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID); @@ -223,7 +227,9 @@ main(int argc, char* argv[]) signal(SIGSEGV, sighandler); +#if defined(PR_LOGGING) gTestSocketIOLog = PR_NewLogModule("TestSocketIO"); +#endif if (argc < 3) usage(argv); diff --git a/netwerk/test/TestSocketTransport.cpp b/netwerk/test/TestSocketTransport.cpp index d657aba50739..907e14964f32 100644 --- a/netwerk/test/TestSocketTransport.cpp +++ b/netwerk/test/TestSocketTransport.cpp @@ -27,10 +27,12 @@ //////////////////////////////////////////////////////////////////////////////// +#if defined(PR_LOGGING) // // set NSPR_LOG_MODULES=Test:5 // static PRLogModuleInfo *gTestLog = nullptr; +#endif #define LOG(args) PR_LOG(gTestLog, PR_LOG_DEBUG, args) //////////////////////////////////////////////////////////////////////////////// @@ -221,7 +223,9 @@ main(int argc, char* argv[]) if (registrar) registrar->AutoRegister(nullptr); +#if defined(PR_LOGGING) gTestLog = PR_NewLogModule("Test"); +#endif // Make sure the DNS service is initialized on the main thread nsCOMPtr dns = diff --git a/netwerk/test/TestStreamChannel.cpp b/netwerk/test/TestStreamChannel.cpp index 8452f8eb7924..1636f7b0d9ca 100644 --- a/netwerk/test/TestStreamChannel.cpp +++ b/netwerk/test/TestStreamChannel.cpp @@ -25,11 +25,15 @@ //////////////////////////////////////////////////////////////////////////////// +#if defined(PR_LOGGING) // // set NSPR_LOG_MODULES=Test:5 // static PRLogModuleInfo *gTestLog = nullptr; #define LOG(args) PR_LOG(gTestLog, PR_LOG_DEBUG, args) +#else +#define LOG(args) +#endif //////////////////////////////////////////////////////////////////////////////// @@ -180,7 +184,9 @@ main(int argc, char* argv[]) if (registrar) registrar->AutoRegister(nullptr); +#if defined(PR_LOGGING) gTestLog = PR_NewLogModule("Test"); +#endif nsCOMPtr file; rv = NS_NewNativeLocalFile(nsDependentCString(fileName), false, getter_AddRefs(file)); diff --git a/netwerk/test/TestStreamLoader.cpp b/netwerk/test/TestStreamLoader.cpp index e43bf94bc550..42d18172d378 100644 --- a/netwerk/test/TestStreamLoader.cpp +++ b/netwerk/test/TestStreamLoader.cpp @@ -6,10 +6,12 @@ #include "mozilla/Attributes.h" #include "nsIScriptSecurityManager.h" +#if defined(PR_LOGGING) // // set NSPR_LOG_MODULES=Test:5 // static PRLogModuleInfo *gTestLog = nullptr; +#endif #define LOG(args) PR_LOG(gTestLog, PR_LOG_DEBUG, args) class MyStreamLoaderObserver final : public nsIStreamLoaderObserver @@ -50,7 +52,9 @@ int main(int argc, char **argv) return -1; } +#if defined(PR_LOGGING) gTestLog = PR_NewLogModule("Test"); +#endif nsresult rv = NS_InitXPCOM2(nullptr, nullptr, nullptr); if (NS_FAILED(rv)) diff --git a/netwerk/test/TestStreamPump.cpp b/netwerk/test/TestStreamPump.cpp index 6a006e48e278..ffbfa74e6e0d 100644 --- a/netwerk/test/TestStreamPump.cpp +++ b/netwerk/test/TestStreamPump.cpp @@ -27,11 +27,15 @@ //////////////////////////////////////////////////////////////////////////////// +#if defined(PR_LOGGING) // // set NSPR_LOG_MODULES=Test:5 // static PRLogModuleInfo *gTestLog = nullptr; #define LOG(args) PR_LOG(gTestLog, PR_LOG_DEBUG, args) +#else +#define LOG(args) +#endif //////////////////////////////////////////////////////////////////////////////// @@ -151,7 +155,9 @@ main(int argc, char* argv[]) if (registrar) registrar->AutoRegister(nullptr); +#if defined(PR_LOGGING) gTestLog = PR_NewLogModule("Test"); +#endif nsCOMPtr file; rv = NS_NewNativeLocalFile(nsDependentCString(fileName), false, getter_AddRefs(file)); diff --git a/netwerk/test/TestStreamTransport.cpp b/netwerk/test/TestStreamTransport.cpp index c8e12e4dd03a..9fbcc109b312 100644 --- a/netwerk/test/TestStreamTransport.cpp +++ b/netwerk/test/TestStreamTransport.cpp @@ -25,10 +25,12 @@ //////////////////////////////////////////////////////////////////////////////// +#if defined(PR_LOGGING) // // set NSPR_LOG_MODULES=Test:5 // static PRLogModuleInfo *gTestLog = nullptr; +#endif #define LOG(args) PR_LOG(gTestLog, PR_LOG_DEBUG, args) //////////////////////////////////////////////////////////////////////////////// @@ -278,7 +280,9 @@ main(int argc, char* argv[]) if (registrar) registrar->AutoRegister(nullptr); +#if defined(PR_LOGGING) gTestLog = PR_NewLogModule("Test"); +#endif nsCOMPtr srcFile; rv = NS_NewNativeLocalFile(nsDependentCString(fileName), false, getter_AddRefs(srcFile)); diff --git a/netwerk/test/TestUpload.cpp b/netwerk/test/TestUpload.cpp index b01cf13b2763..e5be007285db 100644 --- a/netwerk/test/TestUpload.cpp +++ b/netwerk/test/TestUpload.cpp @@ -16,10 +16,12 @@ #include "nsIUploadChannel.h" #include "prlog.h" +#if defined(PR_LOGGING) // // set NSPR_LOG_MODULES=Test:5 // static PRLogModuleInfo *gTestLog = nullptr; +#endif #define LOG(args) PR_LOG(gTestLog, PR_LOG_DEBUG, args) //----------------------------------------------------------------------------- @@ -108,7 +110,9 @@ main(int argc, char* argv[]) char* uriSpec = argv[1]; char* fileName = argv[2]; +#if defined(PR_LOGGING) gTestLog = PR_NewLogModule("Test"); +#endif { nsCOMPtr servMan; diff --git a/netwerk/wifi/nsWifiAccessPoint.cpp b/netwerk/wifi/nsWifiAccessPoint.cpp index a2f1d17fb4c6..55a6df5dadfc 100644 --- a/netwerk/wifi/nsWifiAccessPoint.cpp +++ b/netwerk/wifi/nsWifiAccessPoint.cpp @@ -7,7 +7,9 @@ #include "nsMemory.h" #include "prlog.h" +#if defined(PR_LOGGING) extern PRLogModuleInfo *gWifiMonitorLog; +#endif #define LOG(args) PR_LOG(gWifiMonitorLog, PR_LOG_DEBUG, args) diff --git a/netwerk/wifi/nsWifiMonitor.cpp b/netwerk/wifi/nsWifiMonitor.cpp index 394287d2ab82..465792836899 100644 --- a/netwerk/wifi/nsWifiMonitor.cpp +++ b/netwerk/wifi/nsWifiMonitor.cpp @@ -20,7 +20,9 @@ using namespace mozilla; +#if defined(PR_LOGGING) PRLogModuleInfo *gWifiMonitorLog; +#endif NS_IMPL_ISUPPORTS(nsWifiMonitor, nsIRunnable, @@ -32,7 +34,9 @@ nsWifiMonitor::nsWifiMonitor() , mThreadComplete(false) , mReentrantMonitor("nsWifiMonitor.mReentrantMonitor") { +#if defined(PR_LOGGING) gWifiMonitorLog = PR_NewLogModule("WifiMonitor"); +#endif nsCOMPtr obsSvc = mozilla::services::GetObserverService(); if (obsSvc) diff --git a/netwerk/wifi/nsWifiMonitor.h b/netwerk/wifi/nsWifiMonitor.h index 3e462facada4..1077abbdc013 100644 --- a/netwerk/wifi/nsWifiMonitor.h +++ b/netwerk/wifi/nsWifiMonitor.h @@ -26,7 +26,9 @@ #include "win_wifiScanner.h" #endif +#if defined(PR_LOGGING) extern PRLogModuleInfo *gWifiMonitorLog; +#endif #define LOG(args) PR_LOG(gWifiMonitorLog, PR_LOG_DEBUG, args) class nsWifiAccessPoint; diff --git a/netwerk/wifi/nsWifiMonitorGonk.cpp b/netwerk/wifi/nsWifiMonitorGonk.cpp index 513f430ca8eb..043df56bf9b7 100644 --- a/netwerk/wifi/nsWifiMonitorGonk.cpp +++ b/netwerk/wifi/nsWifiMonitorGonk.cpp @@ -22,7 +22,9 @@ using namespace mozilla; +#if defined(PR_LOGGING) PRLogModuleInfo *gWifiMonitorLog; +#endif NS_IMPL_ISUPPORTS(nsWifiMonitor, nsIWifiMonitor, @@ -31,7 +33,9 @@ NS_IMPL_ISUPPORTS(nsWifiMonitor, nsWifiMonitor::nsWifiMonitor() { +#if defined(PR_LOGGING) gWifiMonitorLog = PR_NewLogModule("WifiMonitor"); +#endif nsCOMPtr obsSvc = mozilla::services::GetObserverService(); if (obsSvc) {