mORMot2 DailyDaily read of upstream commits

Async shutdown closes leaks while HTTP timeouts split by phase

This is a high-impact networking edition. Async servers, tunnels and RTSP-over-HTTP receive a coordinated ownership and shutdown repair, while TSynThreadPool closes a race that could leave queued work sleeping. HTTP clients gain separate connect, send and receive timeouts, and Kerberos server authentication is consolidated behind a cross-platform wrapper with one public method removal.

TL;DR

  • TSynThreadPool now clears a worker's processing state under the pending-queue lock, preventing a queued task from being stranded by a wake-up race.
  • Async socket, tunnel and RTSP-over-HTTP cleanup now closes file descriptors and transferred connections on failure and shutdown paths.
  • TCrtSocket and HTTP clients now expose separate connect, send and receive timeouts; use 0, not a negative value, when requesting legacy fallback on a live TCrtSocket.
  • TServerSspiKeyTab.ComputeServerHeader is removed; migrate direct callers to KerberosServerAuthHeader and prepare a POSIX keytab explicitly when required.
  • Delphi users should land on build 2.4.17398, which repairs compilation after the timeout constructor refactor.

Upgrade advice

Upgrade async-server, tunnel and RTSP deployments to the final build 2.4.17398 and exercise shutdown under idle, partial-request and pending-write traffic. Delphi users should not stop on 2.4.17393–2.4.17397. Grep for TServerSspiKeyTab.ComputeServerHeader before upgrading and replace direct calls with KerberosServerAuthHeader.

Build2.4.17372 → 2.4.17398
Commits26
Lines+1199 -716
Read6 min

25 of 25 entries · 26 commits upstream

Stories
# Entry Category Units
1 Critical Thread-pool wake-up race could strand queued work TSynThreadPool.PopPendingContext now accepts the caller thread and clears its fProcessingContext while holding fPendingSafe. Queue inspection and worker-idle publication are therefore atomic with respect to Push. Fixes mormot.core.threads+1 4860cac1+18-20

core: fixed TSynThreadPool.PopPendingContext race condition

Impact

On non-IOCP thread-pool paths, Push can no longer enqueue behind a worker that is about to sleep without waking it. This prevents pending asynchronous work from stalling until some unrelated event arrives.

Arnaud Bouchez · 14:10 UTC · view the commit on GitHub →

2 High Direct keytab HTTP authentication method is removed TServerSspiKeyTab.ComputeServerHeader is deleted. TServerSspiKeyTab gains FileSetter and a nil-safe KeyTab getter, while ServerSspiDataNtlm now checks for at least four input bytes before reading a cardinal. Breaking changes mormot.lib.gssapi+1 03373d42+46-61

lib: removed TServerSspiKeyTab.ComputeServerHeader

Impact

Applications that call ComputeServerHeader no longer compile. Short malformed SSPI/GSSAPI tokens are now rejected without an out-of-bounds cardinal read.

Migration required

Grep for TServerSspiKeyTab.ComputeServerHeader. Call KerberosServerAuthHeader instead; on POSIX call PrepareKeyTab first when using a specific keytab.

Public API

  • TServerSspiKeyTab.ComputeServerHeaderremoved — Use KerberosServerAuthHeader from mormot.net.client.
  • TServerSspiKeyTab.FileSetteradded

Arnaud Bouchez · 11:54 UTC · view the commit on GitHub →

3 High Async server shutdown now owns every connection exit path TAsyncConnections closes pending reads, waits workers and accept loops, releases tracked connections, permits final GC insertion and fixes ConnectionDelete and EndConnection ordering. Client request failure paths now abort transferred connections consistently. Fixes mormot.net.async+1 c87c00ab+92-50

net: avoid connection leaks in async server

Impact

Long-running Delphi and FPC async servers avoid leaked connection objects and sockets during shutdown, failed accepts and client setup errors. Destruction waits for worker ownership to settle before freeing shared state.

Arnaud Bouchez · 09:08 UTC · view the commit on GitHub →

