diff --git a/app/master/tools/service_guard/action/guard_action.cpp b/app/master/tools/service_guard/action/guard_action.cpp index f24aa6156..b7ba531d7 100644 --- a/app/master/tools/service_guard/action/guard_action.cpp +++ b/app/master/tools/service_guard/action/guard_action.cpp @@ -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) diff --git a/app/master/tools/service_guard/dao/service_node.cpp b/app/master/tools/service_guard/dao/service_node.cpp index da47d53a4..fa3290854 100644 --- a/app/master/tools/service_guard/dao/service_node.cpp +++ b/app/master/tools/service_guard/dao/service_node.cpp @@ -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::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; }