mORMot2 DailyDaily read of upstream commits

Async uploads stop growing without bound

This is a dense networking and concurrency edition. Async HTTP reads are now bounded before request processing, Digest authentication accepts valid empty parameters, and Date, delayed-response and thread-completion paths receive targeted fixes. Two network extractions also require uses-clause changes for peer-cache and Windows http.sys applications, while Delphi POSIX locking gains its non-recursive pthread implementation and an alignment follow-up.

TL;DR

  • TPollAsyncSockets.ReadMaxBytes defaults to 1 MB, preventing fast or endless uploads from filling process memory before OnRead runs.
  • THttpPeerCache moves to mormot.net.peercache, while THttpApiServer and THttpApiWebSocketServer move to mormot.net.server.win; direct users must update uses clauses.
  • Digest challenges with an empty optional value such as opaque="" now produce an Authorization header instead of remaining in a 401 loop.
  • Delphi POSIX TOSLightLock now uses a non-recursive pthread mutex and should be taken with the pointer-alignment follow-up.
  • Async Date generation, delayed AsyncResponse handling and TLoggedThread.WaitFinished each receive focused correctness fixes.

Upgrade advice

For this batch, land on merged head 751c1a03af59f7b3d9a2430f18f9e93d766592f5 at 2.4.17963. Do not take the mormot.net.server.win extraction without the later 9f810c80 conditional fix, and take the Delphi POSIX lock change together with c280a10c alignment. Update affected uses clauses, rebuild every Delphi/FPC target, and stress async uploads, Date headers and delayed responses.

Build2.4.17934 → 2.4.17963
Commits29
Lines+12152 -11014
Read8 min

21 of 21 entries · 29 commits upstream

Stories
# Entry Category Units
1 High Peer-cache types move out of mormot.net.server The complete THttpPeerCache section, including THttpPeerCrypt and its initialization assertion, moves unchanged from mormot.net.server to the new mormot.net.peercache unit. Lazarus package metadata, the mormot2 umbrella unit, mget, tests and documentation now import or list the new unit. Breaking changes mormot.net.peercache+2 506dd5c2+2919-2833

