core: split nm_netns_watcher_remove_all()
The name suggests that the function always removes all the watchers
with the given tag; instead it removes only "dirty" ones when the
"all" parameter is FALSE. Split the function in two variants.
(cherry picked from commit b6e67c6abc
)
This commit is contained in:
@@ -4960,7 +4960,7 @@ next:
|
||||
}
|
||||
|
||||
out:
|
||||
nm_netns_watcher_remove_all(self->priv.netns, TAG, FALSE);
|
||||
nm_netns_watcher_remove_dirty(self->priv.netns, TAG);
|
||||
}
|
||||
/*****************************************************************************/
|
||||
|
||||
@@ -5841,12 +5841,8 @@ finalize(GObject *object)
|
||||
gboolean changed;
|
||||
|
||||
if (self->priv.netns) {
|
||||
nm_netns_watcher_remove_all(self->priv.netns,
|
||||
_NETNS_WATCHER_IP_ADDR_TAG(self, AF_INET),
|
||||
TRUE);
|
||||
nm_netns_watcher_remove_all(self->priv.netns,
|
||||
_NETNS_WATCHER_IP_ADDR_TAG(self, AF_INET6),
|
||||
TRUE);
|
||||
nm_netns_watcher_remove_all(self->priv.netns, _NETNS_WATCHER_IP_ADDR_TAG(self, AF_INET));
|
||||
nm_netns_watcher_remove_all(self->priv.netns, _NETNS_WATCHER_IP_ADDR_TAG(self, AF_INET6));
|
||||
}
|
||||
|
||||
nm_prioq_destroy(&self->priv.p->failedobj_prioq);
|
||||
|
@@ -1369,8 +1369,8 @@ nm_netns_watcher_remove_handle(NMNetns *self, NMNetnsWatcherHandle *handle)
|
||||
g_object_unref(self);
|
||||
}
|
||||
|
||||
void
|
||||
nm_netns_watcher_remove_all(NMNetns *self, gconstpointer tag, gboolean all)
|
||||
static void
|
||||
watcher_remove(NMNetns *self, gconstpointer tag, gboolean all)
|
||||
{
|
||||
NMNetnsPrivate *priv;
|
||||
WatcherByTag *watcher_by_tag;
|
||||
@@ -1420,6 +1420,21 @@ nm_netns_watcher_remove_all(NMNetns *self, gconstpointer tag, gboolean all)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nm_netns_watcher_remove_all(NMNetns *self, gconstpointer tag)
|
||||
{
|
||||
watcher_remove(self, tag, TRUE);
|
||||
}
|
||||
|
||||
/* Similar to nm_netns_watcher_remove_all(), but removes only watchers
|
||||
* that were marked as "dirty" in a previous call of this function and were
|
||||
* not added back via nm_netns_watcher_add() in the meantime. */
|
||||
void
|
||||
nm_netns_watcher_remove_dirty(NMNetns *self, gconstpointer tag)
|
||||
{
|
||||
watcher_remove(self, tag, FALSE);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
|
@@ -98,7 +98,7 @@ void nm_netns_watcher_add(NMNetns *self,
|
||||
NMNetnsWatcherCallback callback,
|
||||
gpointer user_data);
|
||||
|
||||
void
|
||||
nm_netns_watcher_remove_all(NMNetns *self, gconstpointer tag, gboolean all /* or only dirty */);
|
||||
void nm_netns_watcher_remove_all(NMNetns *self, gconstpointer tag);
|
||||
void nm_netns_watcher_remove_dirty(NMNetns *self, gconstpointer tag);
|
||||
|
||||
#endif /* __NM_NETNS_H__ */
|
||||
|
Reference in New Issue
Block a user