mirror of
https://gitee.com/acl-dev/acl.git
synced 2024-11-30 19:07:35 +08:00
service_guard: there're bugs in service_node.cpp for using redis_zset::save.
This commit is contained in:
parent
2242fd58aa
commit
ebd2c013f0
@ -64,19 +64,21 @@ bool guard_action::on_service_list(acl::json& json)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ret = true;
|
||||
|
||||
service_node node(var_redis);
|
||||
if (node.save(ip_, res) == false) {
|
||||
logger_error("save error, ip=%s", ip_.c_str());
|
||||
return false;
|
||||
ret = false;
|
||||
}
|
||||
|
||||
service_app app(var_redis);
|
||||
if (app.save(ip_, res) == false) {
|
||||
logger_error("save app info error, ip=%s", ip_.c_str());
|
||||
return false;
|
||||
ret = false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool guard_action::on_service_dead(acl::json& json)
|
||||
|
@ -28,11 +28,14 @@ bool service_node::save(const char* ip, const service_list_res_t& res)
|
||||
bool ret = true;
|
||||
|
||||
acl::redis cmd(&redis_);
|
||||
if (cmd.zadd(ip, members) < 0) {
|
||||
logger_error("zadd error=%s, ip=%s", cmd.result_error(), ip);
|
||||
if (cmd.zadd(ip, members) == -1) {
|
||||
logger_error("zadd error=%s, ip=%s, members=%d",
|
||||
cmd.result_error(), ip, (int) members.size());
|
||||
ret = false;
|
||||
}
|
||||
|
||||
cmd.clear();
|
||||
|
||||
acl::string key;
|
||||
members.clear();
|
||||
for (std::vector<service_info_t>::const_iterator cit = res.data.begin();
|
||||
@ -42,8 +45,9 @@ bool service_node::save(const char* ip, const service_list_res_t& res)
|
||||
members[key] = now;
|
||||
}
|
||||
|
||||
if (cmd.zadd(SERVICES, members) == false) {
|
||||
logger_error("zadd error=%s, ip=%s", cmd.result_error(), ip);
|
||||
if (cmd.zadd(SERVICES, members) == -1) {
|
||||
logger_error("zadd error=%s, ip=%s, members=%d",
|
||||
cmd.result_error(), ip, (int) members.size());
|
||||
ret = false;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user