… | |
… | |
101 | #include "libeio/eio.c" |
101 | #include "libeio/eio.c" |
102 | |
102 | |
103 | typedef eio_req *aio_req; |
103 | typedef eio_req *aio_req; |
104 | typedef eio_req *aio_req_ornot; |
104 | typedef eio_req *aio_req_ornot; |
105 | |
105 | |
106 | static unsigned int max_outstanding = 0x7fffffff; |
106 | static int max_outstanding = 0; |
107 | |
107 | |
108 | static int next_pri = EIO_DEFAULT_PRI + EIO_PRI_BIAS; |
108 | static int next_pri = EIO_DEFAULT_PRI + EIO_PRI_BIAS; |
109 | |
109 | |
110 | static int respipe_osf [2], respipe [2] = { -1, -1 }; |
110 | static int respipe_osf [2], respipe [2] = { -1, -1 }; |
111 | |
111 | |
… | |
… | |
405 | } |
405 | } |
406 | } |
406 | } |
407 | |
407 | |
408 | static int poll_cb (void) |
408 | static 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 | |
|
|
424 | static 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 | |
471 | void |
485 | void |
472 | max_poll_reqs (int nreqs) |
486 | max_poll_reqs (int nreqs) |
473 | PROTOTYPE: $ |
487 | PROTOTYPE: $ |
… | |
… | |
918 | |
932 | |
919 | void |
933 | void |
920 | flush () |
934 | flush () |
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 | |