From d336e56185e21387acb4b8189f89c92f551fc034 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Mon, 9 Jan 2012 19:43:52 -0800 Subject: [PATCH] Bug 715770 - Remove necko buffer cache. r=biesi. --- netwerk/base/src/nsIOService.cpp | 27 ++++--------------- netwerk/base/src/nsIOService.h | 4 +-- netwerk/base/src/nsNetSegmentUtils.h | 12 --------- netwerk/base/src/nsSocketTransport2.cpp | 6 ++--- netwerk/base/src/nsStreamTransportService.cpp | 6 ++--- netwerk/build/nsNetModule.cpp | 3 --- netwerk/protocol/http/nsHttpPipeline.cpp | 3 +-- netwerk/protocol/http/nsHttpTransaction.cpp | 3 +-- 8 files changed, 12 insertions(+), 52 deletions(-) diff --git a/netwerk/base/src/nsIOService.cpp b/netwerk/base/src/nsIOService.cpp index 3dcf8432059..760533916bf 100644 --- a/netwerk/base/src/nsIOService.cpp +++ b/netwerk/base/src/nsIOService.cpp @@ -63,7 +63,6 @@ #include "nsIProxyInfo.h" #include "nsEscape.h" #include "nsNetCID.h" -#include "nsIRecyclingAllocator.h" #include "nsISocketTransport.h" #include "nsCRT.h" #include "nsSimpleNestedURI.h" @@ -86,6 +85,9 @@ #define AUTODIAL_PREF "network.autodial-helper.enabled" #define MANAGE_OFFLINE_STATUS_PREF "network.manage-offline-status" +// Nb: these have been misnomers since bug 715770 removed the buffer cache. +// "network.segment.count" and "network.segment.size" would be better names, +// but the old names are still used to preserve backward compatibility. #define NECKO_BUFFER_CACHE_COUNT_PREF "network.buffer.cache.count" #define NECKO_BUFFER_CACHE_SIZE_PREF "network.buffer.cache.size" @@ -166,8 +168,7 @@ static const char kProfileChangeNetTeardownTopic[] = "profile-change-net-teardow static const char kProfileChangeNetRestoreTopic[] = "profile-change-net-restore"; static const char kProfileDoChange[] = "profile-do-change"; -// Necko buffer cache -nsIMemory* nsIOService::gBufferCache = nsnull; +// Necko buffer defaults PRUint32 nsIOService::gDefaultSegmentSize = 4096; PRUint32 nsIOService::gDefaultSegmentCount = 24; @@ -245,24 +246,6 @@ nsIOService::Init() NS_TIME_FUNCTION_MARK("Registered observers"); - // Get the allocator ready - if (!gBufferCache) { - nsresult rv = NS_OK; - nsCOMPtr recyclingAllocator = - do_CreateInstance(NS_RECYCLINGALLOCATOR_CONTRACTID, &rv); - - if (NS_FAILED(rv)) - return rv; - rv = recyclingAllocator->Init(gDefaultSegmentCount, - (15 * 60), // 15 minutes - "necko"); - - NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Was unable to allocate. No gBufferCache."); - CallQueryInterface(recyclingAllocator, &gBufferCache); - } - - NS_TIME_FUNCTION_MARK("Set up the recycling allocator"); - gIOService = this; InitializeNetworkLinkService(); @@ -924,7 +907,7 @@ nsIOService::PrefsChanged(nsIPrefBranch *prefs, const char *pref) */ if (size > 0 && size < 1024*1024) gDefaultSegmentSize = size; - NS_WARN_IF_FALSE( (!(size & (size - 1))) , "network buffer cache size is not a power of 2!"); + NS_WARN_IF_FALSE( (!(size & (size - 1))) , "network segment size is not a power of 2!"); } } diff --git a/netwerk/base/src/nsIOService.h b/netwerk/base/src/nsIOService.h index dc231a5858d..0b68750e2de 100644 --- a/netwerk/base/src/nsIOService.h +++ b/netwerk/base/src/nsIOService.h @@ -165,9 +165,7 @@ private: bool mAutoDialEnabled; public: - // Necko buffer cache. Used for all default buffer sizes that necko - // allocates. - static nsIMemory *gBufferCache; + // Used for all default buffer sizes that necko allocates. static PRUint32 gDefaultSegmentSize; static PRUint32 gDefaultSegmentCount; }; diff --git a/netwerk/base/src/nsNetSegmentUtils.h b/netwerk/base/src/nsNetSegmentUtils.h index 4401c360a83..dbf2b126a1c 100644 --- a/netwerk/base/src/nsNetSegmentUtils.h +++ b/netwerk/base/src/nsNetSegmentUtils.h @@ -40,18 +40,6 @@ #include "nsIOService.h" -/** - * returns preferred allocator for given segment size. NULL implies - * system allocator. this result can be used when allocating a pipe. - */ - -static inline nsIMemory * -net_GetSegmentAlloc(PRUint32 segsize) -{ - return (segsize == nsIOService::gDefaultSegmentSize) - ? nsIOService::gBufferCache : nsnull; -} - /** * applies defaults to segment params in a consistent way. */ diff --git a/netwerk/base/src/nsSocketTransport2.cpp b/netwerk/base/src/nsSocketTransport2.cpp index d856e978257..18cf88058cf 100644 --- a/netwerk/base/src/nsSocketTransport2.cpp +++ b/netwerk/base/src/nsSocketTransport2.cpp @@ -1725,12 +1725,11 @@ nsSocketTransport::OpenInputStream(PRUint32 flags, bool openBlocking = (flags & OPEN_BLOCKING); net_ResolveSegmentParams(segsize, segcount); - nsIMemory *segalloc = net_GetSegmentAlloc(segsize); // create a pipe nsCOMPtr pipeOut; rv = NS_NewPipe2(getter_AddRefs(pipeIn), getter_AddRefs(pipeOut), - !openBlocking, true, segsize, segcount, segalloc); + !openBlocking, true, segsize, segcount); if (NS_FAILED(rv)) return rv; // async copy from socket to pipe @@ -1772,12 +1771,11 @@ nsSocketTransport::OpenOutputStream(PRUint32 flags, bool openBlocking = (flags & OPEN_BLOCKING); net_ResolveSegmentParams(segsize, segcount); - nsIMemory *segalloc = net_GetSegmentAlloc(segsize); // create a pipe nsCOMPtr pipeIn; rv = NS_NewPipe2(getter_AddRefs(pipeIn), getter_AddRefs(pipeOut), - true, !openBlocking, segsize, segcount, segalloc); + true, !openBlocking, segsize, segcount); if (NS_FAILED(rv)) return rv; // async copy from socket to pipe diff --git a/netwerk/base/src/nsStreamTransportService.cpp b/netwerk/base/src/nsStreamTransportService.cpp index 4537da3f40f..772a3809af8 100644 --- a/netwerk/base/src/nsStreamTransportService.cpp +++ b/netwerk/base/src/nsStreamTransportService.cpp @@ -129,13 +129,12 @@ nsInputStreamTransport::OpenInputStream(PRUint32 flags, bool nonblocking = !(flags & OPEN_BLOCKING); net_ResolveSegmentParams(segsize, segcount); - nsIMemory *segalloc = net_GetSegmentAlloc(segsize); nsCOMPtr pipeOut; rv = NS_NewPipe2(getter_AddRefs(mPipeIn), getter_AddRefs(pipeOut), nonblocking, true, - segsize, segcount, segalloc); + segsize, segcount); if (NS_FAILED(rv)) return rv; mInProgress = true; @@ -340,13 +339,12 @@ nsOutputStreamTransport::OpenOutputStream(PRUint32 flags, bool nonblocking = !(flags & OPEN_BLOCKING); net_ResolveSegmentParams(segsize, segcount); - nsIMemory *segalloc = net_GetSegmentAlloc(segsize); nsCOMPtr pipeIn; rv = NS_NewPipe2(getter_AddRefs(pipeIn), getter_AddRefs(mPipeOut), true, nonblocking, - segsize, segcount, segalloc); + segsize, segcount); if (NS_FAILED(rv)) return rv; mInProgress = true; diff --git a/netwerk/build/nsNetModule.cpp b/netwerk/build/nsNetModule.cpp index 9385f2f1a16..5b7b9cefe46 100644 --- a/netwerk/build/nsNetModule.cpp +++ b/netwerk/build/nsNetModule.cpp @@ -655,9 +655,6 @@ static void nsNetShutdown() // Release the url parser that the stdurl is holding. nsStandardURL::ShutdownGlobalObjects(); - // Release buffer cache - NS_IF_RELEASE(nsIOService::gBufferCache); - // Release global state used by the URL helper module. net_ShutdownURLHelper(); #ifdef XP_MACOSX diff --git a/netwerk/protocol/http/nsHttpPipeline.cpp b/netwerk/protocol/http/nsHttpPipeline.cpp index d895b2c7cc6..4cbc1c71e10 100644 --- a/netwerk/protocol/http/nsHttpPipeline.cpp +++ b/netwerk/protocol/http/nsHttpPipeline.cpp @@ -726,8 +726,7 @@ nsHttpPipeline::FillSendBuf() getter_AddRefs(mSendBufOut), nsIOService::gDefaultSegmentSize, /* segment size */ nsIOService::gDefaultSegmentSize, /* max size */ - true, true, - nsIOService::gBufferCache); + true, true); if (NS_FAILED(rv)) return rv; } diff --git a/netwerk/protocol/http/nsHttpTransaction.cpp b/netwerk/protocol/http/nsHttpTransaction.cpp index bb149d7bfa8..30faafb6ea6 100644 --- a/netwerk/protocol/http/nsHttpTransaction.cpp +++ b/netwerk/protocol/http/nsHttpTransaction.cpp @@ -297,8 +297,7 @@ nsHttpTransaction::Init(PRUint8 caps, getter_AddRefs(mPipeOut), true, true, nsIOService::gDefaultSegmentSize, - nsIOService::gDefaultSegmentCount, - nsIOService::gBufferCache); + nsIOService::gDefaultSegmentCount); if (NS_FAILED(rv)) return rv; NS_ADDREF(*responseBody = mPipeIn);