error = vconn_open(name, min_version, &vconn, DSCP_DEFAULT);
if (!error) {
- while ((error = vconn_connect(vconn)) == EAGAIN) {
- vconn_run(vconn);
- vconn_run_wait(vconn);
- vconn_connect_wait(vconn);
- poll_block();
- }
- assert(error != EINPROGRESS);
+ error = vconn_connect_block(vconn);
}
if (error) {
return retval;
}
+/* Same as vconn_connect(), except that it waits until the connection on
+ * 'vconn' completes or fails. Thus, it will never return EAGAIN. */
+int
+vconn_connect_block(struct vconn *vconn)
+{
+ int error;
+
+ while ((error = vconn_connect(vconn)) == EAGAIN) {
+ vconn_run(vconn);
+ vconn_run_wait(vconn);
+ vconn_connect_wait(vconn);
+ poll_block();
+ }
+ assert(error != EINPROGRESS);
+
+ return error;
+}
+
/* Same as vconn_send, except that it waits until 'msg' can be transmitted. */
int
vconn_send_block(struct vconn *vconn, struct ofpbuf *msg)
/*
- * Copyright (c) 2008, 2009, 2010, 2011 Nicira, Inc.
+ * Copyright (c) 2008, 2009, 2010, 2011, 2012 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
int vconn_open_block(const char *name, enum ofp_version min_version,
struct vconn **);
+int vconn_connect_block(struct vconn *);
int vconn_send_block(struct vconn *, struct ofpbuf *);
int vconn_recv_block(struct vconn *, struct ofpbuf **);
DSCP_DEFAULT), 0);
fpv_close(&fpv);
vconn_run(vconn);
- CHECK_ERRNO(vconn_connect(vconn), expected_error);
+ CHECK_ERRNO(vconn_connect_block(vconn), expected_error);
vconn_close(vconn);
fpv_destroy(&fpv);
}
poll_block();
}
stream_close(stream);
- CHECK_ERRNO(vconn_connect(vconn), ECONNRESET);
+ CHECK_ERRNO(vconn_connect_block(vconn), ECONNRESET);
vconn_close(vconn);
}
poll_block();
}
stream_close(stream);
- CHECK_ERRNO(vconn_recv(vconn, &msg), EOF);
+ CHECK_ERRNO(vconn_recv_block(vconn, &msg), EOF);
vconn_close(vconn);
}