2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-30 22:05:19 +00:00

Convert shash users that don't use the 'data' value to sset instead.

In each of the cases converted here, an shash was used simply to maintain
a set of strings, with the shash_nodes' 'data' values set to NULL.  This
commit converts them to use sset instead.
This commit is contained in:
Ben Pfaff
2011-03-25 15:26:30 -07:00
parent f391294fde
commit b3c01ed330
7 changed files with 109 additions and 116 deletions

View File

@@ -45,6 +45,7 @@
#include "rtnetlink.h"
#include "rtnetlink-link.h"
#include "shash.h"
#include "sset.h"
#include "svec.h"
#include "unaligned.h"
#include "util.h"
@@ -125,7 +126,7 @@ struct dpif_linux {
unsigned int listen_mask;
/* Change notification. */
struct shash changed_ports; /* Ports that have changed. */
struct sset changed_ports; /* Ports that have changed. */
struct rtnetlink_notifier port_notifier;
bool change_error;
};
@@ -231,7 +232,7 @@ open_dpif(const struct dpif_linux_dp *dp, struct dpif **dpifp)
}
dpif->listen_mask = 0;
dpif->dp_ifindex = dp->dp_ifindex;
shash_init(&dpif->changed_ports);
sset_init(&dpif->changed_ports);
dpif->change_error = false;
*dpifp = &dpif->dpif;
@@ -247,7 +248,7 @@ dpif_linux_close(struct dpif *dpif_)
{
struct dpif_linux *dpif = dpif_linux_cast(dpif_);
rtnetlink_link_notifier_unregister(&dpif->port_notifier);
shash_destroy(&dpif->changed_ports);
sset_destroy(&dpif->changed_ports);
free(dpif);
}
@@ -483,11 +484,10 @@ dpif_linux_port_poll(const struct dpif *dpif_, char **devnamep)
if (dpif->change_error) {
dpif->change_error = false;
shash_clear(&dpif->changed_ports);
sset_clear(&dpif->changed_ports);
return ENOBUFS;
} else if (!shash_is_empty(&dpif->changed_ports)) {
struct shash_node *node = shash_first(&dpif->changed_ports);
*devnamep = shash_steal(&dpif->changed_ports, node);
} else if (!sset_is_empty(&dpif->changed_ports)) {
*devnamep = sset_pop(&dpif->changed_ports);
return 0;
} else {
return EAGAIN;
@@ -498,7 +498,7 @@ static void
dpif_linux_port_poll_wait(const struct dpif *dpif_)
{
struct dpif_linux *dpif = dpif_linux_cast(dpif_);
if (!shash_is_empty(&dpif->changed_ports) || dpif->change_error) {
if (!sset_is_empty(&dpif->changed_ports) || dpif->change_error) {
poll_immediate_wake();
} else {
rtnetlink_link_notifier_wait();
@@ -1041,7 +1041,7 @@ dpif_linux_port_changed(const struct rtnetlink_link_change *change,
{
/* Our datapath changed, either adding a new port or deleting an
* existing one. */
shash_add_once(&dpif->changed_ports, change->ifname, NULL);
sset_add(&dpif->changed_ports, change->ifname);
}
} else {
dpif->change_error = true;