aboutsummaryrefslogtreecommitdiff
path: root/lib/stream.c
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2010-03-18 12:59:32 -0700
committerBen Pfaff <blp@nicira.com>2010-04-12 11:13:04 -0700
commit766407ea9011d347d577a3409acb0f8d34cc72e1 (patch)
tree9a1ec65614e13ae92acb05df59aa77f2fba37a18 /lib/stream.c
parentc6278d208924bb04c41266ddca276712f95533bc (diff)
stream: Generalize stream_open_block().
This change makes it possible to separate opening a stream from blocking on connection completion. This avoids some code redundancy in an upcoming commit.
Diffstat (limited to 'lib/stream.c')
-rw-r--r--lib/stream.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/stream.c b/lib/stream.c
index ed497d69..7d00cafe 100644
--- a/lib/stream.c
+++ b/lib/stream.c
@@ -222,13 +222,21 @@ error:
return error;
}
+/* Blocks until a previously started stream connection attempt succeeds or
+ * fails. 'error' should be the value returned by stream_open() and 'streamp'
+ * should point to the stream pointer set by stream_open(). Returns 0 if
+ * successful, otherwise a positive errno value other than EAGAIN or
+ * EINPROGRESS. If successful, leaves '*streamp' untouched; on error, closes
+ * '*streamp' and sets '*streamp' to null.
+ *
+ * Typical usage:
+ * error = stream_open_block(stream_open("tcp:1.2.3.4:5", &stream), &stream);
+ */
int
-stream_open_block(const char *name, struct stream **streamp)
+stream_open_block(int error, struct stream **streamp)
{
- struct stream *stream;
- int error;
+ struct stream *stream = *streamp;
- error = stream_open(name, &stream);
while (error == EAGAIN) {
stream_run(stream);
stream_run_wait(stream);