--- IO-AIO/AIO.xs 2008/05/10 18:06:41 1.115 +++ IO-AIO/AIO.xs 2008/05/10 19:25:33 1.116 @@ -103,7 +103,7 @@ typedef eio_req *aio_req; typedef eio_req *aio_req_ornot; -static unsigned int max_outstanding = 0x7fffffff; +static int max_outstanding = 0; static int next_pri = EIO_DEFAULT_PRI + EIO_PRI_BIAS; @@ -407,14 +407,25 @@ static int poll_cb (void) { - int res = eio_poll (); + int res; - if (res > 0) - croak (0); + do + { + res = eio_poll (); + + if (res > 0) + croak (0); + } + while (max_outstanding && max_outstanding <= eio_nreqs ()); return res; } +static void atfork_child (void) +{ + create_respipe (); +} + #define dREQ \ aio_req req; \ int req_pri = next_pri; \ @@ -466,6 +477,9 @@ if (eio_init (want_poll, done_poll) < 0) croak ("IO::AIO: unable to initialise eio library"); + + /* atfork child called in fifo order, so before eio's handler */ + X_THREAD_ATFORK (0, 0, atfork_child); } void @@ -920,7 +934,7 @@ flush () PROTOTYPE: CODE: - while (nreqs) + while (eio_nreqs ()) { poll_wait (); poll_cb ();