Act nowcan affect a running systemTCrtSocket documentation says negative phase timeouts restore TimeOut, but the final getters fall back only when the stored value is 0. This review therefore recommends 0 for live-socket fallback; the exact runtime effect of a negative value is backend-specific.
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.
25 of 25 entries · 26 commits upstream
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.
Upgrade recommended
Prioritize this update for POSIX and other non-IOCP asynchronous workloads, then stress queued work during worker idle transitions.
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
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.
Upgrade recommended
Upgrade async servers and test destruction with idle clients, partial requests, pending writes and acoNoConnectionTrack.
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.
Upgrade recommended
Exercise failed GET/POST pairing and interrupted RTSP setup while monitoring socket and object counts.
Units
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.
Upgrade recommended
Stress failed Open and OpenSocket attempts and verify descriptor counts return to baseline.
Units
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.
Upgrade recommended
Include this destructor fix when deploying the broader async ownership changes.
Units
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.
Upgrade recommended
On epoll deployments, monitor open file descriptors while repeatedly starting and stopping async services.
Units
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.
Upgrade recommended
Use build 2.4.17398 or later if you took any of the new timeout commits.
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.
Units
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.
Upgrade recommended
Take this fix with the surrounding tunnel cleanup commits before testing tunnel teardown.
Units
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.SetTimeoutsaddedTCrtSocket.ConnectTimeoutaddedTCrtSocket.SendTimeoutbehaviour-changed — The property is now readable as well as writable.TCrtSocket.ReceiveTimeoutbehaviour-changed — The property is now readable as well as writable.
Units
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.
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.ConnectTimeoutMSaddedTHttpRequestExtendedOptions.SendTimeoutMSaddedTHttpRequestExtendedOptions.ReceiveTimeoutMSaddedTHttpRequestExtendedOptions.GetTimeoutsadded
Units
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.
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.
Units
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
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.
Upgrade recommended
Retest POSIX server shutdown latency and confirm read and write pollers exit promptly.
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
Units
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.
Units
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.
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.
Units
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.
Units
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
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.PendingaddedTPollAsyncSockets.PollWritebehaviour-changed — Its accessor is now read fWrite instead of write fWrite.
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.