4 High RTSP-over-HTTP setup cleans every partially owned connection TRtspOverHttpServer.ConnectionCreate tracks GET, POST and RTSP connection ownership explicitly and releases each object or raw RTSP socket in its finally block unless ownership was transferred successfully. Fixes mormot.net.rtsphttp 213dd8c6+50-33

net: fixed potential leaks in TRtspOverHttpServer

Impact

Failed or interrupted RTSP-over-HTTP pairing no longer leaks sockets and connection objects. Existing Delphi and FPC application APIs are unchanged.

Arnaud Bouchez · 08:15 UTC · view the commit on GitHub →

5 High Tunnel failure paths close both endpoint sockets TTunnelLocalThread.Destroy closes fServerSock and fClientSock, while TTunnelLocal.Open and OpenSocket use ShutdownAndClose and nil transferred sockets on exceptions and failed setup. Fixes mormot.net.tunnel 2eb90dbc+17-5

net: fixed FD socket leak in TTunnelLocal

Impact

Repeated failed tunnel openings no longer accumulate file descriptors or socket handles on POSIX, Delphi or FPC targets.

Arnaud Bouchez · 08:21 UTC · view the commit on GitHub →

6 High Async connection destruction closes sockets left by Stop TPollAsyncConnection.Destroy now releases fSecure, sets linger to immediate close and calls ShutdownAndClose when fSocket remains assigned after Stop. Fixes mormot.net.async 5707c869+19-2

net: fixed TPollAsyncConnection.Destroy

Impact

Destroying a partially stopped asynchronous connection no longer leaves its socket handle open. The fix applies to Delphi and FPC async backends.

Arnaud Bouchez · 07:43 UTC · view the commit on GitHub →

7 High Epoll unsubscribe closes sockets even when removal fails TPollSocketEpoll.Unsubscribe moves raw-socket closing outside the EPOLL_CTL_DEL success branch when fUnsubscribeShutdownSocket is set. It also closes when the epoll descriptor is already unavailable. Fixes mormot.net.sock 54de4647+11-10

net: fixed leaking socket FD in TPollSocketEpoll.Unsubscribe

Impact

Linux and other epoll-based servers no longer leak file descriptors when unsubscribe races with teardown or EPOLL_CTL_DEL fails. Windows and non-epoll backends are unaffected.

Arnaud Bouchez · 06:34 UTC · view the commit on GitHub →

8 High Delphi compilation is restored after the HTTP timeout refactor TCrtSocket constructors now call a protected virtual DoCreate method, and THttpClientSocket overrides DoCreate instead of redeclaring Create. This preserves subclass initialization without the constructor conflict seen by Delphi. Compiler & platform mormot.net.client+1 fd5b3409+24-24

net: fixed Delphi compilation of THttpClientSocket

Impact

The completed timeout series builds again with Delphi. FPC follows the same initialization path but did not require an application-code change.

Arnaud Bouchez · 21:12 UTC · view the commit on GitHub →

9 Medium Async connection rollback is centralized before registration The protected TAsyncConnections.ConnectionAbortAndNil method now clears a caller reference, preserves caller-owned sockets, closes registered connections through fSockets and directly frees instances that never registered. Fixes mormot.net.async 3742e9a7+62-25

net: new TAsyncConnections.ConnectionAbortAndNil method

Impact

Framework failure paths now use one ownership rule, reducing double-free and leak risks. The helper is protected and does not add a public application API.

Arnaud Bouchez · 08:09 UTC · view the commit on GitHub →

10 Medium Tunnel close no longer calls a missing transmit closure TTunnelLocal.SendFrame checks that fTransmit is assigned before sending the closing frame when the tunnel is terminating. Fixes mormot.net.tunnel fbb9dc6b+1-1

tun - fix nil transmit try to send frame

Impact

Tunnel teardown avoids a nil closure call in both Delphi and FPC builds. No application-code migration is required.

tprudhomme · 08:21 UTC · view the commit on GitHub →

