update upstream_delete() ret, 0:success, -1:not existed.

This commit is contained in:
holmes1412
2021-03-26 17:20:30 +08:00
parent e46f97728e
commit 5150262166
2 changed files with 7 additions and 9 deletions

View File

@@ -138,10 +138,7 @@ int UpstreamManager::upstream_remove_server(const std::string& name,
UPSGroupPolicy *policy = dynamic_cast<UPSGroupPolicy *>(ns->get_policy(name.c_str()));
if (policy)
{
policy->remove_server(address);
return 0;
}
return policy->remove_server(address);
errno = ENOENT;
return -1;
@@ -150,15 +147,16 @@ int UpstreamManager::upstream_remove_server(const std::string& name,
int UpstreamManager::upstream_delete(const std::string& name)
{
WFNameService *ns = WFGlobal::get_name_service();
auto *policy = ns->del_policy(name.c_str());
WFNSPolicy *policy = ns->del_policy(name.c_str());
if (policy)
{
delete policy;
return 1;
return 0;
}
return 0;
errno = ENOENT;
return -1;
}
std::vector<std::string>

View File

@@ -131,8 +131,8 @@ public:
* @brief Delete one upstream
* @param[in] name upstream name
* @return success/fail
* @retval 0 fail, not found
* @retval 1 success
* @retval 0 success
* @retval -1 fail, not found
*/
static int upstream_delete(const std::string& name);