Worth a looka fix or feature you may want
THttpServer thread-pool lifecycle callbacks restored
THttpServer now forwards its thread-start callback to the internal worker pool. This restores both OnHttpThreadStart and OnHttpThreadTerminate for pooled workers, which matters to applications that allocate and release per-thread state.
TL;DR
- TSynThreadPoolTHttpServer now copies THttpServer.fOnThreadStart before creating its worker threads.
- Pooled THttpServer workers once again run the paired start and termination callbacks; request processing and public signatures are unchanged.
Upgrade advice
Land on build 18239 at cb0cf6a7a53b9c8d3b3b9ab3f63509b4e23126ba. It contains the lifecycle-callback fix, and the payload lists no later same-routine fix in superseded_by.
1 of 1 entries · 3 commits upstream
1
Medium
THttpServer pooled workers now receive start and termination notifications
In mormot.net.server, TSynThreadPoolTHttpServer.Create now copies fServer.fOnThreadStart into the pool's fOnThreadStart field, alongside the existing fOnThreadTerminate copy. TSynThreadPoolWorkThread.Execute can therefore call the configured start handler and set StartNotified; TSynThread.DoTerminate then permits the matching termination handler to run.
Fixes
mormot.net.server
40e03307+1-0
net: THttpServer OnThreadStart/OnThreadTerminate events were never called for its thread pool
Impact
Before this fix, Delphi and FPC applications using the socket-based THttpServer thread pool did not receive OnHttpThreadStart for pooled workers. Because StartNotified remained unset, OnHttpThreadTerminate was skipped as well, so per-thread initialization and cleanup such as TRest.EndCurrentThread could be missed. Applications without these handlers, and non-pooled server implementations, keep their existing behaviour.
Upgrade recommended
Upgrade to build 18239 and verify that each pooled THttpServer worker produces one paired OnHttpThreadStart and OnHttpThreadTerminate call during server startup and shutdown.
Public API
THttpServerGeneric.OnHttpThreadStartbehaviour-changed — The existing event now fires for TSynThreadPoolTHttpServer workers instead of being silently skipped.THttpServerGeneric.OnHttpThreadTerminatebehaviour-changed — The existing event now follows a successful pooled-worker start notification because StartNotified is set.