11 Medium Sockets gain separate connect, send and receive timeouts TCrtSocket adds SetTimeouts and ConnectTimeout, and makes SendTimeout and ReceiveTimeout readable as well as writable. Connect, proxy, TLS, send and receive paths select the relevant phase value. New features mormot.net.sock 221f7715+181-81

net: introduce 3 specific timeouts to TCrtSocket

Impact

Delphi and FPC code can tune slow connection setup separately from request and response I/O. Existing code using TimeOut continues to provide the default when phase values stay zero.

Worth a look

Public API

  • TCrtSocket.SetTimeoutsadded
  • TCrtSocket.ConnectTimeoutadded
  • TCrtSocket.SendTimeoutbehaviour-changed — The property is now readable as well as writable.
  • TCrtSocket.ReceiveTimeoutbehaviour-changed — The property is now readable as well as writable.

Arnaud Bouchez · 16:32 UTC · view the commit on GitHub →

12 Medium One Kerberos HTTP helper now serves Windows and POSIX KerberosServerAuthHeader moves the single-roundtrip Negotiate helper to mormot.net.client, rejects NTLM, and is used by server authorization on both SSPI and GSSAPI. NOKERBEROSCLIENT can exclude the helper. New features mormot.lib.gssapi+3 0bc90ef6+79-75

net: new HTTP "Negotiate" KerberosServerAuthHeader() wrapper

Impact

Custom Delphi and FPC HTTP servers can use one public helper across Windows and POSIX. It supports only a simple two-message Kerberos exchange, not NTLM or multi-round negotiation.

Worth a look

Public API

  • KerberosServerAuthHeaderadded — Final cross-platform name in mormot.net.client.

Arnaud Bouchez · 12:18 UTC · view the commit on GitHub →

13 Medium Extended HTTP options carry three independent timeout values THttpRequestExtendedOptions adds ConnectTimeoutMS, SendTimeoutMS, ReceiveTimeoutMS and GetTimeouts. Serialization uses tm, tc, ts and tr fields, and HTTP backends consume the resolved values when opening requests. New features mormot.net.client ad936f42+71-13

net: extended THttpRequestExtendedOptions to include the timeouts

Impact

Delphi and FPC applications can configure request phases separately while existing zeroed records continue to fall back through CreateTimeoutMS and backend defaults.

Worth a look

Public API

  • THttpRequestExtendedOptions.ConnectTimeoutMSadded
  • THttpRequestExtendedOptions.SendTimeoutMSadded
  • THttpRequestExtendedOptions.ReceiveTimeoutMSadded
  • THttpRequestExtendedOptions.GetTimeoutsadded

Arnaud Bouchez · 17:11 UTC · view the commit on GitHub →

14 Medium REST socket clients apply phase timeouts consistently TRestHttpClientSocket stores timeout values in fExtendedOptions, passes them through OpenOptions before connecting, and compares them when deciding whether a socket can be reused. TCrtSocket getters now use TimeOut only when the phase value is 0. New featuresinterp mormot.net.sock+1 50ade795+46-36

rest: properly use new THttpClientSocket timeouts

Impact

REST clients can keep connection, send and receive policies distinct through reconnects. A negative live TCrtSocket phase value no longer selects the legacy fallback in the final implementation.

Worth a look

Use 0 for legacy fallback and test reconnect behavior where phase-specific values are configured.

Arnaud Bouchez · 21:06 UTC · view the commit on GitHub →

15 Medium REST SSPI authentication can select a POSIX keytab On POSIX, TRestServerAuthenticationSspi adds a KeyTab property backed by TServerSspiKeyTab. Setting a valid file initializes GSSAPI credentials and Idle refreshes changed keytab files. New features mormot.rest.server be652e42+30-2

rest: optional TRestServerAuthenticationSspi.KeyTab support with GSSAPI

Impact

POSIX REST servers can use an explicit and hot-refreshable keytab instead of relying only on default GSSAPI credentials. Windows SSPI behavior is unchanged.

