2018-11-30 18:39:55 +03:00
|
|
|
/* vim:set ts=4 sw=2 sts=2 ci et: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2003-01-18 04:27:53 +03:00
|
|
|
|
|
|
|
#ifndef nsSocketTransportService2_h__
|
|
|
|
#define nsSocketTransportService2_h__
|
|
|
|
|
2020-06-12 08:10:47 +03:00
|
|
|
#include "PollableEvent.h"
|
|
|
|
#include "mozilla/Atomics.h"
|
2016-05-23 19:20:58 +03:00
|
|
|
#include "mozilla/LinkedList.h"
|
2020-06-12 08:10:47 +03:00
|
|
|
#include "mozilla/Logging.h"
|
2020-02-27 20:39:15 +03:00
|
|
|
#include "mozilla/Maybe.h"
|
Rollup of bug 645263 and bug 646259: Switch to mozilla:: sync primitives. r=cjones,dbaron,doublec,ehsan src=bsmedberg
Bug 645263, part 0: Count sync primitive ctor/dtors. r=dbaron
Bug 645263, part 1: Migrate content/media to mozilla:: sync primitives. r=doublec
Bug 645263, part 2: Migrate modules/plugin to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 3: Migrate nsComponentManagerImpl to mozilla:: sync primitives. sr=bsmedberg
Bug 645263, part 4: Migrate everything else to mozilla:: sync primitives. r=dbaron
Bug 645263, part 5: Remove nsAutoLock.*. sr=bsmedberg
Bug 645263, part 6: Make editor test be nicer to deadlock detector. r=ehsan
Bug 645263, part 7: Disable tracemalloc backtraces for xpcshell tests. r=dbaron
Bug 646259: Fix nsCacheService to use a CondVar for notifying. r=cjones
2011-04-01 08:29:02 +04:00
|
|
|
#include "mozilla/Mutex.h"
|
2015-03-12 12:25:13 +03:00
|
|
|
#include "mozilla/TimeStamp.h"
|
2020-01-16 20:22:36 +03:00
|
|
|
#include "mozilla/Tuple.h"
|
2016-03-22 18:02:39 +03:00
|
|
|
#include "mozilla/UniquePtr.h"
|
2020-06-12 08:10:47 +03:00
|
|
|
#include "mozilla/net/DashboardTypes.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsIDirectTaskDispatcher.h"
|
|
|
|
#include "nsIObserver.h"
|
|
|
|
#include "nsIRunnable.h"
|
|
|
|
#include "nsIThreadInternal.h"
|
|
|
|
#include "nsITimer.h"
|
|
|
|
#include "nsPISocketTransportService.h"
|
|
|
|
#include "prinit.h"
|
|
|
|
#include "prinrval.h"
|
2003-01-18 04:27:53 +03:00
|
|
|
|
2013-09-22 07:04:57 +04:00
|
|
|
class nsASocketHandler;
|
2013-09-23 07:35:05 +04:00
|
|
|
struct PRPollDesc;
|
2016-05-11 12:31:01 +03:00
|
|
|
class nsIPrefBranch;
|
2013-09-22 07:04:57 +04:00
|
|
|
|
2003-01-18 04:27:53 +03:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-05-19 05:02:57 +03:00
|
|
|
namespace mozilla {
|
|
|
|
namespace net {
|
|
|
|
|
2003-01-18 04:27:53 +03:00
|
|
|
//
|
2016-05-26 02:13:54 +03:00
|
|
|
// set MOZ_LOG=nsSocketTransport:5
|
2003-01-18 04:27:53 +03:00
|
|
|
//
|
2016-05-19 05:02:57 +03:00
|
|
|
extern LazyLogModule gSocketTransportLog;
|
|
|
|
#define SOCKET_LOG(args) MOZ_LOG(gSocketTransportLog, LogLevel::Debug, args)
|
2018-11-16 19:35:52 +03:00
|
|
|
#define SOCKET_LOG1(args) MOZ_LOG(gSocketTransportLog, LogLevel::Error, args)
|
2016-05-19 05:02:57 +03:00
|
|
|
#define SOCKET_LOG_ENABLED() MOZ_LOG_TEST(gSocketTransportLog, LogLevel::Debug)
|
2003-01-18 04:27:53 +03:00
|
|
|
|
2015-05-29 17:13:39 +03:00
|
|
|
//
|
2016-05-26 02:13:54 +03:00
|
|
|
// set MOZ_LOG=UDPSocket:5
|
2015-05-29 17:13:39 +03:00
|
|
|
//
|
2016-05-19 05:02:57 +03:00
|
|
|
extern LazyLogModule gUDPSocketLog;
|
|
|
|
#define UDPSOCKET_LOG(args) MOZ_LOG(gUDPSocketLog, LogLevel::Debug, args)
|
|
|
|
#define UDPSOCKET_LOG_ENABLED() MOZ_LOG_TEST(gUDPSocketLog, LogLevel::Debug)
|
2015-05-29 17:13:39 +03:00
|
|
|
|
2003-01-18 04:27:53 +03:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#define NS_SOCKET_POLL_TIMEOUT PR_INTERVAL_NO_TIMEOUT
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2014-02-06 23:51:38 +04:00
|
|
|
// These maximums are borrowed from the linux kernel.
|
|
|
|
static const int32_t kMaxTCPKeepIdle = 32767; // ~9 hours.
|
|
|
|
static const int32_t kMaxTCPKeepIntvl = 32767;
|
|
|
|
static const int32_t kMaxTCPKeepCount = 127;
|
|
|
|
static const int32_t kDefaultTCPKeepCount =
|
|
|
|
#if defined(XP_WIN)
|
|
|
|
10; // Hardcoded in Windows.
|
|
|
|
#elif defined(XP_MACOSX)
|
|
|
|
8; // Hardcoded in OSX.
|
|
|
|
#else
|
|
|
|
4; // Specifiable in Linux.
|
|
|
|
#endif
|
|
|
|
|
2016-05-23 19:20:58 +03:00
|
|
|
class LinkedRunnableEvent final
|
|
|
|
: public LinkedListElement<LinkedRunnableEvent> {
|
|
|
|
public:
|
|
|
|
explicit LinkedRunnableEvent(nsIRunnable* event) : mEvent(event) {}
|
2018-04-30 19:46:04 +03:00
|
|
|
~LinkedRunnableEvent() = default;
|
2016-05-23 19:20:58 +03:00
|
|
|
|
|
|
|
already_AddRefed<nsIRunnable> TakeEvent() { return mEvent.forget(); }
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2016-05-23 19:20:58 +03:00
|
|
|
private:
|
|
|
|
nsCOMPtr<nsIRunnable> mEvent;
|
|
|
|
};
|
|
|
|
|
2014-02-06 23:51:38 +04:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class nsSocketTransportService final : public nsPISocketTransportService,
|
2018-11-23 19:46:52 +03:00
|
|
|
public nsISerialEventTarget,
|
2015-03-27 21:52:19 +03:00
|
|
|
public nsIThreadObserver,
|
|
|
|
public nsIRunnable,
|
2020-06-12 08:10:47 +03:00
|
|
|
public nsIObserver,
|
2021-09-07 11:01:18 +03:00
|
|
|
public nsINamed,
|
2020-06-12 08:10:47 +03:00
|
|
|
public nsIDirectTaskDispatcher {
|
2003-01-18 04:27:53 +03:00
|
|
|
public:
|
2013-07-19 06:24:13 +04:00
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
2005-04-15 03:18:34 +04:00
|
|
|
NS_DECL_NSPISOCKETTRANSPORTSERVICE
|
2003-01-18 04:27:53 +03:00
|
|
|
NS_DECL_NSISOCKETTRANSPORTSERVICE
|
2015-04-09 18:31:59 +03:00
|
|
|
NS_DECL_NSIROUTEDSOCKETTRANSPORTSERVICE
|
2017-05-20 06:58:07 +03:00
|
|
|
NS_DECL_NSIEVENTTARGET_FULL
|
2006-05-10 21:30:15 +04:00
|
|
|
NS_DECL_NSITHREADOBSERVER
|
2003-01-18 04:27:53 +03:00
|
|
|
NS_DECL_NSIRUNNABLE
|
2009-02-09 20:31:44 +03:00
|
|
|
NS_DECL_NSIOBSERVER
|
2021-09-07 11:01:18 +03:00
|
|
|
NS_DECL_NSINAMED
|
2020-06-12 08:10:47 +03:00
|
|
|
NS_DECL_NSIDIRECTTASKDISPATCHER
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2021-06-11 10:10:41 +03:00
|
|
|
static const uint32_t SOCKET_LIMIT_MIN = 50U;
|
|
|
|
|
2003-01-18 04:27:53 +03:00
|
|
|
nsSocketTransportService();
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2011-04-13 16:59:29 +04:00
|
|
|
// Max Socket count may need to get initialized/used by nsHttpHandler
|
|
|
|
// before this class is initialized.
|
2012-08-22 19:56:38 +04:00
|
|
|
static uint32_t gMaxCount;
|
2011-04-13 16:59:29 +04:00
|
|
|
static PRCallOnceType gMaxCountInitOnce;
|
|
|
|
static PRStatus DiscoverMaxCount();
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2016-03-24 03:44:28 +03:00
|
|
|
bool CanAttachSocket();
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2013-07-29 20:08:03 +04:00
|
|
|
// Called by the networking dashboard on the socket thread only
|
2012-12-10 18:13:55 +04:00
|
|
|
// Fills the passed array with socket information
|
2016-05-19 05:02:57 +03:00
|
|
|
void GetSocketConnections(nsTArray<SocketInfo>*);
|
2013-07-29 20:08:03 +04:00
|
|
|
uint64_t GetSentBytes() { return mSentBytesCount; }
|
|
|
|
uint64_t GetReceivedBytes() { return mReceivedBytesCount; }
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2014-02-06 23:51:38 +04:00
|
|
|
// Returns true if keepalives are enabled in prefs.
|
|
|
|
bool IsKeepaliveEnabled() { return mKeepaliveEnabledPref; }
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-12-18 20:19:29 +03:00
|
|
|
bool IsTelemetryEnabledAndNotSleepPhase();
|
2016-01-18 10:20:00 +03:00
|
|
|
PRIntervalTime MaxTimeForPrClosePref() { return mMaxTimeForPrClosePref; }
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2020-01-16 20:22:36 +03:00
|
|
|
// According the preference value of `network.socket.forcePort` this method
|
|
|
|
// possibly remaps the port number passed as the arg.
|
|
|
|
void ApplyPortRemap(uint16_t* aPort);
|
|
|
|
|
|
|
|
// Reads the preference string and updates (rewrites) the mPortRemapping
|
|
|
|
// array on the socket thread. Returns true if the whole pref string was
|
|
|
|
// correctly formed.
|
|
|
|
bool UpdatePortRemapPreference(nsACString const& aPortMappingPref);
|
|
|
|
|
2003-11-15 08:52:32 +03:00
|
|
|
protected:
|
2003-01-18 04:27:53 +03:00
|
|
|
virtual ~nsSocketTransportService();
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2003-11-15 08:52:32 +03:00
|
|
|
private:
|
2003-01-18 04:27:53 +03:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
// misc (any thread)
|
|
|
|
//-------------------------------------------------------------------------
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2020-06-30 14:06:31 +03:00
|
|
|
// The value is guaranteed to be valid and not dangling while on the socket
|
|
|
|
// thread as mThread is only ever reset after it's been shutdown.
|
|
|
|
// This member should only ever be read on the socket thread.
|
2021-06-11 10:10:41 +03:00
|
|
|
nsIThread* mRawThread{nullptr};
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2020-06-30 14:06:31 +03:00
|
|
|
// Returns mThread in a thread-safe manner.
|
2007-12-05 05:18:58 +03:00
|
|
|
already_AddRefed<nsIThread> GetThreadSafely();
|
2020-06-12 08:10:47 +03:00
|
|
|
// Same as above, but return mThread as a nsIDirectTaskDispatcher
|
|
|
|
already_AddRefed<nsIDirectTaskDispatcher> GetDirectTaskDispatcherSafely();
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2005-06-09 18:09:23 +04:00
|
|
|
//-------------------------------------------------------------------------
|
2006-05-10 21:30:15 +04:00
|
|
|
// initialization and shutdown (any thread)
|
2005-06-09 18:09:23 +04:00
|
|
|
//-------------------------------------------------------------------------
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2021-06-11 10:10:41 +03:00
|
|
|
Atomic<bool> mInitialized{false};
|
2020-06-30 14:06:31 +03:00
|
|
|
// indicates whether we are currently in the process of shutting down
|
2021-06-11 10:10:41 +03:00
|
|
|
Atomic<bool> mShuttingDown{false};
|
|
|
|
Mutex mLock{"nsSocketTransportService::mLock"};
|
2020-06-30 14:06:31 +03:00
|
|
|
// Variables in the next section protected by mLock
|
|
|
|
|
|
|
|
// mThread and mDirectTaskDispatcher are only ever modified on the main
|
|
|
|
// thread. Will be set on Init and set to null after shutdown. You must access
|
|
|
|
// mThread and mDirectTaskDispatcher outside the main thread via respectively
|
|
|
|
// GetThreadSafely and GetDirectTaskDispatchedSafely().
|
|
|
|
nsCOMPtr<nsIThread> mThread;
|
|
|
|
// We store a pointer to mThread as a direct task dispatcher to avoid having
|
|
|
|
// to do do_QueryInterface whenever we need to access the interface.
|
|
|
|
nsCOMPtr<nsIDirectTaskDispatcher> mDirectTaskDispatcher;
|
|
|
|
UniquePtr<PollableEvent> mPollableEvent;
|
2021-06-11 10:10:41 +03:00
|
|
|
bool mOffline{false};
|
|
|
|
bool mGoingOffline{false};
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2012-09-18 03:45:10 +04:00
|
|
|
// Detaches all sockets.
|
|
|
|
void Reset(bool aGuardLocals);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2016-09-19 20:29:59 +03:00
|
|
|
nsresult ShutdownThread();
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2003-01-18 04:27:53 +03:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
// socket lists (socket thread only)
|
|
|
|
//
|
|
|
|
// only "active" sockets are on the poll list. the active list is kept
|
2003-02-23 08:07:34 +03:00
|
|
|
// in sync with the poll list such that:
|
|
|
|
//
|
|
|
|
// mActiveList[k].mFD == mPollList[k+1].fd
|
|
|
|
//
|
|
|
|
// where k=0,1,2,...
|
2003-01-18 04:27:53 +03:00
|
|
|
//-------------------------------------------------------------------------
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2003-01-18 04:27:53 +03:00
|
|
|
struct SocketContext {
|
|
|
|
PRFileDesc* mFD;
|
|
|
|
nsASocketHandler* mHandler;
|
2018-03-12 08:00:00 +03:00
|
|
|
PRIntervalTime mPollStartEpoch; // time we started to poll this socket
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-03-12 08:00:00 +03:00
|
|
|
public:
|
2018-03-19 14:48:00 +03:00
|
|
|
// Returns true iff the socket has not been signalled longer than
|
|
|
|
// the desired timeout (mHandler->mPollTimeout).
|
2018-03-12 08:00:00 +03:00
|
|
|
bool IsTimedOut(PRIntervalTime now) const;
|
2018-03-19 14:48:00 +03:00
|
|
|
// Engages the timeout by marking the epoch we start polling this socket.
|
|
|
|
// If epoch is already marked this does nothing, hence, this method can be
|
|
|
|
// called everytime we put this socket to poll() list with in-flags set.
|
|
|
|
void EnsureTimeout(PRIntervalTime now);
|
|
|
|
// Called after an event on a socket has been signalled to turn of the
|
|
|
|
// timeout calculation.
|
|
|
|
void DisengageTimeout();
|
|
|
|
// Returns the number of intervals this socket is about to timeout in,
|
|
|
|
// or 0 (zero) when it has already timed out. Returns
|
|
|
|
// NS_SOCKET_POLL_TIMEOUT when there is no timeout set on the socket.
|
2018-03-12 08:00:00 +03:00
|
|
|
PRIntervalTime TimeoutIn(PRIntervalTime now) const;
|
2018-08-21 17:33:52 +03:00
|
|
|
// When a socket timeout is reset and later set again, it may happen
|
|
|
|
// that mPollStartEpoch is not reset in between. We have to manually
|
|
|
|
// call this on every iteration over sockets to ensure the epoch reset.
|
|
|
|
void MaybeResetEpoch();
|
2003-01-18 04:27:53 +03:00
|
|
|
};
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2011-04-13 16:59:29 +04:00
|
|
|
SocketContext* mActiveList; /* mListSize entries */
|
|
|
|
SocketContext* mIdleList; /* mListSize entries */
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2021-06-11 10:10:41 +03:00
|
|
|
uint32_t mActiveListSize{SOCKET_LIMIT_MIN};
|
|
|
|
uint32_t mIdleListSize{SOCKET_LIMIT_MIN};
|
|
|
|
uint32_t mActiveCount{0};
|
|
|
|
uint32_t mIdleCount{0};
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2011-04-13 16:59:29 +04:00
|
|
|
nsresult DetachSocket(SocketContext*, SocketContext*);
|
2003-01-18 04:27:53 +03:00
|
|
|
nsresult AddToIdleList(SocketContext*);
|
|
|
|
nsresult AddToPollList(SocketContext*);
|
|
|
|
void RemoveFromIdleList(SocketContext*);
|
|
|
|
void RemoveFromPollList(SocketContext*);
|
2003-02-23 08:07:34 +03:00
|
|
|
void MoveToIdleList(SocketContext* sock);
|
|
|
|
void MoveToPollList(SocketContext* sock);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool GrowActiveList();
|
|
|
|
bool GrowIdleList();
|
2011-04-13 16:59:29 +04:00
|
|
|
void InitMaxCount();
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2013-07-29 20:08:03 +04:00
|
|
|
// Total bytes number transfered through all the sockets except active ones
|
2021-06-11 10:10:41 +03:00
|
|
|
uint64_t mSentBytesCount{0};
|
|
|
|
uint64_t mReceivedBytesCount{0};
|
2003-01-18 04:27:53 +03:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
// poll list (socket thread only)
|
|
|
|
//
|
2016-03-22 18:02:39 +03:00
|
|
|
// first element of the poll list is mPollableEvent (or null if the pollable
|
2003-02-23 08:07:34 +03:00
|
|
|
// event cannot be created).
|
2003-01-18 04:27:53 +03:00
|
|
|
//-------------------------------------------------------------------------
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2011-04-13 16:59:29 +04:00
|
|
|
PRPollDesc* mPollList; /* mListSize + 1 entries */
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-03-12 08:00:00 +03:00
|
|
|
PRIntervalTime PollTimeout(
|
|
|
|
PRIntervalTime now); // computes ideal poll timeout
|
2016-05-19 05:02:57 +03:00
|
|
|
nsresult DoPollIteration(TimeDuration* pollDuration);
|
2006-05-10 21:30:15 +04:00
|
|
|
// perfoms a single poll iteration
|
2021-06-04 15:35:16 +03:00
|
|
|
int32_t Poll(TimeDuration* pollDuration, PRIntervalTime ts);
|
2006-05-10 21:30:15 +04:00
|
|
|
// calls PR_Poll. the out param
|
2005-01-26 05:13:14 +03:00
|
|
|
// interval indicates the poll
|
|
|
|
// duration in seconds.
|
2015-03-12 12:25:13 +03:00
|
|
|
// pollDuration is used only for
|
|
|
|
// telemetry
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2003-04-09 02:18:10 +04:00
|
|
|
//-------------------------------------------------------------------------
|
2003-10-06 05:46:31 +04:00
|
|
|
// pending socket queue - see NotifyWhenCanAttachSocket
|
2003-04-09 02:18:10 +04:00
|
|
|
//-------------------------------------------------------------------------
|
2016-05-23 19:20:58 +03:00
|
|
|
AutoCleanLinkedList<LinkedRunnableEvent> mPendingSocketQueue;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2014-02-06 23:51:38 +04:00
|
|
|
// Preference Monitor for SendBufferSize and Keepalive prefs.
|
2009-02-09 20:31:44 +03:00
|
|
|
nsresult UpdatePrefs();
|
2019-11-01 05:57:20 +03:00
|
|
|
static void UpdatePrefs(const char* aPref, void* aSelf);
|
2018-07-05 23:15:52 +03:00
|
|
|
void UpdateSendBufferPref();
|
2021-06-11 10:10:41 +03:00
|
|
|
int32_t mSendBufferSize{0};
|
2014-02-06 23:51:38 +04:00
|
|
|
// Number of seconds of connection is idle before first keepalive ping.
|
2021-06-11 10:10:41 +03:00
|
|
|
int32_t mKeepaliveIdleTimeS{600};
|
2014-02-06 23:51:38 +04:00
|
|
|
// Number of seconds between retries should keepalive pings fail.
|
2021-06-11 10:10:41 +03:00
|
|
|
int32_t mKeepaliveRetryIntervalS{1};
|
2014-02-06 23:51:38 +04:00
|
|
|
// Number of keepalive probes to send.
|
2021-06-11 10:10:41 +03:00
|
|
|
int32_t mKeepaliveProbeCount{kDefaultTCPKeepCount};
|
2014-02-06 23:51:38 +04:00
|
|
|
// True if TCP keepalive is enabled globally.
|
2021-06-11 10:10:41 +03:00
|
|
|
bool mKeepaliveEnabledPref{false};
|
2018-05-30 17:31:09 +03:00
|
|
|
// Timeout of pollable event signalling.
|
|
|
|
TimeDuration mPollableEventTimeout;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2021-06-11 10:10:41 +03:00
|
|
|
Atomic<bool> mServingPendingQueue{false};
|
|
|
|
Atomic<int32_t, Relaxed> mMaxTimePerPollIter{100};
|
2016-05-19 05:02:57 +03:00
|
|
|
Atomic<PRIntervalTime, Relaxed> mMaxTimeForPrClosePref;
|
2018-05-30 17:36:42 +03:00
|
|
|
// Timestamp of the last network link change event, tracked
|
|
|
|
// also on child processes.
|
2021-06-11 10:10:41 +03:00
|
|
|
Atomic<PRIntervalTime, Relaxed> mLastNetworkLinkChangeTime{0};
|
2018-05-30 17:36:42 +03:00
|
|
|
// Preference for how long we do busy wait after network link
|
|
|
|
// change has been detected.
|
|
|
|
Atomic<PRIntervalTime, Relaxed> mNetworkLinkChangeBusyWaitPeriod;
|
|
|
|
// Preference for the value of timeout for poll() we use during
|
|
|
|
// the network link change event period.
|
|
|
|
Atomic<PRIntervalTime, Relaxed> mNetworkLinkChangeBusyWaitTimeout;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2016-03-19 06:25:00 +03:00
|
|
|
// Between a computer going to sleep and waking up the PR_*** telemetry
|
|
|
|
// will be corrupted - so do not record it.
|
2021-06-11 10:10:41 +03:00
|
|
|
Atomic<bool, Relaxed> mSleepPhase{false};
|
2016-05-19 05:02:57 +03:00
|
|
|
nsCOMPtr<nsITimer> mAfterWakeUpTimer;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2020-01-16 20:22:36 +03:00
|
|
|
// Lazily created array of forced port remappings. The tuple members meaning
|
|
|
|
// is exactly:
|
|
|
|
// <0> the greater-or-equal port number of the range to remap
|
|
|
|
// <1> the less-or-equal port number of the range to remap
|
|
|
|
// <2> the port number to remap to, when the given port number falls to the
|
|
|
|
// range
|
2021-06-04 15:35:16 +03:00
|
|
|
using TPortRemapping = CopyableTArray<Tuple<uint16_t, uint16_t, uint16_t>>;
|
2020-01-16 20:22:36 +03:00
|
|
|
Maybe<TPortRemapping> mPortRemapping;
|
|
|
|
|
|
|
|
// Called on the socket thread to apply the mapping build on the main thread
|
|
|
|
// from the preference.
|
|
|
|
void ApplyPortRemapPreference(TPortRemapping const& portRemapping);
|
|
|
|
|
2014-02-06 23:51:38 +04:00
|
|
|
void OnKeepaliveEnabledPrefChange();
|
|
|
|
void NotifyKeepaliveEnabledPrefChange(SocketContext* sock);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2011-10-25 19:36:49 +04:00
|
|
|
// Socket thread only for dynamically adjusting max socket size
|
|
|
|
#if defined(XP_WIN)
|
|
|
|
void ProbeMaxCount();
|
|
|
|
#endif
|
2021-06-11 10:10:41 +03:00
|
|
|
bool mProbedMaxCount{false};
|
2012-12-10 18:13:55 +04:00
|
|
|
|
2021-08-11 19:07:54 +03:00
|
|
|
// Report socket status to about:networking
|
2016-05-19 05:02:57 +03:00
|
|
|
void AnalyzeConnection(nsTArray<SocketInfo>* data, SocketContext* context,
|
2012-12-10 18:13:55 +04:00
|
|
|
bool aActive);
|
2012-12-08 02:50:43 +04:00
|
|
|
|
|
|
|
void ClosePrivateConnections();
|
2013-04-10 04:46:25 +04:00
|
|
|
void DetachSocketWithGuard(bool aGuardLocals, SocketContext* socketList,
|
|
|
|
int32_t index);
|
2015-03-04 16:17:00 +03:00
|
|
|
|
|
|
|
void MarkTheLastElementOfPendingQueue();
|
2016-09-13 11:43:00 +03:00
|
|
|
|
|
|
|
#if defined(XP_WIN)
|
2021-06-11 10:10:41 +03:00
|
|
|
Atomic<bool> mPolling{false};
|
2016-09-13 11:43:00 +03:00
|
|
|
nsCOMPtr<nsITimer> mPollRepairTimer;
|
|
|
|
void StartPollWatchdog();
|
|
|
|
void DoPollRepair();
|
|
|
|
void StartPolling();
|
|
|
|
void EndPolling();
|
|
|
|
#endif
|
2018-05-30 17:31:09 +03:00
|
|
|
|
|
|
|
void TryRepairPollableEvent();
|
2018-09-22 23:54:11 +03:00
|
|
|
|
2020-11-19 21:57:42 +03:00
|
|
|
CopyableTArray<nsCOMPtr<nsISTSShutdownObserver>> mShutdownObservers;
|
2003-01-18 04:27:53 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
extern nsSocketTransportService* gSocketTransportService;
|
2017-04-27 21:34:42 +03:00
|
|
|
bool OnSocketThread();
|
2016-05-19 05:02:57 +03:00
|
|
|
|
|
|
|
} // namespace net
|
|
|
|
} // namespace mozilla
|
2003-01-18 04:27:53 +03:00
|
|
|
|
|
|
|
#endif // !nsSocketTransportService_h__
|