-
Notifications
You must be signed in to change notification settings - Fork 342
RedisPipeline ignore flush when call dtor from another thread. #736
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,10 @@ | |
| #include "rediscommand.h" | ||
| #include "dbconnector.h" | ||
|
|
||
| #include "unistd.h" | ||
| #include "sys/syscall.h" | ||
| #define gettid() syscall(SYS_gettid) | ||
|
|
||
| namespace swss { | ||
|
|
||
| class RedisPipeline { | ||
|
|
@@ -19,10 +23,16 @@ class RedisPipeline { | |
| , m_remaining(0) | ||
| { | ||
| m_db = db->newConnector(NEWCONNECTOR_TIMEOUT); | ||
| initializeOwnerTid(); | ||
| } | ||
|
|
||
| ~RedisPipeline() { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, I check all dtor in swss-common only find RedisPipeline class run redis command in dtor. |
||
| flush(); | ||
| if (m_ownerTid == gettid()) | ||
| { | ||
| // call flush from different thread will trigger race condition issue. | ||
| flush(); | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed |
||
|
|
||
| delete m_db; | ||
| } | ||
|
|
||
|
|
@@ -125,10 +135,16 @@ class RedisPipeline { | |
| return m_db; | ||
| } | ||
|
|
||
| void initializeOwnerTid() | ||
| { | ||
| m_ownerTid = gettid(); | ||
| } | ||
|
|
||
| private: | ||
| DBConnector *m_db; | ||
| std::queue<int> m_expectedTypes; | ||
| size_t m_remaining; | ||
| long int m_ownerTid; | ||
|
|
||
| void mayflush() | ||
| { | ||
|
|
||
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.
there is no wrapper for gettid() in glibc <= 2.30, so we need use syscall(SYS_gettid)