Details
-
Task
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
None
-
10.1.31
Description
Specifically on Windows, server startup creates too many unnecessary threads. There is a thread that does nothing but waits for shutdown event, and possibly thread that handles socket connections, and possibly a thread that handles named pipe connections, and perhaps a thread that does shared memory connections. And there is a main thread that does nothing but waits for all other threads
None of that is necessary, does not look good and is prone to races (shutdown thread vs main thread for example).
It could be relatively easily rewritten to run in the main thread.
IOCP/ GetQueuedCompletionStatus loop in the main thread could handle l sockets and named pipe connections directly .Also waiting for events can be rewritten that they do not block current thread, RegisterWaitForSingleObject does that, and can be passed handler routine which forwards event to the main thread's completion port via PostQueuedCompletionStatus