зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1239961 - Minimize amount of PR_Poll and PR_Read calls during shutdown. r=mcmanus
This commit is contained in:
Родитель
a170797259
Коммит
854aecd889
|
@ -8,6 +8,7 @@
|
|||
#include "nsSocketTransport2.h"
|
||||
#include "NetworkActivityMonitor.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "nsIOService.h"
|
||||
#endif // !defined(MOZILLA_XPCOMRT_API)
|
||||
#include "nsASocketHandler.h"
|
||||
#include "nsError.h"
|
||||
|
@ -1065,7 +1066,16 @@ nsSocketTransportService::DoPollIteration(bool wait, TimeDuration *pollDuration)
|
|||
// Measures seconds spent while blocked on PR_Poll
|
||||
uint32_t pollInterval;
|
||||
|
||||
int32_t n = Poll(wait, &pollInterval, pollDuration);
|
||||
int32_t n = 0;
|
||||
#if !defined(MOZILLA_XPCOMRT_API)
|
||||
if (!gIOService->IsNetTearingDown()) {
|
||||
// Let's not do polling during shutdown.
|
||||
n = Poll(wait, &pollInterval, pollDuration);
|
||||
}
|
||||
#else
|
||||
n = Poll(wait, &pollInterval, pollDuration);
|
||||
#endif // defined(MOZILLA_XPCOMRT_API)
|
||||
|
||||
if (n < 0) {
|
||||
SOCKET_LOG((" PR_Poll error [%d] os error [%d]\n", PR_GetError(),
|
||||
PR_GetOSError()));
|
||||
|
|
|
@ -558,7 +558,7 @@ nsHttpConnection::AddTransaction(nsAHttpTransaction *httpTransaction,
|
|||
}
|
||||
|
||||
void
|
||||
nsHttpConnection::Close(nsresult reason)
|
||||
nsHttpConnection::Close(nsresult reason, bool aIsShutdown)
|
||||
{
|
||||
LOG(("nsHttpConnection::Close [this=%p reason=%x]\n", this, reason));
|
||||
|
||||
|
@ -596,7 +596,8 @@ nsHttpConnection::Close(nsresult reason)
|
|||
// socket with data pending. TLS is a classic case of this where
|
||||
// a Alert record might be superfulous to a clean HTTP/SPDY shutdown.
|
||||
// Never block to do this and limit it to a small amount of data.
|
||||
if (mSocketIn) {
|
||||
// During shutdown just be fast!
|
||||
if (mSocketIn && !aIsShutdown) {
|
||||
char buffer[4000];
|
||||
uint32_t count, total = 0;
|
||||
nsresult rv;
|
||||
|
|
|
@ -77,7 +77,7 @@ public:
|
|||
nsresult Activate(nsAHttpTransaction *, uint32_t caps, int32_t pri);
|
||||
|
||||
// Close the underlying socket transport.
|
||||
void Close(nsresult reason);
|
||||
void Close(nsresult reason, bool aIsShutdown = false);
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// XXX document when these are ok to call
|
||||
|
|
|
@ -998,7 +998,7 @@ nsHttpConnectionMgr::ShutdownPassCB(const nsACString &key,
|
|||
ent->mActiveConns.RemoveElementAt(0);
|
||||
self->DecrementActiveConnCount(conn);
|
||||
|
||||
conn->Close(NS_ERROR_ABORT);
|
||||
conn->Close(NS_ERROR_ABORT, true);
|
||||
NS_RELEASE(conn);
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче