Created
October 15, 2025 15:23
-
-
Save jrmuizel/c2bc7710ccb050758b47b876c6096c9c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| commit fbaacca0ea987d5e231f5dc05fd11d222bfdf2b0 | |
| Author: Jeff Muizelaar <[email protected]> | |
| Date: Wed Nov 6 23:19:11 2024 -0500 | |
| Socket markers | |
| diff --git a/netwerk/base/nsSocketTransport2.cpp b/netwerk/base/nsSocketTransport2.cpp | |
| index 8952bbebd9f9a..e800018820091 100644 | |
| --- a/netwerk/base/nsSocketTransport2.cpp | |
| +++ b/netwerk/base/nsSocketTransport2.cpp | |
| @@ -7,20 +7,21 @@ | |
| #include <algorithm> | |
| #include "nsSocketTransport2.h" | |
| #include "MockNetworkLayer.h" | |
| #include "MockNetworkLayerController.h" | |
| #include "NSSErrorsService.h" | |
| #include "NetworkDataCountLayer.h" | |
| #include "QuicSocketControl.h" | |
| #include "mozilla/Attributes.h" | |
| +#include "mozilla/FlowMarkers.h" | |
| #include "mozilla/StaticPrefs_network.h" | |
| #include "mozilla/SyncRunnable.h" | |
| #include "mozilla/glean/NetwerkMetrics.h" | |
| #include "mozilla/Telemetry.h" | |
| #include "mozilla/dom/ToJSValue.h" | |
| #include "mozilla/net/NeckoChild.h" | |
| #include "mozilla/net/SSLTokensCache.h" | |
| #include "mozilla/ProfilerBandwidthCounter.h" | |
| #include "nsCOMPtr.h" | |
| #include "nsICancelable.h" | |
| @@ -570,20 +571,21 @@ nsSocketOutputStream::Write(const char* buf, uint32_t count, | |
| MutexAutoLock lock(mTransport->mLock); | |
| if (NS_FAILED(mCondition)) return mCondition; | |
| fd = mTransport->GetFD_Locked(); | |
| if (!fd) return NS_BASE_STREAM_WOULD_BLOCK; | |
| } | |
| SOCKET_LOG((" calling PR_Write [count=%u]\n", count)); | |
| + AUTO_PROFILER_FLOW_MARKER("nsSocketOutputStream::Write", OTHER, Flow::FromPointer(fd)); | |
| // cannot hold lock while calling NSPR. (worried about the fact that PSM | |
| // synchronously proxies notifications over to the UI thread, which could | |
| // mistakenly try to re-enter this code.) | |
| int32_t n = PR_Write(fd, buf, count); | |
| SOCKET_LOG((" PR_Write returned [n=%d]\n", n)); | |
| nsresult rv = NS_OK; | |
| { | |
| MutexAutoLock lock(mTransport->mLock); | |
| @@ -2126,20 +2128,21 @@ uint64_t nsSocketTransport::ByteCountReceived() { return mInput->ByteCount(); } | |
| uint64_t nsSocketTransport::ByteCountSent() { return mOutput->ByteCount(); } | |
| //----------------------------------------------------------------------------- | |
| // socket handler impl | |
| void nsSocketTransport::OnSocketReady(PRFileDesc* fd, int16_t outFlags) { | |
| MOZ_ASSERT(OnSocketThread(), "not on socket thread"); | |
| SOCKET_LOG1(("nsSocketTransport::OnSocketReady [this=%p outFlags=%hd]\n", | |
| this, outFlags)); | |
| + AUTO_PROFILER_FLOW_MARKER("nsSocketTransport::OnSocketReady", OTHER, Flow::FromPointer(fd)); | |
| if (outFlags == -1) { | |
| SOCKET_LOG(("socket timeout expired\n")); | |
| mCondition = NS_ERROR_NET_TIMEOUT; | |
| return; | |
| } | |
| if (mState == STATE_TRANSFERRING) { | |
| // if waiting to write and socket is writable or hit an exception. | |
| if ((mPollFlags & PR_POLL_WRITE) && (outFlags & ~PR_POLL_READ)) { | |
| // assume that we won't need to poll any longer (the stream will | |
| @@ -3343,20 +3346,23 @@ void nsSocketTransport::CloseSocket(PRFileDesc* aFd, bool aTelemetryEnabled) { | |
| #endif | |
| // We use PRIntervalTime here because we need | |
| // nsIOService::LastOfflineStateChange time and | |
| // nsIOService::LastConectivityChange time to be atomic. | |
| PRIntervalTime closeStarted; | |
| if (aTelemetryEnabled) { | |
| closeStarted = PR_IntervalNow(); | |
| } | |
| + PROFILER_MARKER("nsSocketTransport::CloseSocket", NETWORK, {}, | |
| + TerminatingFlowMarker, Flow::FromPointer(aFd)); | |
| + | |
| PR_Close(aFd); | |
| if (aTelemetryEnabled) { | |
| SendPRBlockingTelemetry( | |
| closeStarted, glean::networking::prclose_tcp_blocking_time_normal, | |
| glean::networking::prclose_tcp_blocking_time_shutdown, | |
| glean::networking::prclose_tcp_blocking_time_connectivity_change, | |
| glean::networking::prclose_tcp_blocking_time_link_change, | |
| glean::networking::prclose_tcp_blocking_time_offline); | |
| } | |
| diff --git a/netwerk/base/nsSocketTransportService2.cpp b/netwerk/base/nsSocketTransportService2.cpp | |
| index 2fb30a44fe315..7cc60282ad38b 100644 | |
| --- a/netwerk/base/nsSocketTransportService2.cpp | |
| +++ b/netwerk/base/nsSocketTransportService2.cpp | |
| @@ -501,20 +501,23 @@ int64_t nsSocketTransportService::SockIndex(SocketContextList& aList, | |
| return (int64_t)index; | |
| } | |
| void nsSocketTransportService::AddToPollList(SocketContext* sock) { | |
| MOZ_ASSERT(SockIndex(mActiveList, sock) == -1, | |
| "AddToPollList Socket Already Active"); | |
| SOCKET_LOG(("nsSocketTransportService::AddToPollList %p [handler=%p]\n", sock, | |
| sock->mHandler.get())); | |
| + PROFILER_MARKER("nsSocketTransportService::AddToPollList", NETWORK, {}, | |
| + FlowMarker, Flow::FromPointer(sock->mFD)); | |
| + | |
| sock->EnsureTimeout(PR_IntervalNow()); | |
| PRPollDesc poll; | |
| poll.fd = sock->mFD; | |
| poll.in_flags = sock->mHandler->mPollFlags; | |
| poll.out_flags = 0; | |
| if (ChaosMode::isActive(ChaosFeature::NetworkScheduling)) { | |
| auto newSocketIndex = mActiveList.Length(); | |
| newSocketIndex = ChaosMode::randomUint32LessThan(newSocketIndex + 1); | |
| mActiveList.InsertElementAt(newSocketIndex, *sock); | |
| // mPollList is offset by 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment