aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorEthan Jackson <ethan@nicira.com>2012-04-25 21:12:18 -0700
committerEthan Jackson <ethan@nicira.com>2012-04-26 00:44:07 -0700
commitacb9da402293ba689b1a80dcc7fdabf30751ccd5 (patch)
tree8ef435f598d1813755d3811918fe20ecc99b3de5 /lib
parent47284b1fc6fe84a9b5b43b49bef868e4eb230cd1 (diff)
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 <ethan@nicira.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/learning-switch.c1
-rw-r--r--lib/rconn.c7
2 files changed, 3 insertions, 5 deletions
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;
}