[ovs-dev] [bug14616 3/5] worker: Make worker_request_iovec() verify that it is not being reentered.

Ben Pfaff blp at nicira.com
Fri Jan 11 01:23:03 UTC 2013


This function cannot easily be reentrant because the inner call would
interrupt and corrupt the data being sent by the outer call.

Signed-off-by: Ben Pfaff <blp at nicira.com>
---
 lib/worker.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/lib/worker.c b/lib/worker.c
index b281d70..eceac3d 100644
--- a/lib/worker.c
+++ b/lib/worker.c
@@ -237,11 +237,14 @@ worker_request_iovec(const struct iovec iovs[], size_t n_iovs,
                      worker_request_func *request_cb,
                      worker_reply_func *reply_cb, void *aux)
 {
+    static bool recursing = false;
     struct worker_request rq;
     struct iovec *all_iovs;
     int error;
 
     assert(worker_is_running());
+    assert(!recursing);
+    recursing = true;
 
     rq.request_len = iovec_len(iovs, n_iovs);
     rq.request_cb = request_cb;
@@ -255,6 +258,8 @@ worker_request_iovec(const struct iovec iovs[], size_t n_iovs,
         VLOG_ABORT("send failed (%s)", strerror(error));
     }
     free(all_iovs);
+
+    recursing = false;
 }
 
 /* Closes the client socket, if any, so that worker_is_running() will return
-- 
1.7.2.5




More information about the dev mailing list