Pipe Reader Thread: Server
| 61 | |
| 62 | // Pipe Reader Thread: Server |
| 63 | DWORD WINAPI PplReaderThread(LPVOID param) { |
| 64 | LOG_A(LOG_DEBUG, "!Ppl ReaderThread: begin"); |
| 65 | |
| 66 | // Loop which accepts new clients |
| 67 | while (WaitForSingleObject(hStopEventPpl, 0) != WAIT_OBJECT_0) { |
| 68 | PipeServer* pipeServer = new PipeServer("RedEdr PplReader", (wchar_t*) PPL_DATA_PIPE_NAME); |
| 69 | if (pipeServer == nullptr) { |
| 70 | LOG_A(LOG_ERROR, "PplReader: Failed to create PipeServer"); |
| 71 | Sleep(1000); // Brief delay before retry |
| 72 | continue; |
| 73 | } |
| 74 | // Signal that the thread is ready |
| 75 | SetEvent(threadReadynessPpl); |
| 76 | |
| 77 | if (!pipeServer->StartAndWaitForClient(TRUE)) { |
| 78 | LOG_A(LOG_ERROR, "PplReader: Failed to start pipe server or wait for client"); |
| 79 | pipeServer->Shutdown(); |
| 80 | delete pipeServer; |
| 81 | Sleep(1000); // Brief delay before retry |
| 82 | continue; |
| 83 | } |
| 84 | |
| 85 | LOG_A(LOG_INFO, "PplReader: Client connected successfully"); |
| 86 | |
| 87 | // Handle it here |
| 88 | PplReaderClient(pipeServer); |
| 89 | |
| 90 | // We finished |
| 91 | LOG_A(LOG_INFO, "PplReader: Client disconnected, shutting down this pipe"); |
| 92 | pipeServer->Shutdown(); |
| 93 | delete pipeServer; |
| 94 | } |
| 95 | |
| 96 | LOG_A(LOG_DEBUG, "!Ppl ReaderThread: end"); |
| 97 | return 0; |
| 98 | } |
| 99 | |
| 100 | |
| 101 | // Pipe Reader Thread: Process Client |
nothing calls this directly
no test coverage detected