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.58 by root, Mon Oct 23 18:48:08 2006 UTC vs.
Revision 1.78 by root, Thu Oct 26 14:35:34 2006 UTC

1/* solaris */
2#define _POSIX_PTHREAD_SEMANTICS 1
3
4#if __linux && !defined(_GNU_SOURCE)
5# define _GNU_SOURCE
6#endif
7
8/* just in case */
1#define _REENTRANT 1 9#define _REENTRANT 1
10
2#include <errno.h> 11#include <errno.h>
3 12
4#include "EXTERN.h" 13#include "EXTERN.h"
5#include "perl.h" 14#include "perl.h"
6#include "XSUB.h" 15#include "XSUB.h"
39/* used for struct dirent, AIX doesn't provide it */ 48/* used for struct dirent, AIX doesn't provide it */
40#ifndef NAME_MAX 49#ifndef NAME_MAX
41# define NAME_MAX 4096 50# define NAME_MAX 4096
42#endif 51#endif
43 52
53#ifndef PTHREAD_STACK_MIN
54/* care for broken platforms, e.g. windows */
55# define PTHREAD_STACK_MIN 16384
56#endif
57
44#if __ia64 58#if __ia64
45# define STACKSIZE 65536 59# define STACKSIZE 65536
60#elif __i386 || __x86_64 /* 16k is unreasonably high :( */
61# define STACKSIZE PTHREAD_STACK_MIN
46#else 62#else
47# define STACKSIZE 8192 63# define STACKSIZE 16384
48#endif 64#endif
65
66/* buffer size for various temporary buffers */
67#define AIO_BUFSIZE 65536
68
69#define dBUF \
70 char *aio_buf; \
71 LOCK (wrklock); \
72 self->dbuf = aio_buf = malloc (AIO_BUFSIZE); \
73 UNLOCK (wrklock); \
74 if (!aio_buf) \
75 return -1;
49 76
50enum { 77enum {
51 REQ_QUIT, 78 REQ_QUIT,
52 REQ_OPEN, REQ_CLOSE, 79 REQ_OPEN, REQ_CLOSE,
53 REQ_READ, REQ_WRITE, REQ_READAHEAD, 80 REQ_READ, REQ_WRITE, REQ_READAHEAD,
56 REQ_FSYNC, REQ_FDATASYNC, 83 REQ_FSYNC, REQ_FDATASYNC,
57 REQ_UNLINK, REQ_RMDIR, REQ_RENAME, 84 REQ_UNLINK, REQ_RMDIR, REQ_RENAME,
58 REQ_READDIR, 85 REQ_READDIR,
59 REQ_LINK, REQ_SYMLINK, 86 REQ_LINK, REQ_SYMLINK,
60 REQ_GROUP, REQ_NOP, 87 REQ_GROUP, REQ_NOP,
61 REQ_SLEEP, 88 REQ_BUSY,
62}; 89};
63 90
64#define AIO_REQ_KLASS "IO::AIO::REQ" 91#define AIO_REQ_KLASS "IO::AIO::REQ"
65#define AIO_GRP_KLASS "IO::AIO::GRP" 92#define AIO_GRP_KLASS "IO::AIO::GRP"
66 93
67typedef struct aio_cb 94typedef struct aio_cb
68{ 95{
69 struct aio_cb *volatile next; 96 struct aio_cb *volatile next;
70
71 struct aio_cb *grp, *grp_prev, *grp_next, *grp_first;
72
73 SV *self; /* the perl counterpart of this request, if any */
74 97
75 SV *data, *callback; 98 SV *data, *callback;
76 SV *fh, *fh2; 99 SV *fh, *fh2;
77 void *dataptr, *data2ptr; 100 void *dataptr, *data2ptr;
78 Stat_t *statdata; 101 Stat_t *statdata;
79 off_t offset; 102 off_t offset;
80 size_t length; 103 size_t length;
81 ssize_t result; 104 ssize_t result;
82 105
106 STRLEN dataoffset;
83 int type; 107 int type;
84 int fd, fd2; 108 int fd, fd2;
85 int errorno; 109 int errorno;
86 STRLEN dataoffset;
87 mode_t mode; /* open */ 110 mode_t mode; /* open */
111
112 unsigned char flags;
88 unsigned char pri; 113 unsigned char pri;
89 unsigned char flags; 114
115 SV *self; /* the perl counterpart of this request, if any */
116 struct aio_cb *grp, *grp_prev, *grp_next, *grp_first;
90} aio_cb; 117} aio_cb;
91 118
92enum { 119enum {
93 FLAG_CANCELLED = 0x01, 120 FLAG_CANCELLED = 0x01,
94}; 121};
95 122
96typedef aio_cb *aio_req; 123typedef aio_cb *aio_req;
97typedef aio_cb *aio_req_ornot; 124typedef aio_cb *aio_req_ornot;
98 125
126enum {
127 PRI_MIN = -4,
128 PRI_MAX = 4,
129
130 DEFAULT_PRI = 0,
131 PRI_BIAS = -PRI_MIN,
132 NUM_PRI = PRI_MAX + PRI_BIAS + 1,
133};
134
135static int next_pri = DEFAULT_PRI + PRI_BIAS;
136
99static int started, wanted; 137static unsigned int started, wanted;
100static volatile int nreqs; 138static volatile unsigned int nreqs;
101static int max_outstanding = 1<<30; 139static volatile unsigned int max_outstanding = 0xffffffff;
102static int respipe [2]; 140static int respipe [2];
103 141
142#if __linux && defined (PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP)
143# define AIO_MUTEX_INIT PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP
144#else
145# define AIO_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER
146#endif
147
148#define LOCK(mutex) pthread_mutex_lock (&(mutex))
149#define UNLOCK(mutex) pthread_mutex_unlock (&(mutex))
150
151/* worker threads management */
152static pthread_mutex_t wrklock = AIO_MUTEX_INIT;
153
154typedef struct worker {
155 /* locked by wrklock */
156 struct worker *prev, *next;
157
158 pthread_t tid;
159
160 /* locked by reslock, reqlock or wrklock */
161 aio_req req; /* currently processed request */
162 void *dbuf;
163 DIR *dirp;
164} worker;
165
166static worker wrk_first = { &wrk_first, &wrk_first, 0 };
167
168static void worker_clear (worker *wrk)
169{
170 if (wrk->dirp)
171 {
172 closedir (wrk->dirp);
173 wrk->dirp = 0;
174 }
175
176 if (wrk->dbuf)
177 {
178 free (wrk->dbuf);
179 wrk->dbuf = 0;
180 }
181}
182
183static void worker_free (worker *wrk)
184{
185 wrk->next->prev = wrk->prev;
186 wrk->prev->next = wrk->next;
187
188 free (wrk);
189}
190
104static pthread_mutex_t reslock = PTHREAD_MUTEX_INITIALIZER; 191static pthread_mutex_t reslock = AIO_MUTEX_INIT;
105static pthread_mutex_t reqlock = PTHREAD_MUTEX_INITIALIZER; 192static pthread_mutex_t reqlock = AIO_MUTEX_INIT;
106static pthread_cond_t reqwait = PTHREAD_COND_INITIALIZER; 193static pthread_cond_t reqwait = PTHREAD_COND_INITIALIZER;
107 194
108static volatile aio_req reqs, reqe; /* queue start, queue end */ 195/*
109static volatile aio_req ress, rese; /* queue start, queue end */ 196 * a somewhat faster data structure might be nice, but
197 * with 8 priorities this actually needs <20 insns
198 * per shift, the most expensive operation.
199 */
200typedef struct {
201 aio_req qs[NUM_PRI], qe[NUM_PRI]; /* qstart, qend */
202 int size;
203} reqq;
110 204
205static reqq req_queue;
206static reqq res_queue;
207
208int reqq_push (reqq *q, aio_req req)
209{
210 int pri = req->pri;
211 req->next = 0;
212
213 if (q->qe[pri])
214 {
215 q->qe[pri]->next = req;
216 q->qe[pri] = req;
217 }
218 else
219 q->qe[pri] = q->qs[pri] = req;
220
221 return q->size++;
222}
223
224aio_req reqq_shift (reqq *q)
225{
226 int pri;
227
228 if (!q->size)
229 return 0;
230
231 --q->size;
232
233 for (pri = NUM_PRI; pri--; )
234 {
235 aio_req req = q->qs[pri];
236
237 if (req)
238 {
239 if (!(q->qs[pri] = req->next))
240 q->qe[pri] = 0;
241
242 return req;
243 }
244 }
245
246 abort ();
247}
248
249static int poll_cb (int max);
111static void req_invoke (aio_req req); 250static void req_invoke (aio_req req);
112static void req_free (aio_req req); 251static void req_free (aio_req req);
252static void req_cancel (aio_req req);
113 253
114/* must be called at most once */ 254/* must be called at most once */
115static SV *req_sv (aio_req req, const char *klass) 255static SV *req_sv (aio_req req, const char *klass)
116{ 256{
117 if (!req->self) 257 if (!req->self)
148 ENTER; 288 ENTER;
149 SAVETMPS; 289 SAVETMPS;
150 PUSHMARK (SP); 290 PUSHMARK (SP);
151 XPUSHs (req_sv (grp, AIO_GRP_KLASS)); 291 XPUSHs (req_sv (grp, AIO_GRP_KLASS));
152 PUTBACK; 292 PUTBACK;
153 call_sv (grp->fh2, G_VOID | G_EVAL); 293 call_sv (grp->fh2, G_VOID | G_EVAL | G_KEEPERR);
154 SPAGAIN; 294 SPAGAIN;
155 FREETMPS; 295 FREETMPS;
156 LEAVE; 296 LEAVE;
157 } 297 }
158 298
181 } 321 }
182} 322}
183 323
184static void poll_wait () 324static void poll_wait ()
185{ 325{
186 if (nreqs && !ress)
187 {
188 fd_set rfd; 326 fd_set rfd;
327
328 while (nreqs)
329 {
330 int size;
331#if !(__i386 || __x86_64) /* safe without sempahore on these archs */
332 LOCK (reslock);
333#endif
334 size = res_queue.size;
335#if !(__i386 || __x86_64) /* safe without sempahore on these archs */
336 UNLOCK (reslock);
337#endif
338
339 if (size)
340 return;
341
189 FD_ZERO(&rfd); 342 FD_ZERO(&rfd);
190 FD_SET(respipe [0], &rfd); 343 FD_SET(respipe [0], &rfd);
191 344
192 select (respipe [0] + 1, &rfd, 0, 0, 0); 345 select (respipe [0] + 1, &rfd, 0, 0, 0);
193 } 346 }
194} 347}
195 348
196static void req_invoke (aio_req req) 349static void req_invoke (aio_req req)
197{ 350{
198 dSP; 351 dSP;
199 int errorno = errno;
200 352
201 if (req->flags & FLAG_CANCELLED || !SvOK (req->callback)) 353 if (!(req->flags & FLAG_CANCELLED) && SvOK (req->callback))
202 return; 354 {
203
204 errno = req->errorno; 355 errno = req->errorno;
205 356
206 ENTER; 357 ENTER;
207 SAVETMPS; 358 SAVETMPS;
208 PUSHMARK (SP); 359 PUSHMARK (SP);
209 EXTEND (SP, 1); 360 EXTEND (SP, 1);
210 361
211 switch (req->type) 362 switch (req->type)
212 {
213 case REQ_READDIR:
214 { 363 {
215 SV *rv = &PL_sv_undef; 364 case REQ_READDIR:
216
217 if (req->result >= 0)
218 { 365 {
219 char *buf = req->data2ptr; 366 SV *rv = &PL_sv_undef;
220 AV *av = newAV ();
221 367
222 while (req->result) 368 if (req->result >= 0)
223 { 369 {
370 int i;
371 char *buf = req->data2ptr;
372 AV *av = newAV ();
373
374 av_extend (av, req->result - 1);
375
376 for (i = 0; i < req->result; ++i)
377 {
224 SV *sv = newSVpv (buf, 0); 378 SV *sv = newSVpv (buf, 0);
225 379
226 av_push (av, sv); 380 av_store (av, i, sv);
227 buf += SvCUR (sv) + 1; 381 buf += SvCUR (sv) + 1;
228 req->result--; 382 }
383
384 rv = sv_2mortal (newRV_noinc ((SV *)av));
229 } 385 }
230 386
231 rv = sv_2mortal (newRV_noinc ((SV *)av)); 387 PUSHs (rv);
232 } 388 }
389 break;
233 390
234 PUSHs (rv); 391 case REQ_OPEN:
392 {
393 /* convert fd to fh */
394 SV *fh;
395
396 PUSHs (sv_2mortal (newSViv (req->result)));
397 PUTBACK;
398 call_pv ("IO::AIO::_fd2fh", G_SCALAR | G_EVAL);
399 SPAGAIN;
400
401 fh = SvREFCNT_inc (POPs);
402
403 PUSHMARK (SP);
404 XPUSHs (sv_2mortal (fh));
405 }
406 break;
407
408 case REQ_GROUP:
409 req->fd = 2; /* mark group as finished */
410
411 if (req->data)
412 {
413 int i;
414 AV *av = (AV *)req->data;
415
416 EXTEND (SP, AvFILL (av) + 1);
417 for (i = 0; i <= AvFILL (av); ++i)
418 PUSHs (*av_fetch (av, i, 0));
419 }
420 break;
421
422 case REQ_NOP:
423 case REQ_BUSY:
424 break;
425
426 default:
427 PUSHs (sv_2mortal (newSViv (req->result)));
428 break;
235 } 429 }
236 break;
237 430
238 case REQ_OPEN:
239 {
240 /* convert fd to fh */
241 SV *fh;
242 431
243 PUSHs (sv_2mortal (newSViv (req->result)));
244 PUTBACK; 432 PUTBACK;
245 call_pv ("IO::AIO::_fd2fh", G_SCALAR | G_EVAL);
246 SPAGAIN;
247
248 fh = SvREFCNT_inc (POPs);
249
250 PUSHMARK (SP);
251 XPUSHs (sv_2mortal (fh));
252 }
253 break;
254
255 case REQ_GROUP:
256 req->fd = 2; /* mark group as finished */
257
258 if (req->data)
259 {
260 int i;
261 AV *av = (AV *)req->data;
262
263 EXTEND (SP, AvFILL (av) + 1);
264 for (i = 0; i <= AvFILL (av); ++i)
265 PUSHs (*av_fetch (av, i, 0));
266 }
267 break;
268
269 case REQ_NOP:
270 case REQ_SLEEP:
271 break;
272
273 default:
274 PUSHs (sv_2mortal (newSViv (req->result)));
275 break;
276 }
277
278
279 PUTBACK;
280 call_sv (req->callback, G_VOID | G_EVAL); 433 call_sv (req->callback, G_VOID | G_EVAL);
281 SPAGAIN; 434 SPAGAIN;
282 435
283 FREETMPS; 436 FREETMPS;
284 LEAVE; 437 LEAVE;
285
286 errno = errorno;
287
288 if (SvTRUE (ERRSV))
289 { 438 }
290 req_free (req);
291 croak (0);
292 }
293}
294 439
295static void req_free (aio_req req)
296{
297 if (req->grp) 440 if (req->grp)
298 { 441 {
299 aio_req grp = req->grp; 442 aio_req grp = req->grp;
300 443
301 /* unlink request */ 444 /* unlink request */
306 grp->grp_first = req->grp_next; 449 grp->grp_first = req->grp_next;
307 450
308 aio_grp_dec (grp); 451 aio_grp_dec (grp);
309 } 452 }
310 453
454 if (SvTRUE (ERRSV))
455 {
456 req_free (req);
457 croak (0);
458 }
459}
460
461static void req_free (aio_req req)
462{
311 if (req->self) 463 if (req->self)
312 { 464 {
313 sv_unmagic (req->self, PERL_MAGIC_ext); 465 sv_unmagic (req->self, PERL_MAGIC_ext);
314 SvREFCNT_dec (req->self); 466 SvREFCNT_dec (req->self);
315 } 467 }
318 SvREFCNT_dec (req->fh); 470 SvREFCNT_dec (req->fh);
319 SvREFCNT_dec (req->fh2); 471 SvREFCNT_dec (req->fh2);
320 SvREFCNT_dec (req->callback); 472 SvREFCNT_dec (req->callback);
321 Safefree (req->statdata); 473 Safefree (req->statdata);
322 474
323 if (req->type == REQ_READDIR && req->result >= 0) 475 if (req->type == REQ_READDIR)
324 free (req->data2ptr); 476 free (req->data2ptr);
325 477
326 Safefree (req); 478 Safefree (req);
327} 479}
328 480
481static void req_cancel_subs (aio_req grp)
482{
483 aio_req sub;
484
485 if (grp->type != REQ_GROUP)
486 return;
487
488 SvREFCNT_dec (grp->fh2);
489 grp->fh2 = 0;
490
491 for (sub = grp->grp_first; sub; sub = sub->grp_next)
492 req_cancel (sub);
493}
494
329static void req_cancel (aio_req req) 495static void req_cancel (aio_req req)
330{ 496{
331 req->flags |= FLAG_CANCELLED; 497 req->flags |= FLAG_CANCELLED;
332 498
333 if (req->type == REQ_GROUP) 499 req_cancel_subs (req);
334 {
335 aio_req sub;
336
337 for (sub = req->grp_first; sub; sub = sub->grp_next)
338 req_cancel (sub);
339 }
340} 500}
341 501
342static int poll_cb () 502static int poll_cb (int max)
343{ 503{
344 dSP; 504 dSP;
345 int count = 0; 505 int count = 0;
346 int do_croak = 0; 506 int do_croak = 0;
347 aio_req req; 507 aio_req req;
348 508
349 for (;;) 509 for (;;)
350 { 510 {
351 pthread_mutex_lock (&reslock); 511 while (max <= 0 || count < max)
352 req = ress;
353
354 if (req)
355 { 512 {
356 ress = req->next; 513 LOCK (reslock);
514 req = reqq_shift (&res_queue);
357 515
358 if (!ress) 516 if (req)
359 { 517 {
518 if (!res_queue.size)
519 {
360 /* read any signals sent by the worker threads */ 520 /* read any signals sent by the worker threads */
361 char buf [32]; 521 char buf [32];
362 while (read (respipe [0], buf, 32) == 32) 522 while (read (respipe [0], buf, 32) == 32)
523 ;
363 ; 524 }
364
365 rese = 0;
366 } 525 }
526
527 UNLOCK (reslock);
528
529 if (!req)
530 break;
531
532 --nreqs;
533
534 if (req->type == REQ_QUIT)
535 --started;
536 else if (req->type == REQ_GROUP && req->length)
537 {
538 req->fd = 1; /* mark request as delayed */
539 continue;
540 }
541 else
542 {
543 if (req->type == REQ_READ)
544 SvCUR_set (req->data, req->dataoffset + (req->result > 0 ? req->result : 0));
545
546 if (req->data2ptr && (req->type == REQ_READ || req->type == REQ_WRITE))
547 SvREADONLY_off (req->data);
548
549 if (req->statdata)
550 {
551 PL_laststype = req->type == REQ_LSTAT ? OP_LSTAT : OP_STAT;
552 PL_laststatval = req->result;
553 PL_statcache = *(req->statdata);
554 }
555
556 req_invoke (req);
557
558 count++;
559 }
560
561 req_free (req);
367 } 562 }
368 563
369 pthread_mutex_unlock (&reslock); 564 if (nreqs <= max_outstanding)
370
371 if (!req)
372 break; 565 break;
373 566
374 --nreqs; 567 poll_wait ();
375 568
376 if (req->type == REQ_QUIT) 569 max = 0;
377 started--;
378 else if (req->type == REQ_GROUP && req->length)
379 {
380 req->fd = 1; /* mark request as delayed */
381 continue;
382 }
383 else
384 {
385 if (req->type == REQ_READ)
386 SvCUR_set (req->data, req->dataoffset + (req->result > 0 ? req->result : 0));
387
388 if (req->data2ptr && (req->type == REQ_READ || req->type == REQ_WRITE))
389 SvREADONLY_off (req->data);
390
391 if (req->statdata)
392 {
393 PL_laststype = req->type == REQ_LSTAT ? OP_LSTAT : OP_STAT;
394 PL_laststatval = req->result;
395 PL_statcache = *(req->statdata);
396 }
397
398 req_invoke (req);
399
400 count++;
401 }
402
403 req_free (req);
404 } 570 }
405 571
406 return count; 572 return count;
407} 573}
408 574
409static void *aio_proc(void *arg); 575static void *aio_proc(void *arg);
410 576
411static void start_thread (void) 577static void start_thread (void)
412{ 578{
413 sigset_t fullsigset, oldsigset; 579 sigset_t fullsigset, oldsigset;
414 pthread_t tid;
415 pthread_attr_t attr; 580 pthread_attr_t attr;
581
582 worker *wrk = calloc (1, sizeof (worker));
583
584 if (!wrk)
585 croak ("unable to allocate worker thread data");
416 586
417 pthread_attr_init (&attr); 587 pthread_attr_init (&attr);
418 pthread_attr_setstacksize (&attr, STACKSIZE); 588 pthread_attr_setstacksize (&attr, STACKSIZE);
419 pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED); 589 pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED);
420 590
421 sigfillset (&fullsigset); 591 sigfillset (&fullsigset);
592
593 LOCK (wrklock);
422 sigprocmask (SIG_SETMASK, &fullsigset, &oldsigset); 594 sigprocmask (SIG_SETMASK, &fullsigset, &oldsigset);
423 595
424 if (pthread_create (&tid, &attr, aio_proc, 0) == 0) 596 if (pthread_create (&wrk->tid, &attr, aio_proc, (void *)wrk) == 0)
597 {
598 wrk->prev = &wrk_first;
599 wrk->next = wrk_first.next;
600 wrk_first.next->prev = wrk;
601 wrk_first.next = wrk;
425 started++; 602 ++started;
603 }
604 else
605 free (wrk);
426 606
427 sigprocmask (SIG_SETMASK, &oldsigset, 0); 607 sigprocmask (SIG_SETMASK, &oldsigset, 0);
608 UNLOCK (wrklock);
428} 609}
429 610
430static void req_send (aio_req req) 611static void req_send (aio_req req)
431{ 612{
432 while (started < wanted && nreqs >= started) 613 while (started < wanted && nreqs >= started)
433 start_thread (); 614 start_thread ();
434 615
435 ++nreqs; 616 ++nreqs;
436 617
437 pthread_mutex_lock (&reqlock); 618 LOCK (reqlock);
438 619 reqq_push (&req_queue, req);
439 req->next = 0;
440
441 if (reqe)
442 {
443 reqe->next = req;
444 reqe = req;
445 }
446 else
447 reqe = reqs = req;
448
449 pthread_cond_signal (&reqwait); 620 pthread_cond_signal (&reqwait);
450 pthread_mutex_unlock (&reqlock); 621 UNLOCK (reqlock);
451
452 if (nreqs > max_outstanding)
453 for (;;)
454 {
455 poll_cb ();
456
457 if (nreqs <= max_outstanding)
458 break;
459
460 poll_wait ();
461 }
462} 622}
463 623
464static void end_thread (void) 624static void end_thread (void)
465{ 625{
466 aio_req req; 626 aio_req req;
627
467 Newz (0, req, 1, aio_cb); 628 Newz (0, req, 1, aio_cb);
629
468 req->type = REQ_QUIT; 630 req->type = REQ_QUIT;
631 req->pri = PRI_MAX + PRI_BIAS;
469 632
470 req_send (req); 633 req_send (req);
471} 634}
472 635
473static void min_parallel (int nthreads) 636static void min_parallel (int nthreads)
490 } 653 }
491 654
492 while (started > wanted) 655 while (started > wanted)
493 { 656 {
494 poll_wait (); 657 poll_wait ();
495 poll_cb (); 658 poll_cb (0);
496 } 659 }
497} 660}
498 661
499static void create_pipe () 662static void create_pipe ()
500{ 663{
525static ssize_t pread (int fd, void *buf, size_t count, off_t offset) 688static ssize_t pread (int fd, void *buf, size_t count, off_t offset)
526{ 689{
527 ssize_t res; 690 ssize_t res;
528 off_t ooffset; 691 off_t ooffset;
529 692
530 pthread_mutex_lock (&preadwritelock); 693 LOCK (preadwritelock);
531 ooffset = lseek (fd, 0, SEEK_CUR); 694 ooffset = lseek (fd, 0, SEEK_CUR);
532 lseek (fd, offset, SEEK_SET); 695 lseek (fd, offset, SEEK_SET);
533 res = read (fd, buf, count); 696 res = read (fd, buf, count);
534 lseek (fd, ooffset, SEEK_SET); 697 lseek (fd, ooffset, SEEK_SET);
535 pthread_mutex_unlock (&preadwritelock); 698 UNLOCK (preadwritelock);
536 699
537 return res; 700 return res;
538} 701}
539 702
540static ssize_t pwrite (int fd, void *buf, size_t count, off_t offset) 703static ssize_t pwrite (int fd, void *buf, size_t count, off_t offset)
541{ 704{
542 ssize_t res; 705 ssize_t res;
543 off_t ooffset; 706 off_t ooffset;
544 707
545 pthread_mutex_lock (&preadwritelock); 708 LOCK (preadwritelock);
546 ooffset = lseek (fd, 0, SEEK_CUR); 709 ooffset = lseek (fd, 0, SEEK_CUR);
547 lseek (fd, offset, SEEK_SET); 710 lseek (fd, offset, SEEK_SET);
548 res = write (fd, buf, count); 711 res = write (fd, buf, count);
549 lseek (fd, offset, SEEK_SET); 712 lseek (fd, offset, SEEK_SET);
550 pthread_mutex_unlock (&preadwritelock); 713 UNLOCK (preadwritelock);
551 714
552 return res; 715 return res;
553} 716}
554#endif 717#endif
555 718
556#if !HAVE_FDATASYNC 719#if !HAVE_FDATASYNC
557# define fdatasync fsync 720# define fdatasync fsync
558#endif 721#endif
559 722
560#if !HAVE_READAHEAD 723#if !HAVE_READAHEAD
561# define readahead aio_readahead 724# define readahead(fd,offset,count) aio_readahead (fd, offset, count, self)
562 725
563static ssize_t readahead (int fd, off_t offset, size_t count) 726static ssize_t aio_readahead (int fd, off_t offset, size_t count, worker *self)
564{ 727{
565 char readahead_buf[4096]; 728 dBUF;
566 729
567 while (count > 0) 730 while (count > 0)
568 { 731 {
569 size_t len = count < sizeof (readahead_buf) ? count : sizeof (readahead_buf); 732 size_t len = count < AIO_BUFSIZE ? count : AIO_BUFSIZE;
570 733
571 pread (fd, readahead_buf, len, offset); 734 pread (fd, aio_buf, len, offset);
572 offset += len; 735 offset += len;
573 count -= len; 736 count -= len;
574 } 737 }
575 738
576 errno = 0; 739 errno = 0;
577} 740}
741
578#endif 742#endif
579 743
580#if !HAVE_READDIR_R 744#if !HAVE_READDIR_R
581# define readdir_r aio_readdir_r 745# define readdir_r aio_readdir_r
582 746
585static int readdir_r (DIR *dirp, struct dirent *ent, struct dirent **res) 749static int readdir_r (DIR *dirp, struct dirent *ent, struct dirent **res)
586{ 750{
587 struct dirent *e; 751 struct dirent *e;
588 int errorno; 752 int errorno;
589 753
590 pthread_mutex_lock (&readdirlock); 754 LOCK (readdirlock);
591 755
592 e = readdir (dirp); 756 e = readdir (dirp);
593 errorno = errno; 757 errorno = errno;
594 758
595 if (e) 759 if (e)
598 strcpy (ent->d_name, e->d_name); 762 strcpy (ent->d_name, e->d_name);
599 } 763 }
600 else 764 else
601 *res = 0; 765 *res = 0;
602 766
603 pthread_mutex_unlock (&readdirlock); 767 UNLOCK (readdirlock);
604 768
605 errno = errorno; 769 errno = errorno;
606 return e ? 0 : -1; 770 return e ? 0 : -1;
607} 771}
608#endif 772#endif
609 773
610/* sendfile always needs emulation */ 774/* sendfile always needs emulation */
611static ssize_t sendfile_ (int ofd, int ifd, off_t offset, size_t count) 775static ssize_t sendfile_ (int ofd, int ifd, off_t offset, size_t count, worker *self)
612{ 776{
613 ssize_t res; 777 ssize_t res;
614 778
615 if (!count) 779 if (!count)
616 return 0; 780 return 0;
627 { 791 {
628 off_t sbytes; 792 off_t sbytes;
629 res = sendfile (ifd, ofd, offset, count, 0, &sbytes, 0); 793 res = sendfile (ifd, ofd, offset, count, 0, &sbytes, 0);
630 794
631 if (res < 0 && sbytes) 795 if (res < 0 && sbytes)
632 /* maybe only on EAGAIN only: as usual, the manpage leaves you guessing */ 796 /* maybe only on EAGAIN: as usual, the manpage leaves you guessing */
633 res = sbytes; 797 res = sbytes;
634 } 798 }
635 799
636# elif __hpux 800# elif __hpux
637 res = sendfile (ofd, ifd, offset, count, 0, 0); 801 res = sendfile (ofd, ifd, offset, count, 0, 0);
665#endif 829#endif
666 ) 830 )
667 ) 831 )
668 { 832 {
669 /* emulate sendfile. this is a major pain in the ass */ 833 /* emulate sendfile. this is a major pain in the ass */
670 char buf[4096]; 834 dBUF;
835
671 res = 0; 836 res = 0;
672 837
673 while (count) 838 while (count)
674 { 839 {
675 ssize_t cnt; 840 ssize_t cnt;
676 841
677 cnt = pread (ifd, buf, count > 4096 ? 4096 : count, offset); 842 cnt = pread (ifd, aio_buf, count > AIO_BUFSIZE ? AIO_BUFSIZE : count, offset);
678 843
679 if (cnt <= 0) 844 if (cnt <= 0)
680 { 845 {
681 if (cnt && !res) res = -1; 846 if (cnt && !res) res = -1;
682 break; 847 break;
683 } 848 }
684 849
685 cnt = write (ofd, buf, cnt); 850 cnt = write (ofd, aio_buf, cnt);
686 851
687 if (cnt <= 0) 852 if (cnt <= 0)
688 { 853 {
689 if (cnt && !res) res = -1; 854 if (cnt && !res) res = -1;
690 break; 855 break;
698 863
699 return res; 864 return res;
700} 865}
701 866
702/* read a full directory */ 867/* read a full directory */
703static int scandir_ (const char *path, void **namesp) 868static void scandir_ (aio_req req, worker *self)
704{ 869{
705 DIR *dirp = opendir (path); 870 DIR *dirp;
706 union 871 union
707 { 872 {
708 struct dirent d; 873 struct dirent d;
709 char b [offsetof (struct dirent, d_name) + NAME_MAX + 1]; 874 char b [offsetof (struct dirent, d_name) + NAME_MAX + 1];
710 } u; 875 } *u;
711 struct dirent *entp; 876 struct dirent *entp;
712 char *name, *names; 877 char *name, *names;
713 int memlen = 4096; 878 int memlen = 4096;
714 int memofs = 0; 879 int memofs = 0;
715 int res = 0; 880 int res = 0;
716 int errorno; 881 int errorno;
717 882
718 if (!dirp) 883 LOCK (wrklock);
719 return -1; 884 self->dirp = dirp = opendir (req->dataptr);
720 885 self->dbuf = u = malloc (sizeof (*u));
721 names = malloc (memlen); 886 req->data2ptr = names = malloc (memlen);
887 UNLOCK (wrklock);
722 888
889 if (dirp && u && names)
723 for (;;) 890 for (;;)
724 { 891 {
892 errno = 0;
725 errno = 0, readdir_r (dirp, &u.d, &entp); 893 readdir_r (dirp, &u->d, &entp);
726 894
727 if (!entp) 895 if (!entp)
728 break; 896 break;
729 897
730 name = entp->d_name; 898 name = entp->d_name;
731 899
732 if (name [0] != '.' || (name [1] && (name [1] != '.' || name [2]))) 900 if (name [0] != '.' || (name [1] && (name [1] != '.' || name [2])))
733 { 901 {
734 int len = strlen (name) + 1; 902 int len = strlen (name) + 1;
735 903
736 res++; 904 res++;
737 905
738 while (memofs + len > memlen) 906 while (memofs + len > memlen)
739 { 907 {
740 memlen *= 2; 908 memlen *= 2;
909 LOCK (wrklock);
741 names = realloc (names, memlen); 910 req->data2ptr = names = realloc (names, memlen);
911 UNLOCK (wrklock);
912
742 if (!names) 913 if (!names)
743 break; 914 break;
744 } 915 }
745 916
746 memcpy (names + memofs, name, len); 917 memcpy (names + memofs, name, len);
747 memofs += len; 918 memofs += len;
748 } 919 }
749 } 920 }
750 921
751 errorno = errno;
752 closedir (dirp);
753
754 if (errorno) 922 if (errno)
755 {
756 free (names);
757 errno = errorno;
758 res = -1; 923 res = -1;
759 } 924
760 925 req->result = res;
761 *namesp = (void *)names;
762 return res;
763} 926}
764 927
765/*****************************************************************************/ 928/*****************************************************************************/
766 929
767static void *aio_proc (void *thr_arg) 930static void *aio_proc (void *thr_arg)
768{ 931{
769 aio_req req; 932 aio_req req;
770 int type; 933 int type;
934 worker *self = (worker *)thr_arg;
771 935
772 do 936 do
773 { 937 {
774 pthread_mutex_lock (&reqlock); 938 LOCK (reqlock);
775 939
776 for (;;) 940 for (;;)
777 { 941 {
778 req = reqs; 942 self->req = req = reqq_shift (&req_queue);
779
780 if (reqs)
781 {
782 reqs = reqs->next;
783 if (!reqs) reqe = 0;
784 }
785 943
786 if (req) 944 if (req)
787 break; 945 break;
788 946
789 pthread_cond_wait (&reqwait, &reqlock); 947 pthread_cond_wait (&reqwait, &reqlock);
790 } 948 }
791 949
792 pthread_mutex_unlock (&reqlock); 950 UNLOCK (reqlock);
793 951
794 errno = 0; /* strictly unnecessary */ 952 errno = 0; /* strictly unnecessary */
953 type = req->type; /* remember type for QUIT check */
795 954
796 if (!(req->flags & FLAG_CANCELLED)) 955 if (!(req->flags & FLAG_CANCELLED))
797 switch (type = req->type) /* remember type for QUIT check */ 956 switch (type)
798 { 957 {
799 case REQ_READ: req->result = pread (req->fd, req->dataptr, req->length, req->offset); break; 958 case REQ_READ: req->result = pread (req->fd, req->dataptr, req->length, req->offset); break;
800 case REQ_WRITE: req->result = pwrite (req->fd, req->dataptr, req->length, req->offset); break; 959 case REQ_WRITE: req->result = pwrite (req->fd, req->dataptr, req->length, req->offset); break;
801 960
802 case REQ_READAHEAD: req->result = readahead (req->fd, req->offset, req->length); break; 961 case REQ_READAHEAD: req->result = readahead (req->fd, req->offset, req->length); break;
803 case REQ_SENDFILE: req->result = sendfile_ (req->fd, req->fd2, req->offset, req->length); break; 962 case REQ_SENDFILE: req->result = sendfile_ (req->fd, req->fd2, req->offset, req->length, self); break;
804 963
805 case REQ_STAT: req->result = stat (req->dataptr, req->statdata); break; 964 case REQ_STAT: req->result = stat (req->dataptr, req->statdata); break;
806 case REQ_LSTAT: req->result = lstat (req->dataptr, req->statdata); break; 965 case REQ_LSTAT: req->result = lstat (req->dataptr, req->statdata); break;
807 case REQ_FSTAT: req->result = fstat (req->fd , req->statdata); break; 966 case REQ_FSTAT: req->result = fstat (req->fd , req->statdata); break;
808 967
814 case REQ_LINK: req->result = link (req->data2ptr, req->dataptr); break; 973 case REQ_LINK: req->result = link (req->data2ptr, req->dataptr); break;
815 case REQ_SYMLINK: req->result = symlink (req->data2ptr, req->dataptr); break; 974 case REQ_SYMLINK: req->result = symlink (req->data2ptr, req->dataptr); break;
816 975
817 case REQ_FDATASYNC: req->result = fdatasync (req->fd); break; 976 case REQ_FDATASYNC: req->result = fdatasync (req->fd); break;
818 case REQ_FSYNC: req->result = fsync (req->fd); break; 977 case REQ_FSYNC: req->result = fsync (req->fd); break;
819 case REQ_READDIR: req->result = scandir_ (req->dataptr, &req->data2ptr); break; 978 case REQ_READDIR: scandir_ (req, self); break;
820 979
821 case REQ_SLEEP: 980 case REQ_BUSY:
822 { 981 {
823 struct timeval tv; 982 struct timeval tv;
824 983
825 tv.tv_sec = req->fd; 984 tv.tv_sec = req->fd;
826 tv.tv_usec = req->fd2; 985 tv.tv_usec = req->fd2;
838 break; 997 break;
839 } 998 }
840 999
841 req->errorno = errno; 1000 req->errorno = errno;
842 1001
843 pthread_mutex_lock (&reslock); 1002 LOCK (reslock);
844 1003
845 req->next = 0; 1004 if (!reqq_push (&res_queue, req))
846
847 if (rese)
848 {
849 rese->next = req;
850 rese = req;
851 }
852 else
853 {
854 rese = ress = req;
855
856 /* write a dummy byte to the pipe so fh becomes ready */ 1005 /* write a dummy byte to the pipe so fh becomes ready */
857 write (respipe [1], &respipe, 1); 1006 write (respipe [1], &respipe, 1);
858 }
859 1007
860 pthread_mutex_unlock (&reslock); 1008 self->req = 0;
1009 worker_clear (self);
1010
1011 UNLOCK (reslock);
861 } 1012 }
862 while (type != REQ_QUIT); 1013 while (type != REQ_QUIT);
863 1014
1015 LOCK (wrklock);
1016 worker_free (self);
1017 UNLOCK (wrklock);
1018
864 return 0; 1019 return 0;
865} 1020}
866 1021
867/*****************************************************************************/ 1022/*****************************************************************************/
868 1023
869static void atfork_prepare (void) 1024static void atfork_prepare (void)
870{ 1025{
871 pthread_mutex_lock (&reqlock); 1026 LOCK (wrklock);
872 pthread_mutex_lock (&reslock); 1027 LOCK (reqlock);
1028 LOCK (reslock);
873#if !HAVE_PREADWRITE 1029#if !HAVE_PREADWRITE
874 pthread_mutex_lock (&preadwritelock); 1030 LOCK (preadwritelock);
875#endif 1031#endif
876#if !HAVE_READDIR_R 1032#if !HAVE_READDIR_R
877 pthread_mutex_lock (&readdirlock); 1033 LOCK (readdirlock);
878#endif 1034#endif
879} 1035}
880 1036
881static void atfork_parent (void) 1037static void atfork_parent (void)
882{ 1038{
883#if !HAVE_READDIR_R 1039#if !HAVE_READDIR_R
884 pthread_mutex_unlock (&readdirlock); 1040 UNLOCK (readdirlock);
885#endif 1041#endif
886#if !HAVE_PREADWRITE 1042#if !HAVE_PREADWRITE
887 pthread_mutex_unlock (&preadwritelock); 1043 UNLOCK (preadwritelock);
888#endif 1044#endif
889 pthread_mutex_unlock (&reslock); 1045 UNLOCK (reslock);
890 pthread_mutex_unlock (&reqlock); 1046 UNLOCK (reqlock);
1047 UNLOCK (wrklock);
891} 1048}
892 1049
893static void atfork_child (void) 1050static void atfork_child (void)
894{ 1051{
895 aio_req prv; 1052 aio_req prv;
896 1053
1054 while (prv = reqq_shift (&req_queue))
1055 req_free (prv);
1056
1057 while (prv = reqq_shift (&res_queue))
1058 req_free (prv);
1059
1060 while (wrk_first.next != &wrk_first)
1061 {
1062 worker *wrk = wrk_first.next;
1063
1064 if (wrk->req)
1065 req_free (wrk->req);
1066
1067 worker_clear (wrk);
1068 worker_free (wrk);
1069 }
1070
897 started = 0; 1071 started = 0;
898 1072 nreqs = 0;
899 while (reqs)
900 {
901 prv = reqs;
902 reqs = prv->next;
903 req_free (prv);
904 }
905
906 reqs = reqe = 0;
907
908 while (ress)
909 {
910 prv = ress;
911 ress = prv->next;
912 req_free (prv);
913 }
914
915 ress = rese = 0;
916 1073
917 close (respipe [0]); 1074 close (respipe [0]);
918 close (respipe [1]); 1075 close (respipe [1]);
919 create_pipe (); 1076 create_pipe ();
920 1077
921 atfork_parent (); 1078 atfork_parent ();
922} 1079}
923 1080
924#define dREQ \ 1081#define dREQ \
925 aio_req req; \ 1082 aio_req req; \
1083 int req_pri = next_pri; \
1084 next_pri = DEFAULT_PRI + PRI_BIAS; \
926 \ 1085 \
927 if (SvOK (callback) && !SvROK (callback)) \ 1086 if (SvOK (callback) && !SvROK (callback)) \
928 croak ("callback must be undef or of reference type"); \ 1087 croak ("callback must be undef or of reference type"); \
929 \ 1088 \
930 Newz (0, req, 1, aio_cb); \ 1089 Newz (0, req, 1, aio_cb); \
931 if (!req) \ 1090 if (!req) \
932 croak ("out of memory during aio_req allocation"); \ 1091 croak ("out of memory during aio_req allocation"); \
933 \ 1092 \
934 req->callback = newSVsv (callback) 1093 req->callback = newSVsv (callback); \
1094 req->pri = req_pri
935 1095
936#define REQ_SEND \ 1096#define REQ_SEND \
937 req_send (req); \ 1097 req_send (req); \
938 \ 1098 \
939 if (GIMME_V != G_VOID) \ 1099 if (GIMME_V != G_VOID) \
953 create_pipe (); 1113 create_pipe ();
954 pthread_atfork (atfork_prepare, atfork_parent, atfork_child); 1114 pthread_atfork (atfork_prepare, atfork_parent, atfork_child);
955} 1115}
956 1116
957void 1117void
958min_parallel (nthreads) 1118min_parallel (int nthreads)
959 int nthreads
960 PROTOTYPE: $ 1119 PROTOTYPE: $
961 1120
962void 1121void
963max_parallel (nthreads) 1122max_parallel (int nthreads)
964 int nthreads
965 PROTOTYPE: $ 1123 PROTOTYPE: $
966 1124
967int 1125int
968max_outstanding (nreqs) 1126max_outstanding (int maxreqs)
969 int nreqs 1127 PROTOTYPE: $
970 PROTOTYPE: $
971 CODE: 1128 CODE:
972 RETVAL = max_outstanding; 1129 RETVAL = max_outstanding;
973 max_outstanding = nreqs; 1130 max_outstanding = maxreqs;
1131 OUTPUT:
1132 RETVAL
974 1133
975void 1134void
976aio_open (pathname,flags,mode,callback=&PL_sv_undef) 1135aio_open (pathname,flags,mode,callback=&PL_sv_undef)
977 SV * pathname 1136 SV * pathname
978 int flags 1137 int flags
1193 1352
1194 REQ_SEND; 1353 REQ_SEND;
1195} 1354}
1196 1355
1197void 1356void
1198aio_sleep (delay,callback=&PL_sv_undef) 1357aio_busy (delay,callback=&PL_sv_undef)
1199 double delay 1358 double delay
1200 SV * callback 1359 SV * callback
1201 PPCODE: 1360 PPCODE:
1202{ 1361{
1203 dREQ; 1362 dREQ;
1204 1363
1205 req->type = REQ_SLEEP; 1364 req->type = REQ_BUSY;
1206 req->fd = delay < 0. ? 0 : delay; 1365 req->fd = delay < 0. ? 0 : delay;
1207 req->fd2 = delay < 0. ? 0 : 1000. * (delay - req->fd); 1366 req->fd2 = delay < 0. ? 0 : 1000. * (delay - req->fd);
1208 1367
1209 REQ_SEND; 1368 REQ_SEND;
1210} 1369}
1214 SV * callback 1373 SV * callback
1215 PROTOTYPE: ;$ 1374 PROTOTYPE: ;$
1216 PPCODE: 1375 PPCODE:
1217{ 1376{
1218 dREQ; 1377 dREQ;
1378
1219 req->type = REQ_GROUP; 1379 req->type = REQ_GROUP;
1220 req_send (req); 1380 req_send (req);
1381
1221 XPUSHs (req_sv (req, AIO_GRP_KLASS)); 1382 XPUSHs (req_sv (req, AIO_GRP_KLASS));
1222} 1383}
1223 1384
1224void 1385void
1225aio_nop (callback=&PL_sv_undef) 1386aio_nop (callback=&PL_sv_undef)
1230 1391
1231 req->type = REQ_NOP; 1392 req->type = REQ_NOP;
1232 1393
1233 REQ_SEND; 1394 REQ_SEND;
1234} 1395}
1396
1397void
1398aioreq_pri (int pri = DEFAULT_PRI)
1399 CODE:
1400 if (pri < PRI_MIN) pri = PRI_MIN;
1401 if (pri > PRI_MAX) pri = PRI_MAX;
1402 next_pri = pri + PRI_BIAS;
1403
1404void
1405aioreq_nice (int nice = 0)
1406 CODE:
1407 nice = next_pri - nice;
1408 if (nice < PRI_MIN) nice = PRI_MIN;
1409 if (nice > PRI_MAX) nice = PRI_MAX;
1410 next_pri = nice + PRI_BIAS;
1235 1411
1236void 1412void
1237flush () 1413flush ()
1238 PROTOTYPE: 1414 PROTOTYPE:
1239 CODE: 1415 CODE:
1240 while (nreqs) 1416 while (nreqs)
1241 { 1417 {
1242 poll_wait (); 1418 poll_wait ();
1243 poll_cb (); 1419 poll_cb (0);
1244 } 1420 }
1245 1421
1246void 1422void
1247poll() 1423poll()
1248 PROTOTYPE: 1424 PROTOTYPE:
1249 CODE: 1425 CODE:
1250 if (nreqs) 1426 if (nreqs)
1251 { 1427 {
1252 poll_wait (); 1428 poll_wait ();
1253 poll_cb (); 1429 poll_cb (0);
1254 } 1430 }
1255 1431
1256int 1432int
1257poll_fileno() 1433poll_fileno()
1258 PROTOTYPE: 1434 PROTOTYPE:
1263 1439
1264int 1440int
1265poll_cb(...) 1441poll_cb(...)
1266 PROTOTYPE: 1442 PROTOTYPE:
1267 CODE: 1443 CODE:
1268 RETVAL = poll_cb (); 1444 RETVAL = poll_cb (0);
1445 OUTPUT:
1446 RETVAL
1447
1448int
1449poll_some(int max = 0)
1450 PROTOTYPE: $
1451 CODE:
1452 RETVAL = poll_cb (max);
1269 OUTPUT: 1453 OUTPUT:
1270 RETVAL 1454 RETVAL
1271 1455
1272void 1456void
1273poll_wait() 1457poll_wait()
1288 1472
1289MODULE = IO::AIO PACKAGE = IO::AIO::REQ 1473MODULE = IO::AIO PACKAGE = IO::AIO::REQ
1290 1474
1291void 1475void
1292cancel (aio_req_ornot req) 1476cancel (aio_req_ornot req)
1293 PROTOTYPE:
1294 CODE: 1477 CODE:
1295 req_cancel (req); 1478 req_cancel (req);
1296 1479
1297void 1480void
1298cb (aio_req req, SV *callback=&PL_sv_undef) 1481cb (aio_req_ornot req, SV *callback=&PL_sv_undef)
1299 CODE: 1482 CODE:
1300 SvREFCNT_dec (req->callback); 1483 SvREFCNT_dec (req->callback);
1301 req->callback = newSVsv (callback); 1484 req->callback = newSVsv (callback);
1302 1485
1303MODULE = IO::AIO PACKAGE = IO::AIO::GRP 1486MODULE = IO::AIO PACKAGE = IO::AIO::GRP
1334 } 1517 }
1335 } 1518 }
1336} 1519}
1337 1520
1338void 1521void
1522cancel_subs (aio_req_ornot req)
1523 CODE:
1524 req_cancel_subs (req);
1525
1526void
1339result (aio_req grp, ...) 1527result (aio_req grp, ...)
1340 CODE: 1528 CODE:
1341{ 1529{
1342 int i; 1530 int i;
1343 AV *av = newAV (); 1531 AV *av = newAV ();
1348 SvREFCNT_dec (grp->data); 1536 SvREFCNT_dec (grp->data);
1349 grp->data = (SV *)av; 1537 grp->data = (SV *)av;
1350} 1538}
1351 1539
1352void 1540void
1353feed_limit (aio_req grp, int limit) 1541limit (aio_req grp, int limit)
1354 CODE: 1542 CODE:
1355 grp->fd2 = limit; 1543 grp->fd2 = limit;
1356 aio_grp_feed (grp); 1544 aio_grp_feed (grp);
1357 1545
1358void 1546void

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines