struct vconn_class *class = vconn_classes[i];
assert(class->name != NULL);
assert(class->open != NULL);
- if (class->close || class->recv || class->send || class->wait) {
+ if (class->close || class->recv || class->send
+ || class->run || class->run_wait || class->wait) {
assert(class->close != NULL);
assert(class->recv != NULL);
assert(class->send != NULL);
return EAFNOSUPPORT;
}
+/* Allows 'vconn' to perform maintenance activities, such as flushing output
+ * buffers. */
+void
+vconn_run(struct vconn *vconn)
+{
+ if (vconn->class->run) {
+ (vconn->class->run)(vconn);
+ }
+}
+
+/* Arranges for the poll loop to wake up when 'vconn' needs to perform
+ * maintenance activities. */
+void
+vconn_run_wait(struct vconn *vconn)
+{
+ if (vconn->class->run_wait) {
+ (vconn->class->run_wait)(vconn);
+ }
+}
+
int
vconn_open_block(const char *name, int min_version, struct vconn **vconnp)
{
error = vconn_open(name, min_version, &vconn);
while (error == EAGAIN) {
+ vconn_run(vconn);
+ vconn_run_wait(vconn);
vconn_connect_wait(vconn);
poll_block();
error = vconn_connect(vconn);
{
int retval;
while ((retval = vconn_send(vconn, msg)) == EAGAIN) {
+ vconn_run(vconn);
+ vconn_run_wait(vconn);
vconn_send_wait(vconn);
poll_block();
}
{
int retval;
while ((retval = vconn_recv(vconn, msgp)) == EAGAIN) {
+ vconn_run(vconn);
+ vconn_run_wait(vconn);
vconn_recv_wait(vconn);
poll_block();
}
vconn->local_ip = 0;
vconn->local_port = 0;
vconn->name = xstrdup(name);
+ assert(vconn->state != VCS_CONNECTING || class->connect);
}
void