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);
/* Bidirectional byte streams. */
int stream_verify_name(const char *name);
int stream_open(const char *name, struct stream **);
-int stream_open_block(const char *name, struct stream **);
+int stream_open_block(int error, struct stream **);
void stream_close(struct stream *);
const char *stream_get_name(const struct stream *);
uint32_t stream_get_remote_ip(const struct stream *);
struct stream *stream;
int error;
- error = stream_open_block(server, &stream);
+ error = stream_open_block(stream_open(server, &stream), &stream);
if (error == EAFNOSUPPORT) {
struct pstream *pstream;
ovs_fatal(0, "not a valid JSON-RPC request: %s", string);
}
- error = stream_open_block(argv[1], &stream);
+ error = stream_open_block(stream_open(argv[1], &stream), &stream);
if (error) {
ovs_fatal(error, "could not open \"%s\"", argv[1]);
}
ovs_fatal(0, "not a JSON RPC-valid notification: %s", string);
}
- error = stream_open_block(argv[1], &stream);
+ error = stream_open_block(stream_open(argv[1], &stream), &stream);
if (error) {
ovs_fatal(error, "could not open \"%s\"", argv[1]);
}
if (argc > 2) {
struct stream *stream;
- error = stream_open_block(argv[1], &stream);
+ error = stream_open_block(stream_open(argv[1], &stream), &stream);
if (error) {
ovs_fatal(error, "failed to connect to \"%s\"", argv[1]);
}