From: Ethan Jackson Date: Thu, 26 Apr 2012 04:12:18 +0000 (-0700) Subject: rconn: Simplify rconn_send() semantics. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=acb9da402293ba689b1a80dcc7fdabf30751ccd5;p=openvswitch 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 --- diff --git a/lib/learning-switch.c b/lib/learning-switch.c index 9e36db88..23d26e7b 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 56a7e197..700de11b 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 629c14d0..281fdd3f 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. */