File tree 2 files changed +13
-4
lines changed
2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -44,19 +44,21 @@ void Logger::terminateSettingThread()
44
44
45
45
if (m_settingThread)
46
46
{
47
- m_runSettingThread = false ;
47
+ m_stopEvent-> notify () ;
48
48
49
49
m_settingThread->join ();
50
50
51
51
m_settingThread = nullptr ;
52
+
53
+ m_stopEvent = nullptr ;
52
54
}
53
55
}
54
56
55
57
void Logger::restartSettingThread ()
56
58
{
57
59
terminateSettingThread ();
58
60
59
- m_runSettingThread = true ;
61
+ m_stopEvent = std::make_unique<SelectableEvent>( 0 ) ;
60
62
61
63
m_settingThread.reset (new std::thread (&Logger::settingThread, this ));
62
64
}
@@ -195,8 +197,9 @@ void Logger::settingThread()
195
197
auto table = std::make_shared<SubscriberStateTable>(&db, CFG_LOGGER_TABLE_NAME);
196
198
selectables.emplace (CFG_LOGGER_TABLE_NAME, table);
197
199
select .addSelectable (table.get ());
200
+ select .addSelectable (m_stopEvent.get ());
198
201
199
- while (m_runSettingThread )
202
+ while (1 )
200
203
{
201
204
202
205
Selectable *selectable = nullptr ;
@@ -216,6 +219,11 @@ void Logger::settingThread()
216
219
continue ;
217
220
}
218
221
222
+ if (selectable == m_stopEvent.get ())
223
+ {
224
+ break ;
225
+ }
226
+
219
227
KeyOpFieldsValuesTuple koValues;
220
228
SubscriberStateTable *subscriberStateTable = NULL ;
221
229
subscriberStateTable = dynamic_cast <SubscriberStateTable *>(selectable);
Original file line number Diff line number Diff line change 10
10
#include < functional>
11
11
12
12
#include " concurrentmap.h"
13
+ #include " selectableevent.h"
13
14
14
15
namespace swss {
15
16
@@ -161,7 +162,7 @@ class Logger
161
162
std::atomic<Output> m_output = { SWSS_SYSLOG };
162
163
std::unique_ptr<std::thread> m_settingThread;
163
164
std::mutex m_mutex;
164
- volatile bool m_runSettingThread = true ;
165
+ std::unique_ptr<SelectableEvent> m_stopEvent ;
165
166
};
166
167
167
168
}
You can’t perform that action at this time.
0 commit comments