-
Notifications
You must be signed in to change notification settings - Fork 273
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
Add support of 'with' statement to ConfigDBConnector #838
Add support of 'with' statement to ConfigDBConnector #838
Conversation
117fbdd
to
b998b56
Compare
@@ -32,6 +32,11 @@ void DBInterface::close(const std::string& dbName) | |||
m_redisClient.erase(dbName); |
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 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.
The 'with' state will not call this method, it will call the map::clear(), and because m_redisClient not store pointer or reference, the dtor of RedisContext will be invoke by clear() and release redis connection:
RedisContext::~RedisContext()
{
if(m_conn)
redisFree(m_conn);
}
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.
Agree. The original comment is invalid.
common/dbinterface.cpp
Outdated
@@ -32,6 +32,11 @@ void DBInterface::close(const std::string& dbName) | |||
m_redisClient.erase(dbName); | |||
} | |||
|
|||
void DBInterface::close_all() |
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 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
Why I did it
Add support of 'with' statement to ConfigDBConnector
How I did it
Add enter and exit method to ConfigDBConnector
Work item tracking
How to verify it
Pass all UT and E2E test cases.
Add new UT to check ConfigDBConnector support 'with' statement
Which release branch to backport (provide reason below if selected)
Description for the changelog
Add support of 'with' statement to ConfigDBConnector
Link to config_db schema for YANG module changes
A picture of a cute animal (not mandatory but encouraged)