Before this patch, rconn_send() would delete 'b' on success, and
not on error.  This is confusing and error-prone.  This patch
causes rconn_send() to always delete 'b'.

Signed-off-by: Ethan Jackson <[email protected]>
---
 lib/learning-switch.c |    1 -
 lib/rconn.c           |   13 ++++---------
 ofproto/connmgr.c     |    4 +---
 3 files changed, 5 insertions(+), 13 deletions(-)

diff --git a/lib/learning-switch.c b/lib/learning-switch.c
index 9e36db8..23d26e7 100644
--- a/lib/learning-switch.c
+++ b/lib/learning-switch.c
@@ -178,7 +178,6 @@ lswitch_create(struct rconn *rconn, const struct 
lswitch_config *cfg)
         if (error) {
             VLOG_INFO_RL(&rl, "%s: failed to queue default flows (%s)",
                          rconn_get_name(rconn), strerror(error));
-            ofpbuf_delete(msg);
         }
     }
 
diff --git a/lib/rconn.c b/lib/rconn.c
index 759c0cb..1b84865 100644
--- a/lib/rconn.c
+++ b/lib/rconn.c
@@ -433,7 +433,6 @@ static void
 run_ACTIVE(struct rconn *rc)
 {
     if (timed_out(rc)) {
-        struct ofpbuf *b;
         unsigned int base = MAX(rc->last_received, rc->state_entered);
         VLOG_DBG("%s: idle %u seconds, sending inactivity probe",
                  rc->name, (unsigned int) (time_now() - base));
@@ -442,10 +441,7 @@ run_ACTIVE(struct rconn *rc)
          * and we don't want to transition back to IDLE if so, because then we
          * can end up queuing a packet with vconn == NULL and then *boom*. */
         state_transition(rc, S_IDLE);
-        b = make_echo_request();
-        if (rconn_send(rc, b, NULL)) {
-            ofpbuf_delete(b);
-        }
+        rconn_send(rc, make_echo_request(), NULL);
         return;
     }
 
@@ -564,9 +560,8 @@ rconn_recv_wait(struct rconn *rc)
     }
 }
 
-/* Sends 'b' on 'rc'.  Returns 0 if successful (in which case 'b' is
- * destroyed), or ENOTCONN if 'rc' is not currently connected (in which case
- * the caller retains ownership of 'b').
+/* Sends 'b' on 'rc'.  Returns 0 if successful, or ENOTCONN if 'rc' is not
+ * currently connected.  In either case, 'b' is deleted.
  *
  * If 'counter' is non-null, then 'counter' will be incremented while the
  * packet is in flight, then decremented when it has been sent (or discarded
@@ -599,6 +594,7 @@ rconn_send(struct rconn *rc, struct ofpbuf *b,
         }
         return 0;
     } else {
+        ofpbuf_delete(b);
         return ENOTCONN;
     }
 }
@@ -623,7 +619,6 @@ rconn_send_with_limit(struct rconn *rc, struct ofpbuf *b,
     retval = counter->n >= queue_limit ? EAGAIN : rconn_send(rc, b, counter);
     if (retval) {
         COVERAGE_INC(rconn_overflow);
-        ofpbuf_delete(b);
     }
     return retval;
 }
diff --git a/ofproto/connmgr.c b/ofproto/connmgr.c
index 629c14d..281fdd3 100644
--- a/ofproto/connmgr.c
+++ b/ofproto/connmgr.c
@@ -1225,9 +1225,7 @@ ofconn_send(const struct ofconn *ofconn, struct ofpbuf 
*msg,
             struct rconn_packet_counter *counter)
 {
     update_openflow_length(msg);
-    if (rconn_send(ofconn->rconn, msg, counter)) {
-        ofpbuf_delete(msg);
-    }
+    rconn_send(ofconn->rconn, msg, counter);
 }
 
 /* Sending asynchronous messages. */
-- 
1.7.10

_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev

Reply via email to