Worth a look

Public API

  • TRestServerAuthenticationSspi.KeyTabadded — Available on POSIX builds.

Arnaud Bouchez · 11:57 UTC · view the commit on GitHub →

16 Medium REST clients install timeout policy before connecting TRestHttpClientSocket now creates and configures THttpClientSocket before Connect, so connect, proxy and TLS setup receive the intended timeouts instead of only later I/O. New features mormot.rest.http.client 29dc590a+17-6

rest: enhance TRestHttpClientSocket to use the new timeouts

Impact

REST connections can time out independently during connection establishment, writes and reads on both Delphi and FPC backends.

Worth a look

Arnaud Bouchez · 16:45 UTC · view the commit on GitHub →

17 Medium Async servers wake poll loops as soon as shutdown begins TAsyncConnections.Destroy marks fSockets terminated before waiting and wakes POSIX read and write pollers. Related HTTP and proxy shutdown paths stop waiting for normal poll timeouts. Performance mormot.net.async+1 2b1b93ae+9-4

net: faster async server shutdown

Impact

POSIX async servers and proxy clients should terminate faster and more predictably. Delphi Windows IOCP builds do not use these poll wake-up branches.

Arnaud Bouchez · 12:44 UTC · view the commit on GitHub →

18 Medium HTTP sockets reuse the base socket timeout implementation THttpClientSocket removes duplicate timeout fields and setters and uses the inherited TCrtSocket timeout storage. Header waits now use ReceiveTimeout, while connection and TLS setup use ConnectTimeout. Under the hood mormot.net.client 9a5f322d+47-74

net: THttpClientSocket can directly use the new TCrtSocket timeouts

Impact

Existing HTTP clients keep the same class surface while timeout reads and writes now share the base implementation. Applications that tune timeouts should exercise connection and response-header waits.

Worth a look

Arnaud Bouchez · 16:38 UTC · view the commit on GitHub →

19 Low Tunnel sends recheck the transmit callback before use TTunnelLocal.SendFrame now requires Assigned(fTransmit) before invoking the callback, including the closing-frame path. Fixes mormot.net.tunnel 2ccea1a0+6-5

net: minor hardening of TTunnelLocal.SendFrame

Impact

A tunnel whose transmit callback has already been cleared avoids a nil callback invocation. No application-code change is required for Delphi or FPC.

Arnaud Bouchez · 14:41 UTC · view the commit on GitHub →

20 Low Cross-platform Negotiate parsing is extracted from the HTTP server A first ServerSspiAuthHeader implementation factors Authorization header parsing, Base64 decoding, NTLM rejection and SSPI/GSSAPI response generation out of THttpServerSocketGeneric.Authorization. New features mormot.lib.gssapi+2 9029fa16+59-2

net: new ServerSspiAuthHeader() cross-platform wrapper function

Impact

This is an intermediate public name in the same edition; the final API is KerberosServerAuthHeader in mormot.net.client. Applications should not adopt the temporary name.

Arnaud Bouchez · 11:52 UTC · view the commit on GitHub →

21 Low HTTP Negotiate authorization delegates to the shared helper THttpServerSocketGeneric.Authorization replaces its inline SSPI/GSSAPI parsing with the shared authentication-header helper and centralizes SspiKeyTab accessors. Under the hood mormot.net.server 71011fb6+11-48

net: simplified THttpServerSocketGeneric.Authorization NEGOTIATE support

Impact

Built-in HTTP Negotiate behavior is consolidated without an application-code change. Windows and POSIX follow the same single-roundtrip decision path.

Arnaud Bouchez · 11:55 UTC · view the commit on GitHub →

22 Low Async connection flag now describes registration accurately The internal TPollAsyncConnectionFlags value fInList is renamed fRegistered, and all registration, removal and recycling checks use the new name. Under the hood mormot.net.async c7708e55+14-13

net: renamed misleading TPollAsyncConnectionFlags fInList item

Impact

No public API or runtime behavior changes. The rename makes connection ownership checks easier to audit in Delphi and FPC source builds.