net: new mormot.net.peercache unit extracted from mormot.net.server (#737)

Impact

Delphi and FPC application units that list only mormot.net.server and directly reference peer-cache declarations will stop compiling until mormot.net.peercache is added to uses. Code that imports the mormot2 umbrella unit receives it automatically. The move is described and shown as structural, with no peer protocol or cache behavior change.

Migration required

Search uses clauses and qualified references for THttpPeerCache and THttpPeerCrypt. Add mormot.net.peercache to every affected unit, then rebuild Delphi, FPC and Lazarus package targets.

Public API

  • THttpPeerCacheremoved — The type is no longer declared by mormot.net.server; it is declared by mormot.net.peercache.
  • THttpPeerCryptremoved — The peer-cache frame type moves with THttpPeerCache to mormot.net.peercache.

zen010101 · 23:55 UTC · PR #737 · view the commit on GitHub →

2 High Windows http.sys servers move to mormot.net.server.win The THttpApiServer and THttpApiWebSocketServer interface and implementation sections move from mormot.net.server to the new mormot.net.server.win unit. Framework consumers, package metadata, tests and documentation add the new unit. Request code reaches the same server instance through the existing api field instead of the former cross-unit protected access. Breaking changes mormot.net.server+3 653e2fd8+2611-2524

net: new mormot.net.server.win unit extracted from mormot.net.server (#737)

Impact

Windows Delphi and FPC code that imports only mormot.net.server for http.sys classes will fail to compile until mormot.net.server.win is added. POSIX builds see a void unit. Runtime http.sys behavior is intended to remain unchanged, but the later conditional fix in 9f810c80e2c6e17a165423a5c57e5ad96090fdeb belongs with this extraction.

Migration required

Search for THttpApiServer, THttpApiWebSocketServer and mormot.net.server in application uses clauses. Add mormot.net.server.win on Windows http.sys paths and take the later 9f810c80 conditional correction before rebuilding.

Public API

  • THttpApiServerremoved — The public type moves from mormot.net.server to mormot.net.server.win.
  • THttpApiWebSocketServerremoved — The public type moves from mormot.net.server to mormot.net.server.win.

zen010101 · 09:22 UTC · PR #737 · view the commit on GitHub →

3 High Async reads are capped before request processing TPollAsyncSockets gains the public ReadMaxBytes property, initialized to 1 MB. ProcessRead now stops its recv loop when the next 32 KB block would cross that limit, calls OnRead, and leaves remaining input in the socket buffer for the next notification. A regression test streams a 16 MB HTTP body and checks the largest block delivered to the download stream. Fixes mormot.net.async 57ff422a+114-2

net: TPollAsyncSockets.ProcessRead() won't buffer more than ReadMaxBytes

Impact

Fast clients can no longer make an async HTTP connection accumulate an entire large or endless body before OnBodyDownload and MaximumAllowedContentLength run. The upstream measurements drop a 300 MB upload from 562 MB peak RSS to about 8 MB. Delphi and FPC servers inherit the 1 MB default; applications can tune ReadMaxBytes if their latency and throughput profile needs another block size.

Public API

  • TPollAsyncSockets.ReadMaxBytesadded — Sets the maximum bytes buffered by ProcessRead between OnRead calls; the default is 1 MB.

zen010101 · 18:24 UTC · view the commit on GitHub →

4 High http.sys extraction now follows the right feature flag mormot.net.server.win now wraps its content with USEHTTPSYS instead of USEWININET and supplies a valid empty implementation otherwise. Stale WinHTTP imports are removed from mormot.net.server and mormot.net.peercache. Tests switch their http.sys uses and methods to USEHTTPSYS while keeping USEWININET only where the WinHTTP client is required. Fixes mormot.net.server.win+2 9f810c80+25-27

net: fixed USEHTTPSYS / USEWININET conditional usage

Impact

Builds whose WinHTTP client and http.sys server selections differ no longer expose or hide the new Windows server unit under the wrong define. This is especially relevant after the unit extraction: without it, valid Windows configurations could compile the wrong surface or fail. POSIX remains a void-unit path.

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

5 High Digest authentication accepts empty quoted parameters TDigestProcess.Parse no longer rejects an empty value returned by GetNextItem, so valid fields such as opaque="" remain in the parsed challenge. DigestServerAuth still rejects empty mandatory client fields. Regression tests use two real IP-camera challenge layouts and verify the generated RFC 7616 response digest. Fixes mormot.crypt.secure d5b3c601+44-3

crypt: TDigestProcess.Parse() accepts a void parameter value

Impact

THttpClientSocket.AuthorizeDigest can now send an Authorization header to devices that advertise an empty optional Digest parameter, instead of returning an empty result and remaining in a 401 loop. Existing server-side validation of mandatory fields is unchanged. The behavior applies to Delphi and FPC clients.

Public API

  • TDigestProcess.Parsebehaviour-changed — An empty quoted auth-param is accepted; mandatory field checks remain in DigestServerAuth.

zen010101 · 18:24 UTC · view the commit on GitHub →

6 High Async Date headers are protected from concurrent updates THttpAsyncServer adds fHttpDateNowUtcSafe. IdleEverySecond locks while replacing the cached fHttpDateNowUtc buffer, and AppendHttpDate takes the same lock while appending it to a response. Fixes mormot.net.async 4624eda3+7-2

net: fixed THttpAsyncServer.AppendHttpDate potential race

Impact

Concurrent async responses can no longer read the cached Date header while the idle thread rewrites it. This removes the reported race and the possibility of a torn or inconsistent HTTP Date line. Application APIs and both Delphi/FPC call sites remain unchanged.

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

7 Medium HttpDateNowUtc initializes its cache before first use HttpDateNowUtc now initializes the shared Value buffer under its lock when Value[0] is zero. Later refreshes compute a temporary value outside the lock and publish it only if the cached tick still matches, preventing obsolete calculations from overwriting newer data. Fixes mormot.core.datetime 7ba6029d+21-9

core: fixed HttpDateNowUtc() potential void value at startup

Impact

The first call at process startup no longer risks returning an empty HTTP Date value, and concurrent refreshes cannot publish an older computation over a newer tick. Existing Delphi and FPC code keeps the same HttpDateNowUtc signature.

Public API

  • HttpDateNowUtcbehaviour-changed — The cache is guaranteed to be initialized on the first call.

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

8 Medium Delayed async responses no longer pre-close on request flags THttpAsyncServer.AsyncResponse removes its local response-state selection and always calls c.DoResponse with soContinue. It no longer passes soClose merely because hfConnectionClose was present in the parsed request; DoResponse may still return soClose and trigger the existing close path. Fixes mormot.net.async 18fb44d1+3-8

net: fixed THttpAsyncServer.AsyncResponse

Impact

Applications using delayed THttpAsyncServer.AsyncResponse avoid the reported premature close behavior tied to the request's Connection flag. Connection closure still follows DoResponse's result, so the change is confined to the asynchronous response path and requires no source migration.

Public API

  • THttpAsyncServer.AsyncResponsebehaviour-changed — The method enters DoResponse with soContinue regardless of hfConnectionClose.

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

9 Medium Delphi POSIX pthread storage gains pointer alignment TPosixLightMutex changes from a 64-byte array to a record containing a pointer followed by seven PtrUInt values. The size remains sufficient for pthread_mutex_t while the record now carries pointer alignment. Fixes mormot.core.os c280a10c+7-3

core: ensure TPosixLightMutex is pointer-aligned on Delphi POSIX

Impact

The direct pthread mutex introduced for Delphi POSIX is no longer placed in byte-aligned storage. This is a correctness follow-up for Linux and Darwin targets; Windows and FPC layouts are unaffected, and application source does not change.

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

10 Medium WaitFinished reports threads that already stopped TLoggedThread.WaitFinished now exits only for a nil instance, initializes Result to not fProcessing, and returns immediately when processing has already ended. The waiting path and timeout normalization remain unchanged. Fixes mormot.core.threads 570c08a6+6-4

core: fixed TLoggedThread.WaitFinished

Impact

Callers no longer receive false when they ask about a TLoggedThread that is already finished. Delphi and FPC code using the Boolean result for shutdown or cleanup can now distinguish successful prior completion without another wait.

Public API

  • TLoggedThread.WaitFinishedbehaviour-changed — Returns true when the thread was already not processing.

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

11 Medium Encrypted tunnels can connect directly in process TTunnelLocal adds OpenDirect to perform the existing authenticated encrypted handshake while delivering plaintext to an in-process ITunnelTransmit instead of a local TCP socket. SendData accepts plaintext from that endpoint, preserves the 64 KB payload limit, serializes outbound frames and keeps AES-GCM IV order. Crypto state moves from TTunnelLocalThread to TTunnelLocal so socket and direct transports share the same path. New features mormot.net.tunnel+1 a2b3264b+290-125

net: new TTunnelLocal.OpenDirect() method

Impact

A backend can connect an in-process KVM or stand-alone VNC component to the tunnel without allocating a local listening port. Existing Open and OpenSocket callers keep their signatures, but their internal encryption ownership is refactored; the separate regression-test commit exercises direct bidirectional binary frames.

Worth a look

If adopting OpenDirect, provide live Transmit and LocalTransmit implementations, keep each SendData payload at or below 64 KB, and test handshake failure, closure and bidirectional ordering.

Public API

  • TTunnelLocal.OpenDirectadded — Opens a portless authenticated tunnel to an in-process ITunnelTransmit.
  • TTunnelLocal.SendDataadded — Sends up to 64 KB of plaintext through the direct or socket-backed tunnel.

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

12 Medium Delphi POSIX light locks become truly non-recursive On Delphi POSIX, TOSLightLock replaces the TRTLCriticalSection/TMonitor fallback with direct pthread_mutex_init, lock, trylock, unlock and destroy calls using default non-recursive attributes. The opaque TPosixLightMutex storage is sized for Linux and Darwin pthread_mutex_t, and the methods are not inlined because Posix.Pthread remains implementation-only. Compiler & platform mormot.core.os+1 d8a8b965+57-6

core: TOSLightLock is a non-recursive pthread mutex on Delphi POSIX

Impact

TryLock from the owning thread now fails and a nested Lock can deadlock, matching the documented TOSLightLock contract and other targets. Windows and FPC are unchanged. Delphi Linux, macOS, Android and iOS code that accidentally relied on recursive behavior needs review, and the later alignment follow-up c280a10c6f05071273a741ae3e7f134860dcadab should be taken with this change.

Worth a look

Audit Delphi POSIX paths for recursive TOSLightLock acquisition or a second TryLock by the owning thread, then test with the alignment follow-up c280a10c.

Public API

  • TOSLightLockbehaviour-changed — Delphi POSIX now enforces the documented non-recursive semantics.

zen010101 · 10:03 UTC · view the commit on GitHub →

13 Medium Socket HTTP servers ignore suffix-only byte ranges THttpRequestContext.ParseHeader now recognizes a Range only when bytes= is followed by a positive numeric offset. Forms such as bytes=100-200 and bytes=100- remain supported. A suffix-only form such as bytes=-10 no longer sets rfWantRange and falls through to a normal full response. Compiler & platform mormot.net.http 54411993+27-24

net: range: bytes=-10 fallback to 200 and the whole content

Impact

Socket-based HTTP servers now match the existing http.sys fallback for suffix ranges by returning status 200 with the whole content instead of treating the suffix as a range. Clients that depend on RFC suffix-range behavior will receive more data and must not assume a 206 response. Delphi and FPC server APIs are unchanged.

Worth a look

Check clients or media downloaders that send suffix-only Range headers. If partial tails are required, issue an explicit start offset or handle the full 200 response.

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

14 Low Binary test constants become code-page independent The Baudot decode table in mormot.core.buffers and the BSON reference bytes in test.core.data are rewritten as hexadecimal strings decoded with HexToBin. This avoids Delphi interpreting concatenated #nnn character escapes through a DBCS host code page. Compiler & platform mormot.core.buffers 2b487195+21-15

core: Baudot2Char and BSONAWESOMEBIN as hexadecimal constants decoded by HexToBin()

Impact

Baudot and BSON expected bytes remain identical, but Delphi builds on DBCS systems no longer depend on source-literal decoding. FPC and non-DBCS builds see no functional change.

zen010101 · 23:36 UTC · view the commit on GitHub →

15 Low Direct tunnels gain bidirectional regression coverage test.net.proto adds an in-process ITunnelTransmit receiver and a TunnelDirect scenario. It opens paired client/server direct tunnels, checks that no worker thread or port is used, sends binary frames in both directions, validates the frame counters and exercises shutdown. Tests 05fed0b1+122-12

test: include TTunnelLocal.OpenDirect() regression tests

Impact

No application code changes. The tests document and protect the new portless tunnel behavior for Delphi and FPC builds.

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

16 Low POSIX numeric tests compare doubles by ULP distance test.core.base adds SameWithin2Ulps and uses it for pure Pascal floating-point parsing paths. Exact bit comparisons remain for the x86-64 assembler path without FP80, while the fallback now accepts a difference of at most two ULPs. Tests b5c58707+32-6

tests: fixed double text expectations on Delphi POSIX

Impact

No production behavior changes. Delphi POSIX and other pure-Pascal test runs avoid false failures caused by tiny double-rounding differences.

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

17 Low CheckMatchAny failures now include their value TSynTestCase.CheckMatchAny replaces a bare Check(result) with CheckUtf8(result, '%=%', [msg, Value]). The same Boolean match is evaluated, but a failure now reports the caller message and actual RawUtf8 value. The commit also refreshes changelog wording. Tests mormot.core.test 4475ffd8+7-6

core: fixed TSynTestCase.CheckMatchAny

Impact

No backend behavior changes. Delphi and FPC test failures become easier to diagnose without changing match semantics.

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

18 Low PDF font tests accept an extra Windows LUTI table The reduced-font test now accepts search fields for either nine tables or ten tables. This covers Windows font versions that include LUTI and stores the inspected bytes in a RawUtf8 value before CheckMatchAny. Tests 4b742162+6-3

test: handle pdf fonts included in LUTI Windows versions

Impact

No PDF generation behavior changes. Test suites no longer reject a valid Windows font layout solely because LUTI adds one table.

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

19 Low Tunnel test literals avoid Delphi compilation hints Two binary TunnelDirect test payloads are built with HexToBin instead of mixed text and numeric character literals. The bytes remain video plus 00 80 FF and key plus 00 01 1B. Tests fd983d13+4-4

test: fixed Delphi compilation hints

Impact

No application or protocol behavior changes. Delphi test compilation is quieter while the same binary frames are exercised.

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

20 Low Crypto factory documentation names the new uses requirement CHANGELOG.md and SAD chapter 3 now list mormot.crypt.factory, distinguish it from mormot.crypt.secure and show both units in the high-level factory example. The changelog names the moved Rnd, Hash, Sign, Cipher, Asym, Cert, Store, ICryptCert and ICryptStore declarations. Docs d73d6142+7-4

docs: mention the mormot.crypt.factory extraction in CHANGELOG and SAD chapter 3

Impact

No code changes. Delphi and FPC developers receive an explicit migration reference for the source-level unit move published in the previous edition.

zen010101 · 16:54 UTC · view the commit on GitHub →

21 Low Network documentation clarifies feature flags and read limits The network README corrects the void-unit condition for mormot.net.server.win from USEWININET to USEHTTPSYS and adds THttpProxyServer to the async-unit inventory. A source comment records the 1 MB default purpose of fReadMaxBytes. Docs mormot.net.async 0cbde657+5-4

core: mostly comments/documentations precisions

Impact

No runtime or application-code change. The documentation now matches the conditional fix and the bounded-read default.

Arnaud Bouchez · 13:56 UTC · view the commit on GitHub →

Upstream activity commits per day · last 60 days
Commits1007
Active days49/60
Busiest2026-09-30
Peak60
2026-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: 12 commits2026-10-11: 2 commits2026-10-12: 40 commits2026-10-13: 31 commits2026-10-14: 23 commits2026-10-15: 16 commits2026-10-16: 27 commits2026-10-17: 0 commits2026-10-18: 0 commits2026-10-19: 0 commits2026-10-20: 0 commits2026-10-21: 0 commits2026-10-22: 3 commits2026-10-23: 6 commits2026-10-24: 29 commits2026-10-25: 7 commits2026-10-26: 25 commits2026-10-27: 4 commits2026-10-28: 8 commits2026-10-29: 17 commits2026-10-30: 20 commits2026-10-31: 0 commits2026-11-01: 0 commits2026-11-02: 16 commits2026-11-03: 32 commits2026-11-04: 15 commits2026-11-05: 32 commits2026-11-06: 26 commits2026-11-07: 19 commits2026-11-08: 2 commits2026-11-09: 29 commits2026-11-10: 17 commits2026-11-11: 8 commits2026-11-12: 38 commits2026-11-13: 39 commits2026-11-14: 9 commits2026-11-15: 6 commits2026-11-16: 21 commits2026-11-17: 30 commits2026-11-18: 37 commits2026-11-19: 28 commits2026-11-20: 31 commits2026-11-21: 0 commits2026-11-22: 0 commits2026-11-23: 1 commit2026-11-24: 6 commits2026-11-25: 3 commits2026-11-26: 3 commits2026-11-27: 0 commits2026-11-28: 0 commits
2026-09-302026-11-28