X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=ofproto%2Fcollectors.c;h=14572db9c73c686869c5894770a58e73e570f40f;hb=626186c3bea6b07442632684eacf4d02545fa05f;hp=0b84c3ece300a44fd62d9e4f6f4e255e99a111a8;hpb=3762274e6359f4afe04107851f4c71347fa0afa0;p=openvswitch diff --git a/ofproto/collectors.c b/ofproto/collectors.c index 0b84c3ec..14572db9 100644 --- a/ofproto/collectors.c +++ b/ofproto/collectors.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2009, 2010 Nicira Networks. + * Copyright (c) 2008, 2009, 2010, 2011 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,12 +24,12 @@ #include #include "socket-util.h" -#include "svec.h" +#include "sset.h" #include "util.h" - -#define THIS_MODULE VLM_collectors #include "vlog.h" +VLOG_DEFINE_THIS_MODULE(collectors); + struct collectors { int *fds; /* Sockets. */ size_t n_fds; /* Number of sockets. */ @@ -47,28 +47,23 @@ struct collectors { * added, otherwise to a new collectors object if at least one was successfully * added. Thus, even on a failure return, it is possible that '*collectorsp' * is nonnull, and even on a successful return, it is possible that - * '*collectorsp' is null, if 'target's is an empty svec. */ + * '*collectorsp' is null, if 'target's is an empty sset. */ int -collectors_create(const struct svec *targets_, uint16_t default_port, +collectors_create(const struct sset *targets, uint16_t default_port, struct collectors **collectorsp) { struct collectors *c; - struct svec targets; + const char *name; int retval = 0; - size_t i; - - svec_clone(&targets, targets_); - svec_sort_unique(&targets); c = xmalloc(sizeof *c); - c->fds = xmalloc(sizeof *c->fds * targets.n); + c->fds = xmalloc(sizeof *c->fds * sset_count(targets)); c->n_fds = 0; - for (i = 0; i < targets.n; i++) { - const char *name = targets.names[i]; + SSET_FOR_EACH (name, targets) { int error; int fd; - error = inet_open_active(SOCK_DGRAM, name, default_port, NULL, &fd); + error = inet_open_active(SOCK_DGRAM, name, default_port, NULL, &fd, 0); if (fd >= 0) { c->fds[c->n_fds++] = fd; } else { @@ -81,7 +76,6 @@ collectors_create(const struct svec *targets_, uint16_t default_port, } } } - svec_destroy(&targets); if (c->n_fds) { *collectorsp = c;