Init() may have dispatched a TLS token load based on the default pref.
Now that the user pref is known to disable persistence, invalidate that
load and drop any records it already inserted.
Differential Revision: https://phabricator.services.mozilla.com/D306171
The metric is meant to signal that the cache capacity is too low and useful
resumption tokens are being discarded. Counting evictions of no-longer-valid
tokens is not useful.
Differential Revision: https://phabricator.services.mozilla.com/D305592
The metric is meant to signal that the cache capacity is too low and useful
resumption tokens are being discarded. Counting evictions of no-longer-valid
tokens is not useful.
Differential Revision: https://phabricator.services.mozilla.com/D305592
Replace the cert fields in TokenCacheRecord with refcounted
CompressedCert objects shared within each record.
The on-disk format advances to version 3.
Differential Revision: https://phabricator.services.mozilla.com/D300715
Replace the cert fields in TokenCacheRecord with refcounted
CompressedCert objects shared within each record.
The on-disk format advances to version 3.
Differential Revision: https://phabricator.services.mozilla.com/D300715
Replace the cert fields in TokenCacheRecord with refcounted
CompressedCert objects shared within each record.
The on-disk format advances to version 3.
Differential Revision: https://phabricator.services.mozilla.com/D300715
SSLTokensCache::Init() runs before user prefs (user.js) are applied, so it
sees the compile-time default for network.ssl_tokens_cache_persistence.
Init() now registers the profile-after-change observer unconditionally
(before the pref check). The handler reconciles persistence state with
the actual pref value: enabling write observers and the shutdown blocker
if the pref is now true (Bug 2040637), or tearing them down if Init()
set them up but the pref is now false (Bug 2034342).
Differential Revision: https://phabricator.services.mozilla.com/D301474
SSLTokensCache::Init() runs before user prefs (user.js) are applied, so it
sees the compile-time default for network.ssl_tokens_cache_persistence.
Init() now registers the profile-after-change observer unconditionally
(before the pref check). The handler reconciles persistence state with
the actual pref value: enabling write observers and the shutdown blocker
if the pref is now true (Bug 2040637), or tearing them down if Init()
set them up but the pref is now false (Bug 2034342).
Differential Revision: https://phabricator.services.mozilla.com/D301474
SSLTokensCache::Init() runs before user prefs (user.js) are applied, so it
sees the compile-time default for network.ssl_tokens_cache_persistence.
Init() now registers the profile-after-change observer unconditionally
(before the pref check). The handler reconciles persistence state with
the actual pref value: enabling write observers and the shutdown blocker
if the pref is now true (Bug 2040637), or tearing them down if Init()
set them up but the pref is now false (Bug 2034342).
Differential Revision: https://phabricator.services.mozilla.com/D301474
At write time, CollectSnapshotLocked builds a transient
nsTArray<SslTokensPersistedRecord> under sLock and serializes it via
ssl_tokens_cache_serialize_snapshot (still under the lock), then releases
the lock and writes off-lock via ssl_tokens_cache_write_bytes. Cert/token
copies are transient (write-time only). SerializeForIPC now holds sLock
across the full snapshot+serialize, eliminating the stale-snapshot race.
This should reduce memory usage.
SslTokensState, STATE, the four shadow FFI fns, ssl_tokens_cache_write,
ssl_tokens_cache_serialize, and all shadow-maintenance calls are removed.
On-disk STCF v2 format unchanged.
Differential Revision: https://phabricator.services.mozilla.com/D298524
Extend SslTokensPersistedRecordFfi and PersistedRecord with server_cert,
succeeded_cert_chain, handshake_certs, and is_built_cert_chain_root_built_in_root
fields. Bump the on-disk format version to 2.
Add regression tests: PersistenceServerCertRoundTrip verifies all cert fields
survive a write/clear/load cycle; ResumedConnectionHasValidCertAfterReload and
ResumedConnectionEnablesCoalescing verify that RebuildCertificateInfoFromSSLTokenCache()
produces a valid cert and a populated succeeded-chain after disk reload.
Differential Revision: https://phabricator.services.mozilla.com/D295649
Eliminates most MOZ_UNANNOTATED occurrences in netwerk/, enabling
Clang's -Wthread-safety analyzer to enforce lock discipline across the
entire directory. The remaining occurrence (nsHttpChannel::mRCWNLock) is
intentionally left as MOZ_UNANNOTATED; it will be removed by D285971.
35 locks receive proper MOZ_GUARDED_BY/MOZ_REQUIRES annotations. 8 locks
are marked MOZ_ANNOTATED where annotation is genuinely not appropriate
(pure condition variables, write-once-then-read-without-lock patterns,
hot paths with intentional lockless reads).
Beyond mechanical marker removal, the annotations surfaced several real
access pattern issues that were fixed: lockless reads in nsUDPSocket,
nsServerSocket, TLSServerSocket, nsHttpConnection, HttpConnectionUDP,
HttpTransactionParent, HttpBackgroundChannelParent, nsHttpActivityDistributor,
and NetlinkService (Linux-only, surfaced by CI); plus a double-checked lockless
read in nsHostResolver::FromUnspecEntry. Initialization-time writes use
MOZ_PUSH_IGNORE_THREAD_SAFETY since no race is possible before the object
is shared.
Differential Revision: https://phabricator.services.mozilla.com/D290185
When network.process.enabled is true (the desktop default), TLS handshakes
happen in the socket process, so SSLTokensCache::Put() is called there while
the parent process cache stays empty — nothing is ever persisted to disk and
0-RTT session resumption never fires after a restart.
This patch wires up the three missing data flows:
- Startup: parent loads ssl_tokens_cache.bin and forwards tokens to the
socket process via LoadSSLTokensCache.
- Runtime: socket process pushes its live cache to the parent on idle-daily
and application-background via SSLTokensCacheData; parent persists on the
next scheduled write.
- Shutdown: parent requests a final flush from the socket process via
FlushSSLTokensCache() before writing the file during ProfileBeforeChange.
Differential Revision: https://phabricator.services.mozilla.com/D294106
When network.process.enabled is true (the desktop default), TLS handshakes
happen in the socket process, so SSLTokensCache::Put() is called there while
the parent process cache stays empty — nothing is ever persisted to disk and
0-RTT session resumption never fires after a restart.
This patch wires up the three missing data flows:
- Startup: parent loads ssl_tokens_cache.bin and forwards tokens to the
socket process via LoadSSLTokensCache.
- Runtime: socket process pushes its live cache to the parent on idle-daily
and application-background via SSLTokensCacheData; parent persists on the
next scheduled write.
- Shutdown: parent requests a final flush from the socket process via
FlushSSLTokensCache() before writing the file during ProfileBeforeChange.
Differential Revision: https://phabricator.services.mozilla.com/D294106
When network.process.enabled is true (the desktop default), TLS handshakes
happen in the socket process, so SSLTokensCache::Put() is called there while
the parent process cache stays empty — nothing is ever persisted to disk and
0-RTT session resumption never fires after a restart.
This patch wires up the three missing data flows:
- Startup: parent loads ssl_tokens_cache.bin and forwards tokens to the
socket process via LoadSSLTokensCache.
- Runtime: socket process pushes its live cache to the parent on idle-daily
and application-background via SSLTokensCacheData; parent persists on the
next scheduled write.
- Shutdown: parent requests a final flush from the socket process via
FlushSSLTokensCache() before writing the file during ProfileBeforeChange.
Differential Revision: https://phabricator.services.mozilla.com/D294106
When network.process.enabled is true (the desktop default), TLS handshakes
happen in the socket process, so SSLTokensCache::Put() is called there while
the parent process cache stays empty — nothing is ever persisted to disk and
0-RTT session resumption never fires after a restart.
This patch wires up the three missing data flows:
- Startup: parent loads ssl_tokens_cache.bin and forwards tokens to the
socket process via LoadSSLTokensCache.
- Runtime: socket process pushes its live cache to the parent on idle-daily
and application-background via SSLTokensCacheData; parent persists on the
next scheduled write.
- Shutdown: parent requests a final flush from the socket process via
FlushSSLTokensCache() before writing the file during ProfileBeforeChange.
Differential Revision: https://phabricator.services.mozilla.com/D294106
Serialize SSLTokensCache to ssl_tokens_cache.bin so TLS session tickets
survive browser restarts, enabling 0-RTT on first connections. A new Rust
crate handles zlib-compressed (Adler-32 integrity) bincode serialization
and atomic tmp→rename writes. Cert chain data is excluded from the
persisted format.
The cache writes to disk when the application is backgrounded (covering
Android OOM kills), daily when idle, and at graceful shutdown via
nsIAsyncShutdownBlocker, keeping all file I/O off the main thread. The
background read uses nsAutoLowPriorityIO to yield disk bandwidth to
startup-critical reads. Consumed and evicted tokens are removed from the
Rust shadow immediately, bounding its memory use independently of write
frequency.
The cache is always partitioned by top-level site via OriginAttributes,
matching cookie-partitioning semantics. CLEAR_TLS_TOKEN_CACHE is part of
CLEAR_COOKIES_AND_SITE_DATA and CLEAR_FORGET_ABOUT_SITE.
Differential Revision: https://phabricator.services.mozilla.com/D288348
Serialize SSLTokensCache to ssl_tokens_cache.bin so TLS session tickets
survive browser restarts, enabling 0-RTT on first connections. A new Rust
crate handles zlib-compressed (Adler-32 integrity) bincode serialization
and atomic tmp→rename writes. Cert chain data is excluded from the
persisted format.
The cache writes to disk when the application is backgrounded (covering
Android OOM kills), daily when idle, and at graceful shutdown via
nsIAsyncShutdownBlocker, keeping all file I/O off the main thread. The
background read uses nsAutoLowPriorityIO to yield disk bandwidth to
startup-critical reads. Consumed and evicted tokens are removed from the
Rust shadow immediately, bounding its memory use independently of write
frequency.
The cache is always partitioned by top-level site via OriginAttributes,
matching cookie-partitioning semantics. CLEAR_TLS_TOKEN_CACHE is part of
CLEAR_COOKIES_AND_SITE_DATA and CLEAR_FORGET_ABOUT_SITE.
Differential Revision: https://phabricator.services.mozilla.com/D288348