mirror of
https://github.com/sogou/workflow.git
synced 2026-10-26 01:30:47 +08:00
fix upstream rwlock bug
This commit is contained in:
@@ -70,6 +70,7 @@ int UpstreamManager::upstream_create_consistent_hash(const std::string& name,
|
||||
return 0;
|
||||
}
|
||||
|
||||
delete policy;
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -85,6 +86,7 @@ int UpstreamManager::upstream_create_weighted_random(const std::string& name,
|
||||
return 0;
|
||||
}
|
||||
|
||||
delete policy;
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -103,6 +105,7 @@ int UpstreamManager::upstream_create_manual(const std::string& name,
|
||||
return 0;
|
||||
}
|
||||
|
||||
delete policy;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -226,7 +226,7 @@ void WFServiceGovernance::success(RouteManager::RouteResult *result,
|
||||
else
|
||||
server = (EndpointAddress *)tracing->data;
|
||||
|
||||
this->rwlock.rlock();
|
||||
this->rwlock.wlock();
|
||||
this->recover_server_from_breaker(server);
|
||||
this->rwlock.unlock();
|
||||
|
||||
@@ -246,7 +246,7 @@ void WFServiceGovernance::failed(RouteManager::RouteResult *result,
|
||||
else
|
||||
server = (EndpointAddress *)tracing->data;
|
||||
|
||||
this->rwlock.rlock();
|
||||
this->rwlock.wlock();
|
||||
size_t fail_count = ++server->fail_count;
|
||||
if (fail_count == server->params->max_fails)
|
||||
this->fuse_server_to_breaker(server);
|
||||
@@ -428,7 +428,7 @@ int WFServiceGovernance::replace_server(const std::string& address,
|
||||
|
||||
void WFServiceGovernance::enable_server(const std::string& address)
|
||||
{
|
||||
this->rwlock.rlock();
|
||||
this->rwlock.wlock();
|
||||
const auto map_it = this->server_map.find(address);
|
||||
if (map_it != this->server_map.cend())
|
||||
{
|
||||
@@ -440,7 +440,7 @@ void WFServiceGovernance::enable_server(const std::string& address)
|
||||
|
||||
void WFServiceGovernance::disable_server(const std::string& address)
|
||||
{
|
||||
this->rwlock.rlock();
|
||||
this->rwlock.wlock();
|
||||
const auto map_it = this->server_map.find(address);
|
||||
if (map_it != this->server_map.cend())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user