[ovs-dev] [OfconnLogging 2/5] rconn: Drop rconn_new(), rconn_new_from_vconn() functions.

Ben Pfaff blp at nicira.com
Fri Jun 4 20:50:14 UTC 2010


There are enough rconn functions without these helpers, which weren't used
much in practice.
---
 extras/ezio/ovs-switchui.c |    3 ++-
 lib/rconn.c                |   23 ++++-------------------
 lib/rconn.h                |    3 ---
 ofproto/ofproto.c          |    6 +++++-
 utilities/ovs-controller.c |    3 ++-
 5 files changed, 13 insertions(+), 25 deletions(-)

diff --git a/extras/ezio/ovs-switchui.c b/extras/ezio/ovs-switchui.c
index 6ebfece..a1adcc5 100644
--- a/extras/ezio/ovs-switchui.c
+++ b/extras/ezio/ovs-switchui.c
@@ -160,7 +160,8 @@ main(int argc, char *argv[])
                   "use --help for help");
     }
 
-    rconn = rconn_new(argv[0], 5, 5);
+    rconn = rconn_create(5, 5);
+    rconn_connect(rconn, argv[0]);
 
     die_if_already_running();
     daemonize();
diff --git a/lib/rconn.c b/lib/rconn.c
index a26b037..7d9592a 100644
--- a/lib/rconn.c
+++ b/lib/rconn.c
@@ -145,24 +145,6 @@ static void copy_to_monitor(struct rconn *, const struct ofpbuf *);
 static bool is_connected_state(enum state);
 static bool is_admitted_msg(const struct ofpbuf *);
 
-/* Creates a new rconn, connects it (reliably) to 'name', and returns it. */
-struct rconn *
-rconn_new(const char *name, int inactivity_probe_interval, int max_backoff)
-{
-    struct rconn *rc = rconn_create(inactivity_probe_interval, max_backoff);
-    rconn_connect(rc, name);
-    return rc;
-}
-
-/* Creates a new rconn, connects it (unreliably) to 'vconn', and returns it. */
-struct rconn *
-rconn_new_from_vconn(struct vconn *vconn) 
-{
-    struct rconn *rc = rconn_create(60, 0);
-    rconn_connect_unreliably(rc, vconn);
-    return rc;
-}
-
 /* Creates and returns a new rconn.
  *
  * 'probe_interval' is a number of seconds.  If the interval passes once
@@ -174,7 +156,10 @@ rconn_new_from_vconn(struct vconn *vconn)
  * 'max_backoff' is the maximum number of seconds between attempts to connect
  * to the peer.  The actual interval starts at 1 second and doubles on each
  * failure until it reaches 'max_backoff'.  If 0 is specified, the default of
- * 8 seconds is used. */
+ * 8 seconds is used.
+ *
+ * The new rconn is initially unconnected.  Use rconn_connect() or
+ * rconn_connect_unreliably() to connect it. */
 struct rconn *
 rconn_create(int probe_interval, int max_backoff)
 {
diff --git a/lib/rconn.h b/lib/rconn.h
index aa9d76c..8222852 100644
--- a/lib/rconn.h
+++ b/lib/rconn.h
@@ -37,9 +37,6 @@
 struct vconn;
 struct rconn_packet_counter;
 
-struct rconn *rconn_new(const char *name, 
-                        int inactivity_probe_interval, int max_backoff);
-struct rconn *rconn_new_from_vconn(struct vconn *);
 struct rconn *rconn_create(int inactivity_probe_interval, int max_backoff);
 
 void rconn_set_max_backoff(struct rconn *, int max_backoff);
diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index adb836b..bf5081b 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -1078,7 +1078,11 @@ ofproto_run1(struct ofproto *p)
 
         retval = pvconn_accept(p->listeners[i], OFP_VERSION, &vconn);
         if (!retval) {
-            ofconn_create(p, rconn_new_from_vconn(vconn), OFCONN_TRANSIENT);
+            struct rconn *rconn;
+
+            rconn = rconn_create(60, 0);
+            rconn_connect_unreliably(rconn, vconn);
+            ofconn_create(p, rconn, OFCONN_TRANSIENT);
         } else if (retval != EAGAIN) {
             VLOG_WARN_RL(&rl, "accept failed (%s)", strerror(retval));
         }
diff --git a/utilities/ovs-controller.c b/utilities/ovs-controller.c
index 19eec15..8de3400 100644
--- a/utilities/ovs-controller.c
+++ b/utilities/ovs-controller.c
@@ -210,7 +210,8 @@ main(int argc, char *argv[])
 static void
 new_switch(struct switch_ *sw, struct vconn *vconn)
 {
-    sw->rconn = rconn_new_from_vconn(vconn);
+    sw->rconn = rconn_create(60, 0);
+    rconn_connect_unreliably(sw->rconn, vconn);
     sw->lswitch = lswitch_create(sw->rconn, learn_macs, exact_flows,
                                  set_up_flows ? max_idle : -1,
                                  action_normal);
-- 
1.7.1





More information about the dev mailing list