-
Notifications
You must be signed in to change notification settings - Fork 275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[logger] Make map access thread safe and proper terminate thread #510
Conversation
Signed-off-by: kcudnik <[email protected]>
test error on test_ConfigDBSubscribe not related to PR |
@arlakshm can you check this test_ConfigDBSubscribe ? |
common/logger.cpp
Outdated
|
||
m_settingThread = nullptr; | ||
|
||
m_runSettingThread = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might consider putting m_runSettingThread = true; in restartSettingThread? Not sure which is cleaner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved to restart
common/logger.cpp
Outdated
|
||
m_settingChangeObservers.get(key).first(key, value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: extra blank line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
linkToDb(dbName, swssPrioNotify, defPrio); | ||
logger.m_settingThread.reset(new std::thread(&Logger::settingThread, &logger)); | ||
|
||
getInstance().restartSettingThread(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is restarting the thread actually required if the thread is already started and the data structures are thread-safe? Put another way: is there any reason to maintain a separate linkToDbNative and linkToDb vs consolidating them into one function which starts the thread if needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thats a good question, im just fixing this instance here, since previously if you call linkToDbNative twice, it will crash, and whether we should have only 1 thread, not sure about that, this PR is just to make those maps thread safe + plus crahs bug fix not changing behavior, @qiluo-msft can you have opinion?
ping |
common/concurentmap.h
Outdated
namespace swss | ||
{ | ||
template <typename K, typename V> | ||
class ConcurentMap |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: typo (ConcurrentMap)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
ping |
1 similar comment
ping |
Signed-off-by: kcudnik [email protected]
Fixes sonic-net/sonic-buildimage#8177
I also made some minor code style refactoring