diff options
| author | Stefan Boberg <[email protected]> | 2026-03-16 11:59:25 +0100 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2026-03-16 11:59:25 +0100 |
| commit | 6929aad0f017ab5faf3d4c6c812d8881a741a28d (patch) | |
| tree | 436753d3ad847641d79700286853fbd67c19be43 | |
| parent | Merge branch 'main' into sb/threadpool (diff) | |
| download | zen-6929aad0f017ab5faf3d4c6c812d8881a741a28d.tar.xz zen-6929aad0f017ab5faf3d4c6c812d8881a741a28d.zip | |
Fix WsHttpSysConnection to use WinIoThreadPool abstraction instead of raw PTP_IO
The WebSocket http.sys code from main used PTP_IO directly, which conflicts
with the threadpool refactoring that abstracts I/O behind WinIoThreadPool.
| -rw-r--r-- | src/zenhttp/servers/httpsys.cpp | 2 | ||||
| -rw-r--r-- | src/zenhttp/servers/wshttpsys.cpp | 13 | ||||
| -rw-r--r-- | src/zenhttp/servers/wshttpsys.h | 9 |
3 files changed, 15 insertions, 9 deletions
diff --git a/src/zenhttp/servers/httpsys.cpp b/src/zenhttp/servers/httpsys.cpp index 2074fbd79..67a71c0cc 100644 --- a/src/zenhttp/servers/httpsys.cpp +++ b/src/zenhttp/servers/httpsys.cpp @@ -2588,7 +2588,7 @@ InitialRequestHandler::HandleCompletion(ULONG IoResult, ULONG_PTR NumberOfBytesT Ref<WsHttpSysConnection> WsConn(new WsHttpSysConnection(RequestQueueHandle, RequestId, *WsHandler, - Transaction().Iocp(), + *Transaction().Server().m_IoThreadPool, &Transaction().Server())); Ref<WebSocketConnection> WsConnRef(WsConn.Get()); diff --git a/src/zenhttp/servers/wshttpsys.cpp b/src/zenhttp/servers/wshttpsys.cpp index af320172d..6abf805ec 100644 --- a/src/zenhttp/servers/wshttpsys.cpp +++ b/src/zenhttp/servers/wshttpsys.cpp @@ -4,6 +4,7 @@ #if ZEN_WITH_HTTPSYS +# include "iothreadpool.h" # include "wsframecodec.h" # include <zencore/logging.h> @@ -23,12 +24,12 @@ WsHttpSysLog() WsHttpSysConnection::WsHttpSysConnection(HANDLE RequestQueueHandle, HTTP_REQUEST_ID RequestId, IWebSocketHandler& Handler, - PTP_IO Iocp, + WinIoThreadPool& IoThreadPool, HttpServer* Server) : m_RequestQueueHandle(RequestQueueHandle) , m_RequestId(RequestId) , m_Handler(Handler) -, m_Iocp(Iocp) +, m_IoThreadPool(IoThreadPool) , m_HttpServer(Server) , m_ReadBuffer(8192) { @@ -98,7 +99,7 @@ WsHttpSysConnection::IssueAsyncRead() ZeroMemory(&m_ReadIoContext.Overlapped, sizeof(OVERLAPPED)); - StartThreadpoolIo(m_Iocp); + m_IoThreadPool.StartIo(); ULONG Result = HttpReceiveRequestEntityBody(m_RequestQueueHandle, m_RequestId, @@ -110,7 +111,7 @@ WsHttpSysConnection::IssueAsyncRead() if (Result != NO_ERROR && Result != ERROR_IO_PENDING) { - CancelThreadpoolIo(m_Iocp); + m_IoThreadPool.CancelIo(); m_OutstandingOps.fetch_sub(1, std::memory_order_relaxed); if (m_IsOpen.exchange(false)) @@ -315,7 +316,7 @@ WsHttpSysConnection::FlushWriteQueue() ZeroMemory(&m_WriteIoContext.Overlapped, sizeof(OVERLAPPED)); - StartThreadpoolIo(m_Iocp); + m_IoThreadPool.StartIo(); ULONG Result = HttpSendResponseEntityBody(m_RequestQueueHandle, m_RequestId, @@ -330,7 +331,7 @@ WsHttpSysConnection::FlushWriteQueue() if (Result != NO_ERROR && Result != ERROR_IO_PENDING) { - CancelThreadpoolIo(m_Iocp); + m_IoThreadPool.CancelIo(); m_OutstandingOps.fetch_sub(1, std::memory_order_relaxed); ZEN_LOG_DEBUG(WsHttpSysLog(), "WebSocket async write failed: {}", Result); diff --git a/src/zenhttp/servers/wshttpsys.h b/src/zenhttp/servers/wshttpsys.h index 6015e3873..7b10fe563 100644 --- a/src/zenhttp/servers/wshttpsys.h +++ b/src/zenhttp/servers/wshttpsys.h @@ -20,6 +20,7 @@ namespace zen { class HttpServer; +class WinIoThreadPool; /** * WebSocket connection over an http.sys opaque-mode connection @@ -39,7 +40,11 @@ class HttpServer; class WsHttpSysConnection : public WebSocketConnection { public: - WsHttpSysConnection(HANDLE RequestQueueHandle, HTTP_REQUEST_ID RequestId, IWebSocketHandler& Handler, PTP_IO Iocp, HttpServer* Server); + WsHttpSysConnection(HANDLE RequestQueueHandle, + HTTP_REQUEST_ID RequestId, + IWebSocketHandler& Handler, + WinIoThreadPool& IoThreadPool, + HttpServer* Server); ~WsHttpSysConnection() override; /** @@ -76,7 +81,7 @@ private: HANDLE m_RequestQueueHandle; HTTP_REQUEST_ID m_RequestId; IWebSocketHandler& m_Handler; - PTP_IO m_Iocp; + WinIoThreadPool& m_IoThreadPool; HttpServer* m_HttpServer; // Tagged OVERLAPPED contexts for concurrent read and write |