From acb9da402293ba689b1a80dcc7fdabf30751ccd5 Mon Sep 17 00:00:00 2001 From: Ethan Jackson Date: Wed, 25 Apr 2012 21:12:18 -0700 Subject: [PATCH 1/1] rconn: Simplify rconn_send() semantics. 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 --- lib/learning-switch.c | 1 - lib/rconn.c | 7 +++---- ofproto/connmgr.c | 4 +--- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/learning-switch.c b/lib/learning-switch.c index 9e36db884..23d26e7bf 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 56a7e1976..700de11b2 100644 --- a/lib/rconn.c +++ b/lib/rconn.c @@ -560,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. Takes ownership of 'b'. * * 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 @@ -595,6 +594,7 @@ rconn_send(struct rconn *rc, struct ofpbuf *b, } return 0; } else { + ofpbuf_delete(b); return ENOTCONN; } } @@ -619,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 629c14d07..281fdd3f5 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. */ -- 2.43.0