Skip to content

Commit 6b9bbbb

Browse files
author
Ben Hillis
committed
Switch MultiHandleWait and port relay from WaitForMultipleObjects to IO completion ports
Replace the WaitForMultipleObjects-based wait loop in relay::MultiHandleWait with an IO completion port (IOCP), removing the MAXIMUM_WAIT_OBJECTS (64) handle limit for all callers. Changes to relay::MultiHandleWait (relay.hpp/cpp): - Add unique_registered_wait RAII type for RegisterWaitForSingleObject handles - Add Register() pure virtual to OverlappedIOHandle, implemented by all subclasses - Handles that support IOCP (pipes, sockets) register directly; handles that don't (console handles, events) use a RegisterWaitForSingleObject bridge - Convert Run() to use GetQueuedCompletionStatus instead of WaitForMultipleObjects - Cancel() posts a key=0 completion to wake Run(); key=0 sets m_cancel on dequeue - Fix member order: m_iocp declared before m_handles for correct destruction Changes to port relay (localhost.cpp): - Replace AcceptThread's WaitForMultipleObjects with a direct IOCP: associate listen sockets via CreateIoCompletionPort, AcceptEx completions go straight to the IOCP, stop signal via PostQueuedCompletionStatus key=0 - Remove the MAXIMUM_WAIT_OBJECTS port limit check - Remove AcceptEvent from PortRelay (no longer needed with direct IOCP)
1 parent 337a116 commit 6b9bbbb

3 files changed

Lines changed: 356 additions & 181 deletions

File tree

0 commit comments

Comments
 (0)