Shutdown
| 130 | |
| 131 | // Shutdown |
| 132 | void PplReaderShutdown() { |
| 133 | LOG_A(LOG_INFO, "PPLReader: Shutdown"); |
| 134 | |
| 135 | // Signal stop |
| 136 | if (hStopEventPpl != NULL) { |
| 137 | SetEvent(hStopEventPpl); |
| 138 | } |
| 139 | |
| 140 | // Cancel any blocking I/O (ReceiveBatch or ConnectNamedPipe) on the worker thread |
| 141 | if (hPplThreadHandle != NULL) { |
| 142 | CancelSynchronousIo(hPplThreadHandle); |
| 143 | } |
| 144 | |
| 145 | // Wait for thread to exit cleanly |
| 146 | if (hPplThreadHandle != NULL) { |
| 147 | if (WaitForSingleObject(hPplThreadHandle, 5000) == WAIT_TIMEOUT) { |
| 148 | LOG_A(LOG_WARNING, "PplReader: Thread did not exit in time, force-terminating"); |
| 149 | TerminateThread(hPplThreadHandle, 1); |
| 150 | } |
| 151 | CloseHandle(hPplThreadHandle); |
| 152 | hPplThreadHandle = NULL; |
| 153 | } |
| 154 | |
| 155 | // Close event handles |
| 156 | if (hStopEventPpl != NULL) { |
| 157 | CloseHandle(hStopEventPpl); |
| 158 | hStopEventPpl = NULL; |
| 159 | } |
| 160 | if (threadReadynessPpl != NULL) { |
| 161 | CloseHandle(threadReadynessPpl); |
| 162 | threadReadynessPpl = NULL; |
| 163 | } |
| 164 | } |
no test coverage detected