From fced83a9da3531e0b6875c80714d47424449f29c Mon Sep 17 00:00:00 2001 From: Andrzej Lichnerowicz Date: Mon, 12 Mar 2018 16:20:31 +0100 Subject: [PATCH] Move timer objects to the end of member list In high CPU load it can happen, that Timer thread wakes up, is swapped out, and when application resumes it does not resume with timer thread, but transport thread, that decides to do failover, destroys `InactivityMonitor` object. When its members are getting destroyed, they arrive at `Timer` object that joins, timer thread resumes in `writeCheck` or `readCheck` method, only to find out `asyncTasks` is already destroyed because it comes later in member declaration list so it was destroyed first. Moving `Timer` object to the end of the list, guarantees that they will be destroyed first, so their threads will get joined and allowed to finish, before the rest of the object is destroyed. Closes AMQCPP-626 --- .../activemq/transport/inactivity/InactivityMonitor.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/activemq-cpp/src/main/activemq/transport/inactivity/InactivityMonitor.cpp b/activemq-cpp/src/main/activemq/transport/inactivity/InactivityMonitor.cpp index 022aca3bb..dd1babb97 100644 --- a/activemq-cpp/src/main/activemq/transport/inactivity/InactivityMonitor.cpp +++ b/activemq-cpp/src/main/activemq/transport/inactivity/InactivityMonitor.cpp @@ -72,9 +72,6 @@ namespace inactivity { Pointer readCheckerTask; Pointer writeCheckerTask; - Timer readCheckTimer; - Timer writeCheckTimer; - Pointer asyncTasks; Pointer asyncReadTask; @@ -98,6 +95,9 @@ namespace inactivity { bool keepAliveResponseRequired; + Timer readCheckTimer; + Timer writeCheckTimer; + InactivityMonitorData(const Pointer wireFormat) : wireFormat(wireFormat), localWireFormatInfo(),