ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/IO-AIO/AIO.xs
(Generate patch)

Comparing IO-AIO/AIO.xs (file contents):
Revision 1.115 by root, Sat May 10 18:06:41 2008 UTC vs.
Revision 1.116 by root, Sat May 10 19:25:33 2008 UTC

101#include "libeio/eio.c" 101#include "libeio/eio.c"
102 102
103typedef eio_req *aio_req; 103typedef eio_req *aio_req;
104typedef eio_req *aio_req_ornot; 104typedef eio_req *aio_req_ornot;
105 105
106static unsigned int max_outstanding = 0x7fffffff; 106static int max_outstanding = 0;
107 107
108static int next_pri = EIO_DEFAULT_PRI + EIO_PRI_BIAS; 108static int next_pri = EIO_DEFAULT_PRI + EIO_PRI_BIAS;
109 109
110static int respipe_osf [2], respipe [2] = { -1, -1 }; 110static int respipe_osf [2], respipe [2] = { -1, -1 };
111 111
405 } 405 }
406} 406}
407 407
408static int poll_cb (void) 408static int poll_cb (void)
409{ 409{
410 int res;
411
412 do
413 {
410 int res = eio_poll (); 414 res = eio_poll ();
411 415
412 if (res > 0) 416 if (res > 0)
413 croak (0); 417 croak (0);
418 }
419 while (max_outstanding && max_outstanding <= eio_nreqs ());
414 420
415 return res; 421 return res;
422}
423
424static void atfork_child (void)
425{
426 create_respipe ();
416} 427}
417 428
418#define dREQ \ 429#define dREQ \
419 aio_req req; \ 430 aio_req req; \
420 int req_pri = next_pri; \ 431 int req_pri = next_pri; \
464 475
465 create_respipe (); 476 create_respipe ();
466 477
467 if (eio_init (want_poll, done_poll) < 0) 478 if (eio_init (want_poll, done_poll) < 0)
468 croak ("IO::AIO: unable to initialise eio library"); 479 croak ("IO::AIO: unable to initialise eio library");
480
481 /* atfork child called in fifo order, so before eio's handler */
482 X_THREAD_ATFORK (0, 0, atfork_child);
469} 483}
470 484
471void 485void
472max_poll_reqs (int nreqs) 486max_poll_reqs (int nreqs)
473 PROTOTYPE: $ 487 PROTOTYPE: $
918 932
919void 933void
920flush () 934flush ()
921 PROTOTYPE: 935 PROTOTYPE:
922 CODE: 936 CODE:
923 while (nreqs) 937 while (eio_nreqs ())
924 { 938 {
925 poll_wait (); 939 poll_wait ();
926 poll_cb (); 940 poll_cb ();
927 } 941 }
928 942

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines