1 | /* solaris */ |
1 | /* solaris */ |
2 | #define _POSIX_PTHREAD_SEMANTICS 1 |
2 | #define _POSIX_PTHREAD_SEMANTICS 1 |
3 | |
3 | |
4 | #if __linux |
4 | #if __linux && !defined(_GNU_SOURCE) |
5 | # define _GNU_SOURCE |
5 | # define _GNU_SOURCE |
6 | #endif |
6 | #endif |
7 | |
7 | |
|
|
8 | /* just in case */ |
8 | #define _REENTRANT 1 |
9 | #define _REENTRANT 1 |
9 | |
10 | |
10 | #include <errno.h> |
11 | #include <errno.h> |
11 | |
12 | |
12 | #include "EXTERN.h" |
13 | #include "EXTERN.h" |
… | |
… | |
47 | /* used for struct dirent, AIX doesn't provide it */ |
48 | /* used for struct dirent, AIX doesn't provide it */ |
48 | #ifndef NAME_MAX |
49 | #ifndef NAME_MAX |
49 | # define NAME_MAX 4096 |
50 | # define NAME_MAX 4096 |
50 | #endif |
51 | #endif |
51 | |
52 | |
|
|
53 | #ifndef PTHREAD_STACK_MIN |
|
|
54 | /* care for broken platforms, e.g. windows */ |
|
|
55 | # define PTHREAD_STACK_MIN 16384 |
|
|
56 | #endif |
|
|
57 | |
52 | #if __ia64 |
58 | #if __ia64 |
53 | # define STACKSIZE 65536 |
59 | # define STACKSIZE 65536 |
54 | #elif __i386 || __x86_64 /* 16k is unreasonably high :( */ |
60 | #elif __i386 || __x86_64 /* 16k is unreasonably high :( */ |
55 | # define STACKSIZE PTHREAD_STACK_MIN |
61 | # define STACKSIZE PTHREAD_STACK_MIN |
56 | #else |
62 | #else |
57 | # define STACKSIZE 16384 |
63 | # define STACKSIZE 16384 |
58 | #endif |
64 | #endif |
59 | |
65 | |
|
|
66 | /* wether word reads are potentially non-atomic. |
|
|
67 | * this is conservatice, likely most arches this runs |
|
|
68 | * on have atomic word read/writes. |
|
|
69 | */ |
|
|
70 | #ifndef WORDREAD_UNSAFE |
|
|
71 | # if __i386 || __x86_64 |
|
|
72 | # define WORDREAD_UNSAFE 0 |
|
|
73 | # else |
|
|
74 | # define WORDREAD_UNSAFE 1 |
|
|
75 | # endif |
|
|
76 | #endif |
|
|
77 | |
60 | /* buffer size for various temporary buffers */ |
78 | /* buffer size for various temporary buffers */ |
61 | #define AIO_BUFSIZE 65536 |
79 | #define AIO_BUFSIZE 65536 |
62 | |
80 | |
63 | #define dBUF \ |
81 | #define dBUF \ |
|
|
82 | char *aio_buf; \ |
|
|
83 | LOCK (wrklock); \ |
64 | char *aio_buf = malloc (AIO_BUFSIZE); \ |
84 | self->dbuf = aio_buf = malloc (AIO_BUFSIZE); \ |
|
|
85 | UNLOCK (wrklock); \ |
65 | if (!aio_buf) \ |
86 | if (!aio_buf) \ |
66 | return -1; |
87 | return -1; |
67 | |
|
|
68 | #define fBUF free (aio_buf) |
|
|
69 | |
88 | |
70 | enum { |
89 | enum { |
71 | REQ_QUIT, |
90 | REQ_QUIT, |
72 | REQ_OPEN, REQ_CLOSE, |
91 | REQ_OPEN, REQ_CLOSE, |
73 | REQ_READ, REQ_WRITE, REQ_READAHEAD, |
92 | REQ_READ, REQ_WRITE, REQ_READAHEAD, |
… | |
… | |
125 | NUM_PRI = PRI_MAX + PRI_BIAS + 1, |
144 | NUM_PRI = PRI_MAX + PRI_BIAS + 1, |
126 | }; |
145 | }; |
127 | |
146 | |
128 | static int next_pri = DEFAULT_PRI + PRI_BIAS; |
147 | static int next_pri = DEFAULT_PRI + PRI_BIAS; |
129 | |
148 | |
130 | static int started, wanted; |
149 | static unsigned int started, wanted; |
131 | static volatile int nreqs; |
150 | static volatile unsigned int nreqs, nready, npending; |
132 | static int max_outstanding = 1<<30; |
151 | static volatile unsigned int max_outstanding = 0xffffffff; |
133 | static int respipe [2]; |
152 | static int respipe [2]; |
134 | |
153 | |
135 | #if __linux && defined (PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP) |
154 | #if __linux && defined (PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP) |
136 | # define AIO_MUTEX_INIT PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP |
155 | # define AIO_MUTEX_INIT PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP |
137 | #else |
156 | #else |
138 | # define AIO_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER |
157 | # define AIO_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER |
139 | #endif |
158 | #endif |
|
|
159 | |
|
|
160 | #define LOCK(mutex) pthread_mutex_lock (&(mutex)) |
|
|
161 | #define UNLOCK(mutex) pthread_mutex_unlock (&(mutex)) |
|
|
162 | |
|
|
163 | /* worker threads management */ |
|
|
164 | static pthread_mutex_t wrklock = AIO_MUTEX_INIT; |
|
|
165 | |
|
|
166 | typedef struct worker { |
|
|
167 | /* locked by wrklock */ |
|
|
168 | struct worker *prev, *next; |
|
|
169 | |
|
|
170 | pthread_t tid; |
|
|
171 | |
|
|
172 | /* locked by reslock, reqlock or wrklock */ |
|
|
173 | aio_req req; /* currently processed request */ |
|
|
174 | void *dbuf; |
|
|
175 | DIR *dirp; |
|
|
176 | } worker; |
|
|
177 | |
|
|
178 | static worker wrk_first = { &wrk_first, &wrk_first, 0 }; |
|
|
179 | |
|
|
180 | static void worker_clear (worker *wrk) |
|
|
181 | { |
|
|
182 | if (wrk->dirp) |
|
|
183 | { |
|
|
184 | closedir (wrk->dirp); |
|
|
185 | wrk->dirp = 0; |
|
|
186 | } |
|
|
187 | |
|
|
188 | if (wrk->dbuf) |
|
|
189 | { |
|
|
190 | free (wrk->dbuf); |
|
|
191 | wrk->dbuf = 0; |
|
|
192 | } |
|
|
193 | } |
|
|
194 | |
|
|
195 | static void worker_free (worker *wrk) |
|
|
196 | { |
|
|
197 | wrk->next->prev = wrk->prev; |
|
|
198 | wrk->prev->next = wrk->next; |
|
|
199 | |
|
|
200 | free (wrk); |
|
|
201 | } |
140 | |
202 | |
141 | static pthread_mutex_t reslock = AIO_MUTEX_INIT; |
203 | static pthread_mutex_t reslock = AIO_MUTEX_INIT; |
142 | static pthread_mutex_t reqlock = AIO_MUTEX_INIT; |
204 | static pthread_mutex_t reqlock = AIO_MUTEX_INIT; |
143 | static pthread_cond_t reqwait = PTHREAD_COND_INITIALIZER; |
205 | static pthread_cond_t reqwait = PTHREAD_COND_INITIALIZER; |
144 | |
206 | |
… | |
… | |
194 | } |
256 | } |
195 | |
257 | |
196 | abort (); |
258 | abort (); |
197 | } |
259 | } |
198 | |
260 | |
|
|
261 | static int poll_cb (int max); |
199 | static void req_invoke (aio_req req); |
262 | static void req_invoke (aio_req req); |
200 | static void req_free (aio_req req); |
263 | static void req_free (aio_req req); |
|
|
264 | static void req_cancel (aio_req req); |
201 | |
265 | |
202 | /* must be called at most once */ |
266 | /* must be called at most once */ |
203 | static SV *req_sv (aio_req req, const char *klass) |
267 | static SV *req_sv (aio_req req, const char *klass) |
204 | { |
268 | { |
205 | if (!req->self) |
269 | if (!req->self) |
… | |
… | |
274 | fd_set rfd; |
338 | fd_set rfd; |
275 | |
339 | |
276 | while (nreqs) |
340 | while (nreqs) |
277 | { |
341 | { |
278 | int size; |
342 | int size; |
279 | #if !(__i386 || __x86_64) /* safe without sempahore on this archs */ |
343 | if (WORDREAD_UNSAFE) LOCK (reslock); |
280 | pthread_mutex_lock (&reslock); |
|
|
281 | #endif |
|
|
282 | size = res_queue.size; |
344 | size = res_queue.size; |
283 | #if !(__i386 || __x86_64) /* safe without sempahore on this archs */ |
345 | if (WORDREAD_UNSAFE) UNLOCK (reslock); |
284 | pthread_mutex_unlock (&reslock); |
|
|
285 | #endif |
|
|
286 | |
346 | |
287 | if (size) |
347 | if (size) |
288 | return; |
348 | return; |
289 | |
349 | |
290 | FD_ZERO(&rfd); |
350 | FD_ZERO(&rfd); |
… | |
… | |
298 | { |
358 | { |
299 | dSP; |
359 | dSP; |
300 | |
360 | |
301 | if (!(req->flags & FLAG_CANCELLED) && SvOK (req->callback)) |
361 | if (!(req->flags & FLAG_CANCELLED) && SvOK (req->callback)) |
302 | { |
362 | { |
303 | errno = req->errorno; |
|
|
304 | |
|
|
305 | ENTER; |
363 | ENTER; |
306 | SAVETMPS; |
364 | SAVETMPS; |
307 | PUSHMARK (SP); |
365 | PUSHMARK (SP); |
308 | EXTEND (SP, 1); |
366 | EXTEND (SP, 1); |
309 | |
367 | |
… | |
… | |
313 | { |
371 | { |
314 | SV *rv = &PL_sv_undef; |
372 | SV *rv = &PL_sv_undef; |
315 | |
373 | |
316 | if (req->result >= 0) |
374 | if (req->result >= 0) |
317 | { |
375 | { |
|
|
376 | int i; |
318 | char *buf = req->data2ptr; |
377 | char *buf = req->data2ptr; |
319 | AV *av = newAV (); |
378 | AV *av = newAV (); |
320 | |
379 | |
321 | while (req->result) |
380 | av_extend (av, req->result - 1); |
|
|
381 | |
|
|
382 | for (i = 0; i < req->result; ++i) |
322 | { |
383 | { |
323 | SV *sv = newSVpv (buf, 0); |
384 | SV *sv = newSVpv (buf, 0); |
324 | |
385 | |
325 | av_push (av, sv); |
386 | av_store (av, i, sv); |
326 | buf += SvCUR (sv) + 1; |
387 | buf += SvCUR (sv) + 1; |
327 | req->result--; |
|
|
328 | } |
388 | } |
329 | |
389 | |
330 | rv = sv_2mortal (newRV_noinc ((SV *)av)); |
390 | rv = sv_2mortal (newRV_noinc ((SV *)av)); |
331 | } |
391 | } |
332 | |
392 | |
… | |
… | |
372 | default: |
432 | default: |
373 | PUSHs (sv_2mortal (newSViv (req->result))); |
433 | PUSHs (sv_2mortal (newSViv (req->result))); |
374 | break; |
434 | break; |
375 | } |
435 | } |
376 | |
436 | |
|
|
437 | errno = req->errorno; |
377 | |
438 | |
378 | PUTBACK; |
439 | PUTBACK; |
379 | call_sv (req->callback, G_VOID | G_EVAL); |
440 | call_sv (req->callback, G_VOID | G_EVAL); |
380 | SPAGAIN; |
441 | SPAGAIN; |
381 | |
442 | |
… | |
… | |
416 | SvREFCNT_dec (req->fh); |
477 | SvREFCNT_dec (req->fh); |
417 | SvREFCNT_dec (req->fh2); |
478 | SvREFCNT_dec (req->fh2); |
418 | SvREFCNT_dec (req->callback); |
479 | SvREFCNT_dec (req->callback); |
419 | Safefree (req->statdata); |
480 | Safefree (req->statdata); |
420 | |
481 | |
421 | if (req->type == REQ_READDIR && req->result >= 0) |
482 | if (req->type == REQ_READDIR) |
422 | free (req->data2ptr); |
483 | free (req->data2ptr); |
423 | |
484 | |
424 | Safefree (req); |
485 | Safefree (req); |
425 | } |
486 | } |
426 | |
487 | |
|
|
488 | static void req_cancel_subs (aio_req grp) |
|
|
489 | { |
|
|
490 | aio_req sub; |
|
|
491 | |
|
|
492 | if (grp->type != REQ_GROUP) |
|
|
493 | return; |
|
|
494 | |
|
|
495 | SvREFCNT_dec (grp->fh2); |
|
|
496 | grp->fh2 = 0; |
|
|
497 | |
|
|
498 | for (sub = grp->grp_first; sub; sub = sub->grp_next) |
|
|
499 | req_cancel (sub); |
|
|
500 | } |
|
|
501 | |
427 | static void req_cancel (aio_req req) |
502 | static void req_cancel (aio_req req) |
428 | { |
503 | { |
429 | req->flags |= FLAG_CANCELLED; |
504 | req->flags |= FLAG_CANCELLED; |
430 | |
505 | |
431 | if (req->type == REQ_GROUP) |
506 | req_cancel_subs (req); |
432 | { |
|
|
433 | aio_req sub; |
|
|
434 | |
|
|
435 | for (sub = req->grp_first; sub; sub = sub->grp_next) |
|
|
436 | req_cancel (sub); |
|
|
437 | } |
|
|
438 | } |
507 | } |
439 | |
508 | |
440 | static int poll_cb () |
509 | static int poll_cb (int max) |
441 | { |
510 | { |
442 | dSP; |
511 | dSP; |
443 | int count = 0; |
512 | int count = 0; |
444 | int do_croak = 0; |
513 | int do_croak = 0; |
445 | aio_req req; |
514 | aio_req req; |
446 | |
515 | |
447 | for (;;) |
516 | for (;;) |
448 | { |
517 | { |
449 | pthread_mutex_lock (&reslock); |
518 | while (max <= 0 || count < max) |
450 | req = reqq_shift (&res_queue); |
|
|
451 | |
|
|
452 | if (req) |
|
|
453 | { |
519 | { |
|
|
520 | LOCK (reslock); |
|
|
521 | req = reqq_shift (&res_queue); |
|
|
522 | |
454 | if (!res_queue.size) |
523 | if (req) |
455 | { |
524 | { |
|
|
525 | --npending; |
|
|
526 | |
|
|
527 | if (!res_queue.size) |
|
|
528 | { |
456 | /* read any signals sent by the worker threads */ |
529 | /* read any signals sent by the worker threads */ |
457 | char buf [32]; |
530 | char buf [32]; |
458 | while (read (respipe [0], buf, 32) == 32) |
531 | while (read (respipe [0], buf, 32) == 32) |
|
|
532 | ; |
459 | ; |
533 | } |
460 | } |
534 | } |
|
|
535 | |
|
|
536 | UNLOCK (reslock); |
|
|
537 | |
|
|
538 | if (!req) |
|
|
539 | break; |
|
|
540 | |
|
|
541 | --nreqs; |
|
|
542 | |
|
|
543 | if (req->type == REQ_QUIT) |
|
|
544 | --started; |
|
|
545 | else if (req->type == REQ_GROUP && req->length) |
|
|
546 | { |
|
|
547 | req->fd = 1; /* mark request as delayed */ |
|
|
548 | continue; |
|
|
549 | } |
|
|
550 | else |
|
|
551 | { |
|
|
552 | if (req->type == REQ_READ) |
|
|
553 | SvCUR_set (req->data, req->dataoffset + (req->result > 0 ? req->result : 0)); |
|
|
554 | |
|
|
555 | if (req->data2ptr && (req->type == REQ_READ || req->type == REQ_WRITE)) |
|
|
556 | SvREADONLY_off (req->data); |
|
|
557 | |
|
|
558 | if (req->statdata) |
|
|
559 | { |
|
|
560 | PL_laststype = req->type == REQ_LSTAT ? OP_LSTAT : OP_STAT; |
|
|
561 | PL_laststatval = req->result; |
|
|
562 | PL_statcache = *(req->statdata); |
|
|
563 | } |
|
|
564 | |
|
|
565 | req_invoke (req); |
|
|
566 | |
|
|
567 | count++; |
|
|
568 | } |
|
|
569 | |
|
|
570 | req_free (req); |
461 | } |
571 | } |
462 | |
572 | |
463 | pthread_mutex_unlock (&reslock); |
573 | if (nreqs <= max_outstanding) |
464 | |
|
|
465 | if (!req) |
|
|
466 | break; |
574 | break; |
467 | |
575 | |
468 | --nreqs; |
576 | poll_wait (); |
469 | |
577 | |
470 | if (req->type == REQ_QUIT) |
578 | max = 0; |
471 | started--; |
|
|
472 | else if (req->type == REQ_GROUP && req->length) |
|
|
473 | { |
|
|
474 | req->fd = 1; /* mark request as delayed */ |
|
|
475 | continue; |
|
|
476 | } |
|
|
477 | else |
|
|
478 | { |
|
|
479 | if (req->type == REQ_READ) |
|
|
480 | SvCUR_set (req->data, req->dataoffset + (req->result > 0 ? req->result : 0)); |
|
|
481 | |
|
|
482 | if (req->data2ptr && (req->type == REQ_READ || req->type == REQ_WRITE)) |
|
|
483 | SvREADONLY_off (req->data); |
|
|
484 | |
|
|
485 | if (req->statdata) |
|
|
486 | { |
|
|
487 | PL_laststype = req->type == REQ_LSTAT ? OP_LSTAT : OP_STAT; |
|
|
488 | PL_laststatval = req->result; |
|
|
489 | PL_statcache = *(req->statdata); |
|
|
490 | } |
|
|
491 | |
|
|
492 | req_invoke (req); |
|
|
493 | |
|
|
494 | count++; |
|
|
495 | } |
|
|
496 | |
|
|
497 | req_free (req); |
|
|
498 | } |
579 | } |
499 | |
580 | |
500 | return count; |
581 | return count; |
501 | } |
582 | } |
502 | |
583 | |
503 | static void *aio_proc(void *arg); |
584 | static void *aio_proc(void *arg); |
504 | |
585 | |
505 | static void start_thread (void) |
586 | static void start_thread (void) |
506 | { |
587 | { |
507 | sigset_t fullsigset, oldsigset; |
588 | sigset_t fullsigset, oldsigset; |
508 | pthread_t tid; |
|
|
509 | pthread_attr_t attr; |
589 | pthread_attr_t attr; |
|
|
590 | |
|
|
591 | worker *wrk = calloc (1, sizeof (worker)); |
|
|
592 | |
|
|
593 | if (!wrk) |
|
|
594 | croak ("unable to allocate worker thread data"); |
510 | |
595 | |
511 | pthread_attr_init (&attr); |
596 | pthread_attr_init (&attr); |
512 | pthread_attr_setstacksize (&attr, STACKSIZE); |
597 | pthread_attr_setstacksize (&attr, STACKSIZE); |
513 | pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED); |
598 | pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED); |
514 | |
599 | |
515 | sigfillset (&fullsigset); |
600 | sigfillset (&fullsigset); |
|
|
601 | |
|
|
602 | LOCK (wrklock); |
516 | sigprocmask (SIG_SETMASK, &fullsigset, &oldsigset); |
603 | sigprocmask (SIG_SETMASK, &fullsigset, &oldsigset); |
517 | |
604 | |
518 | if (pthread_create (&tid, &attr, aio_proc, 0) == 0) |
605 | if (pthread_create (&wrk->tid, &attr, aio_proc, (void *)wrk) == 0) |
|
|
606 | { |
|
|
607 | wrk->prev = &wrk_first; |
|
|
608 | wrk->next = wrk_first.next; |
|
|
609 | wrk_first.next->prev = wrk; |
|
|
610 | wrk_first.next = wrk; |
519 | started++; |
611 | ++started; |
|
|
612 | } |
|
|
613 | else |
|
|
614 | free (wrk); |
520 | |
615 | |
521 | sigprocmask (SIG_SETMASK, &oldsigset, 0); |
616 | sigprocmask (SIG_SETMASK, &oldsigset, 0); |
|
|
617 | UNLOCK (wrklock); |
522 | } |
618 | } |
523 | |
619 | |
524 | static void req_send (aio_req req) |
620 | static void req_send (aio_req req) |
525 | { |
621 | { |
526 | while (started < wanted && nreqs >= started) |
622 | while (started < wanted && nreqs >= started) |
527 | start_thread (); |
623 | start_thread (); |
528 | |
624 | |
529 | ++nreqs; |
625 | ++nreqs; |
530 | |
626 | |
531 | pthread_mutex_lock (&reqlock); |
627 | LOCK (reqlock); |
|
|
628 | ++nready; |
532 | reqq_push (&req_queue, req); |
629 | reqq_push (&req_queue, req); |
533 | pthread_cond_signal (&reqwait); |
630 | pthread_cond_signal (&reqwait); |
534 | pthread_mutex_unlock (&reqlock); |
631 | UNLOCK (reqlock); |
535 | |
|
|
536 | if (nreqs > max_outstanding) |
|
|
537 | for (;;) |
|
|
538 | { |
|
|
539 | poll_cb (); |
|
|
540 | |
|
|
541 | if (nreqs <= max_outstanding) |
|
|
542 | break; |
|
|
543 | |
|
|
544 | poll_wait (); |
|
|
545 | } |
|
|
546 | } |
632 | } |
547 | |
633 | |
548 | static void end_thread (void) |
634 | static void end_thread (void) |
549 | { |
635 | { |
550 | aio_req req; |
636 | aio_req req; |
… | |
… | |
577 | } |
663 | } |
578 | |
664 | |
579 | while (started > wanted) |
665 | while (started > wanted) |
580 | { |
666 | { |
581 | poll_wait (); |
667 | poll_wait (); |
582 | poll_cb (); |
668 | poll_cb (0); |
583 | } |
669 | } |
584 | } |
670 | } |
585 | |
671 | |
586 | static void create_pipe () |
672 | static void create_pipe () |
587 | { |
673 | { |
… | |
… | |
612 | static ssize_t pread (int fd, void *buf, size_t count, off_t offset) |
698 | static ssize_t pread (int fd, void *buf, size_t count, off_t offset) |
613 | { |
699 | { |
614 | ssize_t res; |
700 | ssize_t res; |
615 | off_t ooffset; |
701 | off_t ooffset; |
616 | |
702 | |
617 | pthread_mutex_lock (&preadwritelock); |
703 | LOCK (preadwritelock); |
618 | ooffset = lseek (fd, 0, SEEK_CUR); |
704 | ooffset = lseek (fd, 0, SEEK_CUR); |
619 | lseek (fd, offset, SEEK_SET); |
705 | lseek (fd, offset, SEEK_SET); |
620 | res = read (fd, buf, count); |
706 | res = read (fd, buf, count); |
621 | lseek (fd, ooffset, SEEK_SET); |
707 | lseek (fd, ooffset, SEEK_SET); |
622 | pthread_mutex_unlock (&preadwritelock); |
708 | UNLOCK (preadwritelock); |
623 | |
709 | |
624 | return res; |
710 | return res; |
625 | } |
711 | } |
626 | |
712 | |
627 | static ssize_t pwrite (int fd, void *buf, size_t count, off_t offset) |
713 | static ssize_t pwrite (int fd, void *buf, size_t count, off_t offset) |
628 | { |
714 | { |
629 | ssize_t res; |
715 | ssize_t res; |
630 | off_t ooffset; |
716 | off_t ooffset; |
631 | |
717 | |
632 | pthread_mutex_lock (&preadwritelock); |
718 | LOCK (preadwritelock); |
633 | ooffset = lseek (fd, 0, SEEK_CUR); |
719 | ooffset = lseek (fd, 0, SEEK_CUR); |
634 | lseek (fd, offset, SEEK_SET); |
720 | lseek (fd, offset, SEEK_SET); |
635 | res = write (fd, buf, count); |
721 | res = write (fd, buf, count); |
636 | lseek (fd, offset, SEEK_SET); |
722 | lseek (fd, offset, SEEK_SET); |
637 | pthread_mutex_unlock (&preadwritelock); |
723 | UNLOCK (preadwritelock); |
638 | |
724 | |
639 | return res; |
725 | return res; |
640 | } |
726 | } |
641 | #endif |
727 | #endif |
642 | |
728 | |
643 | #if !HAVE_FDATASYNC |
729 | #if !HAVE_FDATASYNC |
644 | # define fdatasync fsync |
730 | # define fdatasync fsync |
645 | #endif |
731 | #endif |
646 | |
732 | |
647 | #if !HAVE_READAHEAD |
733 | #if !HAVE_READAHEAD |
648 | # define readahead aio_readahead |
734 | # define readahead(fd,offset,count) aio_readahead (fd, offset, count, self) |
649 | |
735 | |
650 | static ssize_t readahead (int fd, off_t offset, size_t count) |
736 | static ssize_t aio_readahead (int fd, off_t offset, size_t count, worker *self) |
651 | { |
737 | { |
652 | dBUF; |
738 | dBUF; |
653 | |
739 | |
654 | while (count > 0) |
740 | while (count > 0) |
655 | { |
741 | { |
… | |
… | |
658 | pread (fd, aio_buf, len, offset); |
744 | pread (fd, aio_buf, len, offset); |
659 | offset += len; |
745 | offset += len; |
660 | count -= len; |
746 | count -= len; |
661 | } |
747 | } |
662 | |
748 | |
663 | fBUF; |
|
|
664 | |
|
|
665 | errno = 0; |
749 | errno = 0; |
666 | } |
750 | } |
|
|
751 | |
667 | #endif |
752 | #endif |
668 | |
753 | |
669 | #if !HAVE_READDIR_R |
754 | #if !HAVE_READDIR_R |
670 | # define readdir_r aio_readdir_r |
755 | # define readdir_r aio_readdir_r |
671 | |
756 | |
… | |
… | |
674 | static int readdir_r (DIR *dirp, struct dirent *ent, struct dirent **res) |
759 | static int readdir_r (DIR *dirp, struct dirent *ent, struct dirent **res) |
675 | { |
760 | { |
676 | struct dirent *e; |
761 | struct dirent *e; |
677 | int errorno; |
762 | int errorno; |
678 | |
763 | |
679 | pthread_mutex_lock (&readdirlock); |
764 | LOCK (readdirlock); |
680 | |
765 | |
681 | e = readdir (dirp); |
766 | e = readdir (dirp); |
682 | errorno = errno; |
767 | errorno = errno; |
683 | |
768 | |
684 | if (e) |
769 | if (e) |
… | |
… | |
687 | strcpy (ent->d_name, e->d_name); |
772 | strcpy (ent->d_name, e->d_name); |
688 | } |
773 | } |
689 | else |
774 | else |
690 | *res = 0; |
775 | *res = 0; |
691 | |
776 | |
692 | pthread_mutex_unlock (&readdirlock); |
777 | UNLOCK (readdirlock); |
693 | |
778 | |
694 | errno = errorno; |
779 | errno = errorno; |
695 | return e ? 0 : -1; |
780 | return e ? 0 : -1; |
696 | } |
781 | } |
697 | #endif |
782 | #endif |
698 | |
783 | |
699 | /* sendfile always needs emulation */ |
784 | /* sendfile always needs emulation */ |
700 | static ssize_t sendfile_ (int ofd, int ifd, off_t offset, size_t count) |
785 | static ssize_t sendfile_ (int ofd, int ifd, off_t offset, size_t count, worker *self) |
701 | { |
786 | { |
702 | ssize_t res; |
787 | ssize_t res; |
703 | |
788 | |
704 | if (!count) |
789 | if (!count) |
705 | return 0; |
790 | return 0; |
… | |
… | |
716 | { |
801 | { |
717 | off_t sbytes; |
802 | off_t sbytes; |
718 | res = sendfile (ifd, ofd, offset, count, 0, &sbytes, 0); |
803 | res = sendfile (ifd, ofd, offset, count, 0, &sbytes, 0); |
719 | |
804 | |
720 | if (res < 0 && sbytes) |
805 | if (res < 0 && sbytes) |
721 | /* maybe only on EAGAIN only: as usual, the manpage leaves you guessing */ |
806 | /* maybe only on EAGAIN: as usual, the manpage leaves you guessing */ |
722 | res = sbytes; |
807 | res = sbytes; |
723 | } |
808 | } |
724 | |
809 | |
725 | # elif __hpux |
810 | # elif __hpux |
726 | res = sendfile (ofd, ifd, offset, count, 0, 0); |
811 | res = sendfile (ofd, ifd, offset, count, 0, 0); |
… | |
… | |
782 | |
867 | |
783 | offset += cnt; |
868 | offset += cnt; |
784 | res += cnt; |
869 | res += cnt; |
785 | count -= cnt; |
870 | count -= cnt; |
786 | } |
871 | } |
787 | |
|
|
788 | fBUF; |
|
|
789 | } |
872 | } |
790 | |
873 | |
791 | return res; |
874 | return res; |
792 | } |
875 | } |
793 | |
876 | |
794 | /* read a full directory */ |
877 | /* read a full directory */ |
795 | static int scandir_ (const char *path, void **namesp) |
878 | static void scandir_ (aio_req req, worker *self) |
796 | { |
879 | { |
797 | DIR *dirp; |
880 | DIR *dirp; |
798 | union |
881 | union |
799 | { |
882 | { |
800 | struct dirent d; |
883 | struct dirent d; |
… | |
… | |
805 | int memlen = 4096; |
888 | int memlen = 4096; |
806 | int memofs = 0; |
889 | int memofs = 0; |
807 | int res = 0; |
890 | int res = 0; |
808 | int errorno; |
891 | int errorno; |
809 | |
892 | |
810 | dirp = opendir (path); |
893 | LOCK (wrklock); |
811 | if (!dirp) |
894 | self->dirp = dirp = opendir (req->dataptr); |
812 | return -1; |
|
|
813 | |
|
|
814 | u = malloc (sizeof (*u)); |
895 | self->dbuf = u = malloc (sizeof (*u)); |
815 | names = malloc (memlen); |
896 | req->data2ptr = names = malloc (memlen); |
|
|
897 | UNLOCK (wrklock); |
816 | |
898 | |
817 | if (u && names) |
899 | if (dirp && u && names) |
818 | for (;;) |
900 | for (;;) |
819 | { |
901 | { |
820 | errno = 0; |
902 | errno = 0; |
821 | readdir_r (dirp, &u->d, &entp); |
903 | readdir_r (dirp, &u->d, &entp); |
822 | |
904 | |
… | |
… | |
832 | res++; |
914 | res++; |
833 | |
915 | |
834 | while (memofs + len > memlen) |
916 | while (memofs + len > memlen) |
835 | { |
917 | { |
836 | memlen *= 2; |
918 | memlen *= 2; |
|
|
919 | LOCK (wrklock); |
837 | names = realloc (names, memlen); |
920 | req->data2ptr = names = realloc (names, memlen); |
|
|
921 | UNLOCK (wrklock); |
|
|
922 | |
838 | if (!names) |
923 | if (!names) |
839 | break; |
924 | break; |
840 | } |
925 | } |
841 | |
926 | |
842 | memcpy (names + memofs, name, len); |
927 | memcpy (names + memofs, name, len); |
843 | memofs += len; |
928 | memofs += len; |
844 | } |
929 | } |
845 | } |
930 | } |
846 | |
931 | |
847 | errorno = errno; |
|
|
848 | free (u); |
|
|
849 | closedir (dirp); |
|
|
850 | |
|
|
851 | if (errorno) |
932 | if (errno) |
852 | { |
|
|
853 | free (names); |
|
|
854 | errno = errorno; |
|
|
855 | res = -1; |
933 | res = -1; |
856 | } |
934 | |
857 | |
935 | req->result = res; |
858 | *namesp = (void *)names; |
|
|
859 | return res; |
|
|
860 | } |
936 | } |
861 | |
937 | |
862 | /*****************************************************************************/ |
938 | /*****************************************************************************/ |
863 | |
939 | |
864 | static void *aio_proc (void *thr_arg) |
940 | static void *aio_proc (void *thr_arg) |
865 | { |
941 | { |
866 | aio_req req; |
942 | aio_req req; |
867 | int type; |
943 | int type; |
|
|
944 | worker *self = (worker *)thr_arg; |
868 | |
945 | |
869 | do |
946 | do |
870 | { |
947 | { |
871 | pthread_mutex_lock (&reqlock); |
948 | LOCK (reqlock); |
872 | |
949 | |
873 | for (;;) |
950 | for (;;) |
874 | { |
951 | { |
875 | req = reqq_shift (&req_queue); |
952 | self->req = req = reqq_shift (&req_queue); |
876 | |
953 | |
877 | if (req) |
954 | if (req) |
878 | break; |
955 | break; |
879 | |
956 | |
880 | pthread_cond_wait (&reqwait, &reqlock); |
957 | pthread_cond_wait (&reqwait, &reqlock); |
881 | } |
958 | } |
882 | |
959 | |
883 | pthread_mutex_unlock (&reqlock); |
960 | --nready; |
|
|
961 | |
|
|
962 | UNLOCK (reqlock); |
884 | |
963 | |
885 | errno = 0; /* strictly unnecessary */ |
964 | errno = 0; /* strictly unnecessary */ |
886 | type = req->type; /* remember type for QUIT check */ |
965 | type = req->type; /* remember type for QUIT check */ |
887 | |
966 | |
888 | if (!(req->flags & FLAG_CANCELLED)) |
967 | if (!(req->flags & FLAG_CANCELLED)) |
… | |
… | |
890 | { |
969 | { |
891 | case REQ_READ: req->result = pread (req->fd, req->dataptr, req->length, req->offset); break; |
970 | case REQ_READ: req->result = pread (req->fd, req->dataptr, req->length, req->offset); break; |
892 | case REQ_WRITE: req->result = pwrite (req->fd, req->dataptr, req->length, req->offset); break; |
971 | case REQ_WRITE: req->result = pwrite (req->fd, req->dataptr, req->length, req->offset); break; |
893 | |
972 | |
894 | case REQ_READAHEAD: req->result = readahead (req->fd, req->offset, req->length); break; |
973 | case REQ_READAHEAD: req->result = readahead (req->fd, req->offset, req->length); break; |
895 | case REQ_SENDFILE: req->result = sendfile_ (req->fd, req->fd2, req->offset, req->length); break; |
974 | case REQ_SENDFILE: req->result = sendfile_ (req->fd, req->fd2, req->offset, req->length, self); break; |
896 | |
975 | |
897 | case REQ_STAT: req->result = stat (req->dataptr, req->statdata); break; |
976 | case REQ_STAT: req->result = stat (req->dataptr, req->statdata); break; |
898 | case REQ_LSTAT: req->result = lstat (req->dataptr, req->statdata); break; |
977 | case REQ_LSTAT: req->result = lstat (req->dataptr, req->statdata); break; |
899 | case REQ_FSTAT: req->result = fstat (req->fd , req->statdata); break; |
978 | case REQ_FSTAT: req->result = fstat (req->fd , req->statdata); break; |
900 | |
979 | |
… | |
… | |
906 | case REQ_LINK: req->result = link (req->data2ptr, req->dataptr); break; |
985 | case REQ_LINK: req->result = link (req->data2ptr, req->dataptr); break; |
907 | case REQ_SYMLINK: req->result = symlink (req->data2ptr, req->dataptr); break; |
986 | case REQ_SYMLINK: req->result = symlink (req->data2ptr, req->dataptr); break; |
908 | |
987 | |
909 | case REQ_FDATASYNC: req->result = fdatasync (req->fd); break; |
988 | case REQ_FDATASYNC: req->result = fdatasync (req->fd); break; |
910 | case REQ_FSYNC: req->result = fsync (req->fd); break; |
989 | case REQ_FSYNC: req->result = fsync (req->fd); break; |
911 | case REQ_READDIR: req->result = scandir_ (req->dataptr, &req->data2ptr); break; |
990 | case REQ_READDIR: scandir_ (req, self); break; |
912 | |
991 | |
913 | case REQ_BUSY: |
992 | case REQ_BUSY: |
914 | { |
993 | { |
915 | struct timeval tv; |
994 | struct timeval tv; |
916 | |
995 | |
… | |
… | |
930 | break; |
1009 | break; |
931 | } |
1010 | } |
932 | |
1011 | |
933 | req->errorno = errno; |
1012 | req->errorno = errno; |
934 | |
1013 | |
935 | pthread_mutex_lock (&reslock); |
1014 | LOCK (reslock); |
|
|
1015 | |
|
|
1016 | ++npending; |
936 | |
1017 | |
937 | if (!reqq_push (&res_queue, req)) |
1018 | if (!reqq_push (&res_queue, req)) |
938 | /* write a dummy byte to the pipe so fh becomes ready */ |
1019 | /* write a dummy byte to the pipe so fh becomes ready */ |
939 | write (respipe [1], &respipe, 1); |
1020 | write (respipe [1], &respipe, 1); |
940 | |
1021 | |
941 | pthread_mutex_unlock (&reslock); |
1022 | self->req = 0; |
|
|
1023 | worker_clear (self); |
|
|
1024 | |
|
|
1025 | UNLOCK (reslock); |
942 | } |
1026 | } |
943 | while (type != REQ_QUIT); |
1027 | while (type != REQ_QUIT); |
944 | |
1028 | |
|
|
1029 | LOCK (wrklock); |
|
|
1030 | worker_free (self); |
|
|
1031 | UNLOCK (wrklock); |
|
|
1032 | |
945 | return 0; |
1033 | return 0; |
946 | } |
1034 | } |
947 | |
1035 | |
948 | /*****************************************************************************/ |
1036 | /*****************************************************************************/ |
949 | |
1037 | |
950 | static void atfork_prepare (void) |
1038 | static void atfork_prepare (void) |
951 | { |
1039 | { |
952 | pthread_mutex_lock (&reqlock); |
1040 | LOCK (wrklock); |
953 | pthread_mutex_lock (&reslock); |
1041 | LOCK (reqlock); |
|
|
1042 | LOCK (reslock); |
954 | #if !HAVE_PREADWRITE |
1043 | #if !HAVE_PREADWRITE |
955 | pthread_mutex_lock (&preadwritelock); |
1044 | LOCK (preadwritelock); |
956 | #endif |
1045 | #endif |
957 | #if !HAVE_READDIR_R |
1046 | #if !HAVE_READDIR_R |
958 | pthread_mutex_lock (&readdirlock); |
1047 | LOCK (readdirlock); |
959 | #endif |
1048 | #endif |
960 | } |
1049 | } |
961 | |
1050 | |
962 | static void atfork_parent (void) |
1051 | static void atfork_parent (void) |
963 | { |
1052 | { |
964 | #if !HAVE_READDIR_R |
1053 | #if !HAVE_READDIR_R |
965 | pthread_mutex_unlock (&readdirlock); |
1054 | UNLOCK (readdirlock); |
966 | #endif |
1055 | #endif |
967 | #if !HAVE_PREADWRITE |
1056 | #if !HAVE_PREADWRITE |
968 | pthread_mutex_unlock (&preadwritelock); |
1057 | UNLOCK (preadwritelock); |
969 | #endif |
1058 | #endif |
970 | pthread_mutex_unlock (&reslock); |
1059 | UNLOCK (reslock); |
971 | pthread_mutex_unlock (&reqlock); |
1060 | UNLOCK (reqlock); |
|
|
1061 | UNLOCK (wrklock); |
972 | } |
1062 | } |
973 | |
1063 | |
974 | static void atfork_child (void) |
1064 | static void atfork_child (void) |
975 | { |
1065 | { |
976 | aio_req prv; |
1066 | aio_req prv; |
977 | |
|
|
978 | started = 0; |
|
|
979 | |
1067 | |
980 | while (prv = reqq_shift (&req_queue)) |
1068 | while (prv = reqq_shift (&req_queue)) |
981 | req_free (prv); |
1069 | req_free (prv); |
982 | |
1070 | |
983 | while (prv = reqq_shift (&res_queue)) |
1071 | while (prv = reqq_shift (&res_queue)) |
984 | req_free (prv); |
1072 | req_free (prv); |
985 | |
1073 | |
|
|
1074 | while (wrk_first.next != &wrk_first) |
|
|
1075 | { |
|
|
1076 | worker *wrk = wrk_first.next; |
|
|
1077 | |
|
|
1078 | if (wrk->req) |
|
|
1079 | req_free (wrk->req); |
|
|
1080 | |
|
|
1081 | worker_clear (wrk); |
|
|
1082 | worker_free (wrk); |
|
|
1083 | } |
|
|
1084 | |
|
|
1085 | started = 0; |
|
|
1086 | nreqs = 0; |
|
|
1087 | |
986 | close (respipe [0]); |
1088 | close (respipe [0]); |
987 | close (respipe [1]); |
1089 | close (respipe [1]); |
988 | create_pipe (); |
1090 | create_pipe (); |
989 | |
1091 | |
990 | atfork_parent (); |
1092 | atfork_parent (); |
… | |
… | |
1025 | create_pipe (); |
1127 | create_pipe (); |
1026 | pthread_atfork (atfork_prepare, atfork_parent, atfork_child); |
1128 | pthread_atfork (atfork_prepare, atfork_parent, atfork_child); |
1027 | } |
1129 | } |
1028 | |
1130 | |
1029 | void |
1131 | void |
1030 | min_parallel (nthreads) |
1132 | min_parallel (int nthreads) |
1031 | int nthreads |
|
|
1032 | PROTOTYPE: $ |
1133 | PROTOTYPE: $ |
1033 | |
1134 | |
1034 | void |
1135 | void |
1035 | max_parallel (nthreads) |
1136 | max_parallel (int nthreads) |
1036 | int nthreads |
|
|
1037 | PROTOTYPE: $ |
1137 | PROTOTYPE: $ |
1038 | |
1138 | |
1039 | int |
1139 | int |
1040 | max_outstanding (nreqs) |
1140 | max_outstanding (int maxreqs) |
1041 | int nreqs |
1141 | PROTOTYPE: $ |
1042 | PROTOTYPE: $ |
|
|
1043 | CODE: |
1142 | CODE: |
1044 | RETVAL = max_outstanding; |
1143 | RETVAL = max_outstanding; |
1045 | max_outstanding = nreqs; |
1144 | max_outstanding = maxreqs; |
|
|
1145 | OUTPUT: |
|
|
1146 | RETVAL |
1046 | |
1147 | |
1047 | void |
1148 | void |
1048 | aio_open (pathname,flags,mode,callback=&PL_sv_undef) |
1149 | aio_open (pathname,flags,mode,callback=&PL_sv_undef) |
1049 | SV * pathname |
1150 | SV * pathname |
1050 | int flags |
1151 | int flags |
… | |
… | |
1305 | req->type = REQ_NOP; |
1406 | req->type = REQ_NOP; |
1306 | |
1407 | |
1307 | REQ_SEND; |
1408 | REQ_SEND; |
1308 | } |
1409 | } |
1309 | |
1410 | |
1310 | void |
1411 | int |
1311 | aioreq_pri (int pri = DEFAULT_PRI) |
1412 | aioreq_pri (int pri = 0) |
1312 | CODE: |
1413 | PROTOTYPE: ;$ |
|
|
1414 | CODE: |
|
|
1415 | RETVAL = next_pri - PRI_BIAS; |
|
|
1416 | if (items > 0) |
|
|
1417 | { |
1313 | if (pri < PRI_MIN) pri = PRI_MIN; |
1418 | if (pri < PRI_MIN) pri = PRI_MIN; |
1314 | if (pri > PRI_MAX) pri = PRI_MAX; |
1419 | if (pri > PRI_MAX) pri = PRI_MAX; |
1315 | next_pri = pri + PRI_BIAS; |
1420 | next_pri = pri + PRI_BIAS; |
|
|
1421 | } |
|
|
1422 | OUTPUT: |
|
|
1423 | RETVAL |
1316 | |
1424 | |
1317 | void |
1425 | void |
1318 | aioreq_nice (int nice = 0) |
1426 | aioreq_nice (int nice = 0) |
1319 | CODE: |
1427 | CODE: |
1320 | nice = next_pri - nice; |
1428 | nice = next_pri - nice; |
1321 | if (nice < PRI_MIN) nice = PRI_MIN; |
1429 | if (nice < PRI_MIN) nice = PRI_MIN; |
1322 | if (nice > PRI_MAX) nice = PRI_MAX; |
1430 | if (nice > PRI_MAX) nice = PRI_MAX; |
1323 | next_pri = nice + PRI_BIAS; |
1431 | next_pri = nice + PRI_BIAS; |
1324 | |
1432 | |
1325 | void |
1433 | void |
1326 | flush () |
1434 | flush () |
1327 | PROTOTYPE: |
1435 | PROTOTYPE: |
1328 | CODE: |
1436 | CODE: |
1329 | while (nreqs) |
1437 | while (nreqs) |
1330 | { |
1438 | { |
1331 | poll_wait (); |
1439 | poll_wait (); |
1332 | poll_cb (); |
1440 | poll_cb (0); |
1333 | } |
1441 | } |
1334 | |
1442 | |
1335 | void |
1443 | void |
1336 | poll() |
1444 | poll() |
1337 | PROTOTYPE: |
1445 | PROTOTYPE: |
1338 | CODE: |
1446 | CODE: |
1339 | if (nreqs) |
1447 | if (nreqs) |
1340 | { |
1448 | { |
1341 | poll_wait (); |
1449 | poll_wait (); |
1342 | poll_cb (); |
1450 | poll_cb (0); |
1343 | } |
1451 | } |
1344 | |
1452 | |
1345 | int |
1453 | int |
1346 | poll_fileno() |
1454 | poll_fileno() |
1347 | PROTOTYPE: |
1455 | PROTOTYPE: |
… | |
… | |
1352 | |
1460 | |
1353 | int |
1461 | int |
1354 | poll_cb(...) |
1462 | poll_cb(...) |
1355 | PROTOTYPE: |
1463 | PROTOTYPE: |
1356 | CODE: |
1464 | CODE: |
1357 | RETVAL = poll_cb (); |
1465 | RETVAL = poll_cb (0); |
|
|
1466 | OUTPUT: |
|
|
1467 | RETVAL |
|
|
1468 | |
|
|
1469 | int |
|
|
1470 | poll_some(int max = 0) |
|
|
1471 | PROTOTYPE: $ |
|
|
1472 | CODE: |
|
|
1473 | RETVAL = poll_cb (max); |
1358 | OUTPUT: |
1474 | OUTPUT: |
1359 | RETVAL |
1475 | RETVAL |
1360 | |
1476 | |
1361 | void |
1477 | void |
1362 | poll_wait() |
1478 | poll_wait() |
… | |
… | |
1371 | CODE: |
1487 | CODE: |
1372 | RETVAL = nreqs; |
1488 | RETVAL = nreqs; |
1373 | OUTPUT: |
1489 | OUTPUT: |
1374 | RETVAL |
1490 | RETVAL |
1375 | |
1491 | |
|
|
1492 | int |
|
|
1493 | nready() |
|
|
1494 | PROTOTYPE: |
|
|
1495 | CODE: |
|
|
1496 | if (WORDREAD_UNSAFE) LOCK (reqlock); |
|
|
1497 | RETVAL = nready; |
|
|
1498 | if (WORDREAD_UNSAFE) UNLOCK (reqlock); |
|
|
1499 | OUTPUT: |
|
|
1500 | RETVAL |
|
|
1501 | |
|
|
1502 | int |
|
|
1503 | npending() |
|
|
1504 | PROTOTYPE: |
|
|
1505 | CODE: |
|
|
1506 | if (WORDREAD_UNSAFE) LOCK (reslock); |
|
|
1507 | RETVAL = npending; |
|
|
1508 | if (WORDREAD_UNSAFE) UNLOCK (reslock); |
|
|
1509 | OUTPUT: |
|
|
1510 | RETVAL |
|
|
1511 | |
1376 | PROTOTYPES: DISABLE |
1512 | PROTOTYPES: DISABLE |
1377 | |
1513 | |
1378 | MODULE = IO::AIO PACKAGE = IO::AIO::REQ |
1514 | MODULE = IO::AIO PACKAGE = IO::AIO::REQ |
1379 | |
1515 | |
1380 | void |
1516 | void |
… | |
… | |
1422 | } |
1558 | } |
1423 | } |
1559 | } |
1424 | } |
1560 | } |
1425 | |
1561 | |
1426 | void |
1562 | void |
|
|
1563 | cancel_subs (aio_req_ornot req) |
|
|
1564 | CODE: |
|
|
1565 | req_cancel_subs (req); |
|
|
1566 | |
|
|
1567 | void |
1427 | result (aio_req grp, ...) |
1568 | result (aio_req grp, ...) |
1428 | CODE: |
1569 | CODE: |
1429 | { |
1570 | { |
1430 | int i; |
1571 | int i; |
|
|
1572 | AV *av; |
|
|
1573 | |
|
|
1574 | grp->errorno = errno; |
|
|
1575 | |
1431 | AV *av = newAV (); |
1576 | av = newAV (); |
1432 | |
1577 | |
1433 | for (i = 1; i < items; ++i ) |
1578 | for (i = 1; i < items; ++i ) |
1434 | av_push (av, newSVsv (ST (i))); |
1579 | av_push (av, newSVsv (ST (i))); |
1435 | |
1580 | |
1436 | SvREFCNT_dec (grp->data); |
1581 | SvREFCNT_dec (grp->data); |
1437 | grp->data = (SV *)av; |
1582 | grp->data = (SV *)av; |
1438 | } |
1583 | } |
|
|
1584 | |
|
|
1585 | void |
|
|
1586 | errno (aio_req grp, int errorno = errno) |
|
|
1587 | CODE: |
|
|
1588 | grp->errorno = errorno; |
1439 | |
1589 | |
1440 | void |
1590 | void |
1441 | limit (aio_req grp, int limit) |
1591 | limit (aio_req grp, int limit) |
1442 | CODE: |
1592 | CODE: |
1443 | grp->fd2 = limit; |
1593 | grp->fd2 = limit; |