Arnaud Bouchez · 09:27 UTC · view the commit on GitHub →

23 Low Shared byte-indexed cardinal table replaces local aliases mormot.core.base publishes TByteToCardinal and several formatting, Unicode, security, cryptography and HTTP routines reuse it. PurgeHeaders also checks P rather than the stale h pointer before reading header length. Under the hood mormot.core.base+6 066e5953+13-12

core: new TByteToCardinal type definition

Impact

Application behavior is unchanged apart from the small PurgeHeaders guard correction. The shared type is available to Delphi and FPC callers that need a 256-entry cardinal lookup table.

Public API

  • TByteToCardinaladded

Arnaud Bouchez · 09:32 UTC · view the commit on GitHub →

24 Low Async shutdown tests cover idle, partial and pending traffic test.net.proto expands async-process coverage for idle sockets, partial headers and bodies, large writes, slow clients and disabled connection tracking. TPollSockets.Pending is exposed for assertions, and TPollAsyncSockets.PollWrite is corrected to a read accessor. Tests mormot.net.async+2 a84c77d1+179-111

test: enhanced async process coverage

Impact

Production behavior is unchanged by the tests. Code that previously could not read PollWrite can now inspect it on non-IOCP builds.

Public API

  • TPollSockets.Pendingadded
  • TPollAsyncSockets.PollWritebehaviour-changed — Its accessor is now read fWrite instead of write fWrite.

Arnaud Bouchez · 12:58 UTC · view the commit on GitHub →

25 Low Issue 633 shutdown scenario becomes a regression test test.net.proto adds the reported asynchronous HTTP shutdown pattern and verifies that idle, slow and pending clients are closed when the server instance is freed. Tests test.net.proto 02bd02a7+96-2

test: include regression code from #633

Impact

Production units and public APIs are unchanged. The test protects the preceding connection-leak repair on Delphi and FPC test runs.

Arnaud Bouchez · 09:19 UTC · PR #633 · view the commit on GitHub →

Upstream activity commits per day · last 60 days
Commits977
Active days44/60
Busiest2026-09-30
Peak60
2026-08-15: 0 commits2026-08-16: 0 commits2026-08-17: 0 commits2026-08-18: 0 commits2026-08-19: 0 commits2026-08-20: 0 commits2026-08-21: 0 commits2026-08-22: 0 commits2026-08-23: 0 commits2026-08-24: 0 commits2026-08-25: 0 commits2026-08-26: 0 commits2026-08-27: 26 commits2026-08-28: 11 commits2026-08-29: 10 commits2026-08-30: 1 commit2026-08-31: 23 commits2026-09-01: 0 commits2026-09-02: 20 commits2026-09-03: 29 commits2026-09-04: 35 commits2026-09-05: 13 commits2026-09-06: 0 commits2026-09-07: 0 commits2026-09-08: 23 commits2026-09-09: 10 commits2026-09-10: 17 commits2026-09-11: 23 commits2026-09-12: 14 commits2026-09-13: 9 commits2026-09-14: 7 commits2026-09-15: 4 commits2026-09-16: 24 commits2026-09-17: 26 commits2026-09-18: 21 commits2026-09-19: 59 commits2026-09-20: 13 commits2026-09-21: 5 commits2026-09-22: 34 commits2026-09-23: 17 commits2026-09-24: 57 commits2026-09-25: 22 commits2026-09-26: 26 commits2026-09-27: 0 commits2026-09-28: 2 commits2026-09-29: 19 commits2026-09-30: 60 commits2026-10-01: 26 commits2026-10-02: 30 commits2026-10-03: 32 commits2026-10-04: 15 commits2026-10-05: 1 commit2026-10-06: 26 commits2026-10-07: 37 commits2026-10-08: 27 commits2026-10-09: 35 commits2026-10-10: 33 commits2026-10-11: 9 commits2026-10-12: 11 commits2026-10-13: 35 commits
2026-08-152026-10-13