]> git.ozlabs.org Git - ccan/commitdiff
io: don't do wakeup immediately.
authorRusty Russell <rusty@rustcorp.com.au>
Fri, 8 Aug 2014 03:25:12 +0000 (12:55 +0930)
committerRusty Russell <rusty@rustcorp.com.au>
Fri, 8 Aug 2014 03:25:12 +0000 (12:55 +0930)
ccan/io users don't expect to deal with callbacks inside each other; we should
just mark woken connections as if they were io_always.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ccan/io/backend.h
ccan/io/io.c
ccan/io/poll.c

index 2c03a98a1a4632917ad810f6e1d74d37813d52df..39605ec48662114944f184f4739848e1d2953c0d 100644 (file)
@@ -88,6 +88,6 @@ void backend_del_conn(struct io_conn *conn);
 
 void io_ready(struct io_conn *conn, int pollflags);
 void io_do_always(struct io_conn *conn);
 
 void io_ready(struct io_conn *conn, int pollflags);
 void io_do_always(struct io_conn *conn);
-void io_do_wakeup(struct io_conn *conn, struct io_plan *plan);
+void io_do_wakeup(struct io_conn *conn, enum io_direction dir);
 void *do_io_loop(struct io_conn **ready);
 #endif /* CCAN_IO_BACKEND_H */
 void *do_io_loop(struct io_conn **ready);
 #endif /* CCAN_IO_BACKEND_H */
index c0af6bf7e4d66ec761307b49931dcca85f64e3a8..7dbb9c5a3962d3a802bf1aae502ceeda4bb1b685 100644 (file)
@@ -384,10 +384,13 @@ void io_do_always(struct io_conn *conn)
                next_plan(conn, &conn->plan[IO_OUT]);
 }
 
                next_plan(conn, &conn->plan[IO_OUT]);
 }
 
-void io_do_wakeup(struct io_conn *conn, struct io_plan *plan)
+void io_do_wakeup(struct io_conn *conn, enum io_direction dir)
 {
 {
+       struct io_plan *plan = &conn->plan[dir];
+
        assert(plan->status == IO_WAITING);
        assert(plan->status == IO_WAITING);
-       next_plan(conn, plan);
+
+       set_always(conn, dir, plan->next, plan->next_arg);
 }
 
 /* Close the connection, we're done. */
 }
 
 /* Close the connection, we're done. */
index 8f77dd42d7c888acfb5dca50aea510304592b403..7af61d5a2699cac1f73aa7470da4da19c37efb9d 100644 (file)
@@ -158,11 +158,11 @@ void backend_wake(const void *wait)
                c = (void *)fds[i];
                if (c->plan[IO_IN].status == IO_WAITING
                    && c->plan[IO_IN].arg.u1.const_vp == wait)
                c = (void *)fds[i];
                if (c->plan[IO_IN].status == IO_WAITING
                    && c->plan[IO_IN].arg.u1.const_vp == wait)
-                       io_do_wakeup(c, &c->plan[IO_IN]);
+                       io_do_wakeup(c, IO_IN);
 
                if (c->plan[IO_OUT].status == IO_WAITING
                    && c->plan[IO_OUT].arg.u1.const_vp == wait)
 
                if (c->plan[IO_OUT].status == IO_WAITING
                    && c->plan[IO_OUT].arg.u1.const_vp == wait)
-                       io_do_wakeup(c, &c->plan[IO_OUT]);
+                       io_do_wakeup(c, IO_OUT);
        }
 }
 
        }
 }