mirror of
https://github.com/pocoproject/poco.git
synced 2026-01-10 16:08:36 +01:00
* fix(NotificationCenter): use RWLock to prevent lock-order-inversion #5150 Change NotificationCenter from Mutex to RWLock to fix TSAN lock-order-inversion warnings when notification handlers call back into the notification center (e.g., hasEventHandler() from within a SocketReactor handler). Key changes: - Replace Mutex with RWLock for better read concurrency - Use read locks for hasObserver(), observersToNotify(), hasObservers(), countObservers(), backlog() - Use write locks for addObserver(), removeObserver(), clear() - observersToNotify() now copies observer list and releases lock before calling accepts() to avoid lock cycle with NObserver's internal mutex - Add clear() method to atomically disable and remove all observers - Update AsyncNotificationCenter to use RWLock::ScopedLock Also fixes AsyncNotificationCenter shutdown to properly signal the dequeue thread via ShutdownNotification instead of relying only on wakeUpAll() #5058 * fix(Net): add SocketReactor::remove() for safe socket cleanup #5150 Add SocketReactor::remove() method that atomically removes a socket from the poll set and disables all its event handlers. This prevents race conditions when removing handlers in destructors, where events could still be dispatched to handlers while other handlers for the same socket are being removed. Changes: - Add SocketReactor::remove(socket) for atomic socket removal - Add SocketNotifier::disableObservers() to disable all handlers - Add SocketNotifier::socket() getter - Skip dispatch for removed sockets in dispatch() methods - Update tests to use remove() before removeEventHandler() - Add testSocketReactorRemove() test * fix(Foundation): improve ProcessRunner robustness #5054 - Fix race condition: set _pPH after _pid to ensure pid() returns valid value when running() returns true - Add upfront invalid PID validation before termination attempt - Escalate to Process::kill() if requestTermination times out, with its own timeout before throwing - Try to remove stale PID file on timeout instead of throwing - Wrap start() wait logic in try/catch to kill orphan process and reset state if startup fails - Clear _error under lock after successful stop to prevent stale error from affecting next start() * Update Net/include/Poco/Net/SocketReactor.h Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Foundation/src/AsyncNotificationCenter.cpp Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Foundation/include/Poco/AsyncNotificationCenter.h Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update Foundation/src/AsyncNotificationCenter.cpp Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * chore: add TaskManager::testCancel to win ignore list * chore: few improvements in NotificationCenter and ODBC cmake. --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Matej Kenda <matejken@gmail.com>