uint32 THREADCALL SocketMgr::SocketWorkerThread(void * lpParam) { SocketMgr *socketMgr = (SocketMgr *)lpParam; HANDLE cp = socketMgr->GetCompletionPort(); DWORD len; Socket * s = nullptr; OverlappedStruct * ov = nullptr; LPOVERLAPPED ol_ptr; while (socketMgr->m_bWorkerThreadsActive) { if (!GetQueuedCompletionStatus(cp, &len, (LPDWORD)&s, &ol_ptr, INFINITE)) { if (s != nullptr) s->Disconnect(); continue; } ov = CONTAINING_RECORD(ol_ptr, OverlappedStruct, m_overlap); if (ov->m_event == SOCKET_IO_THREAD_SHUTDOWN) { delete ov; return 0; } if (ov->m_event < NUM_SOCKET_IO_EVENTS) ophandlers[ov->m_event](s, len); } return 0; }
DWORD WINAPI SocketWorkerThread(LPVOID lpParam) { SocketMgr *socketMgr = (SocketMgr *)lpParam; HANDLE cp = socketMgr->GetCompletionPort(); DWORD len; Socket * s; OverlappedStruct * ov; LPOVERLAPPED ol_ptr; while (true) { #ifndef _WIN64 if (!GetQueuedCompletionStatus(cp, &len, (LPDWORD)&s, &ol_ptr, INFINITE)) #else if (!GetQueuedCompletionStatus(cp, &len, (PULONG_PTR)&s, &ol_ptr, INFINITE)) #endif { if (s != NULL) s->Disconnect(); continue; } ov = CONTAINING_RECORD(ol_ptr, OverlappedStruct, m_overlap); if (ov->m_event == SOCKET_IO_THREAD_SHUTDOWN) { delete ov; return 0; } if (ov->m_event < NUM_SOCKET_IO_EVENTS) ophandlers[ov->m_event](s, len); } return 0; }