shunt-manager: Remove first match if no namespace given during uninstall
Also makes namespace mandatory.
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2015-2016 Tobias Brunner
|
* Copyright (C) 2015-2017 Tobias Brunner
|
||||||
* Copyright (C) 2011-2016 Andreas Steffen
|
* Copyright (C) 2011-2016 Andreas Steffen
|
||||||
* HSR Hochschule fuer Technik Rapperswil
|
* HSR Hochschule fuer Technik Rapperswil
|
||||||
*
|
*
|
||||||
@@ -198,6 +198,13 @@ METHOD(shunt_manager_t, install, bool,
|
|||||||
entry_t *entry;
|
entry_t *entry;
|
||||||
bool found = FALSE, success;
|
bool found = FALSE, success;
|
||||||
|
|
||||||
|
if (!ns)
|
||||||
|
{
|
||||||
|
DBG1(DBG_CFG, "missing namespace for shunt policy '%s'",
|
||||||
|
cfg->get_name(cfg));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/* check if not already installed */
|
/* check if not already installed */
|
||||||
this->lock->write_lock(this->lock);
|
this->lock->write_lock(this->lock);
|
||||||
if (this->installing == INSTALL_DISABLED)
|
if (this->installing == INSTALL_DISABLED)
|
||||||
@@ -224,7 +231,7 @@ METHOD(shunt_manager_t, install, bool,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
INIT(entry,
|
INIT(entry,
|
||||||
.ns = strdupnull(ns),
|
.ns = strdup(ns),
|
||||||
.cfg = cfg->get_ref(cfg),
|
.cfg = cfg->get_ref(cfg),
|
||||||
);
|
);
|
||||||
this->shunts->insert_last(this->shunts, entry);
|
this->shunts->insert_last(this->shunts, entry);
|
||||||
@@ -369,7 +376,7 @@ METHOD(shunt_manager_t, uninstall, bool,
|
|||||||
enumerator = this->shunts->create_enumerator(this->shunts);
|
enumerator = this->shunts->create_enumerator(this->shunts);
|
||||||
while (enumerator->enumerate(enumerator, &entry))
|
while (enumerator->enumerate(enumerator, &entry))
|
||||||
{
|
{
|
||||||
if (streq(ns, entry->ns) &&
|
if ((!ns || streq(ns, entry->ns)) &&
|
||||||
streq(name, entry->cfg->get_name(entry->cfg)))
|
streq(name, entry->cfg->get_name(entry->cfg)))
|
||||||
{
|
{
|
||||||
this->shunts->remove_at(this->shunts, enumerator);
|
this->shunts->remove_at(this->shunts, enumerator);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2015-2016 Tobias Brunner
|
* Copyright (C) 2015-2017 Tobias Brunner
|
||||||
* Copyright (C) 2011 Andreas Steffen
|
* Copyright (C) 2011 Andreas Steffen
|
||||||
* HSR Hochschule fuer Technik Rapperswil
|
* HSR Hochschule fuer Technik Rapperswil
|
||||||
*
|
*
|
||||||
@@ -36,8 +36,7 @@ struct shunt_manager_t {
|
|||||||
/**
|
/**
|
||||||
* Install a policy as a shunt.
|
* Install a policy as a shunt.
|
||||||
*
|
*
|
||||||
* @param ns optional namespace (e.g. name of a connection or
|
* @param ns namespace (e.g. name of a connection or plugin), cloned
|
||||||
* plugin), cloned
|
|
||||||
* @param child child configuration to install as a shunt
|
* @param child child configuration to install as a shunt
|
||||||
* @return TRUE if installed successfully
|
* @return TRUE if installed successfully
|
||||||
*/
|
*/
|
||||||
@@ -46,7 +45,10 @@ struct shunt_manager_t {
|
|||||||
/**
|
/**
|
||||||
* Uninstall a shunt policy.
|
* Uninstall a shunt policy.
|
||||||
*
|
*
|
||||||
* @param ns namespace (same as given during installation)
|
* If no namespace is given the first matching child configuration is
|
||||||
|
* removed.
|
||||||
|
*
|
||||||
|
* @param ns namespace (same as given during installation) or NULL
|
||||||
* @param name name of child configuration to uninstall as a shunt
|
* @param name name of child configuration to uninstall as a shunt
|
||||||
* @return TRUE if uninstalled successfully
|
* @return TRUE if uninstalled successfully
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user