worker: Make worker_request_iovec() verify that it is not being reentered.
authorBen Pfaff <blp@nicira.com>
Fri, 11 Jan 2013 01:16:01 +0000 (17:16 -0800)
committerBen Pfaff <blp@nicira.com>
Fri, 11 Jan 2013 18:37:58 +0000 (10:37 -0800)
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@nicira.com>
Acked-by: Kyle Mestery <kmestery@cisco.com>
lib/worker.c

index b281d70..eceac3d 100644 (file)
@@ -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