Bug 1239961 - Minimize amount of PR_Poll and PR_Read calls during shutdown. r=mcmanus

This commit is contained in:
Dragana Damjanovic 2016-01-15 08:21:00 +01:00
Родитель a170797259
Коммит 854aecd889
4 изменённых файлов: 16 добавлений и 5 удалений

Просмотреть файл

@ -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);
}