ovsdb: Fix use of non-array for JSON-RPC parameters.
[openvswitch] / lib / stream.c
index 1a0ea7ba7466699ca80f1318e16a963e8ad1277c..23b25f22173b4ee4e5f41ce4fa71fb21a67fc39a 100644 (file)
@@ -422,6 +422,27 @@ pstream_accept(struct pstream *pstream, struct stream **new_stream)
     return retval;
 }
 
+/* Tries to accept a new connection on 'pstream'.  If successful, stores the
+ * new connection in '*new_stream' and returns 0.  Otherwise, returns a
+ * positive errno value.
+ *
+ * pstream_accept_block() blocks until a connection is ready or until an error
+ * occurs.  It will not return EAGAIN. */
+int
+pstream_accept_block(struct pstream *pstream, struct stream **new_stream)
+{
+    int error;
+
+    while ((error = pstream_accept(pstream, new_stream)) == EAGAIN) {
+        pstream_wait(pstream);
+        poll_block();
+    }
+    if (error) {
+        *new_stream = NULL;
+    }
+    return error;
+}
+
 void
 pstream_wait(struct pstream *pstream)
 {