1 | #if __linux |
1 | /* solaris */ |
|
|
2 | #define _POSIX_PTHREAD_SEMANTICS 1 |
|
|
3 | |
|
|
4 | #if __linux && !defined(_GNU_SOURCE) |
2 | # define _GNU_SOURCE |
5 | # define _GNU_SOURCE |
3 | #endif |
6 | #endif |
4 | |
7 | |
|
|
8 | /* just in case */ |
5 | #define _REENTRANT 1 |
9 | #define _REENTRANT 1 |
6 | |
10 | |
7 | #include <errno.h> |
11 | #include <errno.h> |
8 | |
12 | |
9 | #include "EXTERN.h" |
13 | #include "EXTERN.h" |
… | |
… | |
44 | /* used for struct dirent, AIX doesn't provide it */ |
48 | /* used for struct dirent, AIX doesn't provide it */ |
45 | #ifndef NAME_MAX |
49 | #ifndef NAME_MAX |
46 | # define NAME_MAX 4096 |
50 | # define NAME_MAX 4096 |
47 | #endif |
51 | #endif |
48 | |
52 | |
|
|
53 | #ifndef PTHREAD_STACK_MIN |
|
|
54 | /* care for broken platforms, e.g. windows */ |
|
|
55 | # define PTHREAD_STACK_MIN 16384 |
|
|
56 | #endif |
|
|
57 | |
49 | #if __ia64 |
58 | #if __ia64 |
50 | # define STACKSIZE 65536 |
59 | # define STACKSIZE 65536 |
|
|
60 | #elif __i386 || __x86_64 /* 16k is unreasonably high :( */ |
|
|
61 | # define STACKSIZE PTHREAD_STACK_MIN |
51 | #else |
62 | #else |
52 | # define STACKSIZE 8192 |
63 | # define STACKSIZE 16384 |
|
|
64 | #endif |
|
|
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 |
53 | #endif |
75 | # endif |
|
|
76 | #endif |
|
|
77 | |
|
|
78 | /* buffer size for various temporary buffers */ |
|
|
79 | #define AIO_BUFSIZE 65536 |
|
|
80 | |
|
|
81 | #define dBUF \ |
|
|
82 | char *aio_buf; \ |
|
|
83 | LOCK (wrklock); \ |
|
|
84 | self->dbuf = aio_buf = malloc (AIO_BUFSIZE); \ |
|
|
85 | UNLOCK (wrklock); \ |
|
|
86 | if (!aio_buf) \ |
|
|
87 | return -1; |
54 | |
88 | |
55 | enum { |
89 | enum { |
56 | REQ_QUIT, |
90 | REQ_QUIT, |
57 | REQ_OPEN, REQ_CLOSE, |
91 | REQ_OPEN, REQ_CLOSE, |
58 | REQ_READ, REQ_WRITE, REQ_READAHEAD, |
92 | REQ_READ, REQ_WRITE, REQ_READAHEAD, |
59 | REQ_SENDFILE, |
93 | REQ_SENDFILE, |
60 | REQ_STAT, REQ_LSTAT, REQ_FSTAT, |
94 | REQ_STAT, REQ_LSTAT, REQ_FSTAT, |
61 | REQ_FSYNC, REQ_FDATASYNC, |
95 | REQ_FSYNC, REQ_FDATASYNC, |
62 | REQ_UNLINK, REQ_RMDIR, REQ_RENAME, |
96 | REQ_UNLINK, REQ_RMDIR, REQ_RENAME, |
63 | REQ_READDIR, |
97 | REQ_MKNOD, REQ_READDIR, |
64 | REQ_LINK, REQ_SYMLINK, |
98 | REQ_LINK, REQ_SYMLINK, |
65 | REQ_GROUP, REQ_NOP, |
99 | REQ_GROUP, REQ_NOP, |
66 | REQ_SLEEP, |
100 | REQ_BUSY, |
67 | }; |
101 | }; |
68 | |
102 | |
69 | #define AIO_REQ_KLASS "IO::AIO::REQ" |
103 | #define AIO_REQ_KLASS "IO::AIO::REQ" |
70 | #define AIO_GRP_KLASS "IO::AIO::GRP" |
104 | #define AIO_GRP_KLASS "IO::AIO::GRP" |
71 | |
105 | |
… | |
… | |
105 | PRI_MIN = -4, |
139 | PRI_MIN = -4, |
106 | PRI_MAX = 4, |
140 | PRI_MAX = 4, |
107 | |
141 | |
108 | DEFAULT_PRI = 0, |
142 | DEFAULT_PRI = 0, |
109 | PRI_BIAS = -PRI_MIN, |
143 | PRI_BIAS = -PRI_MIN, |
|
|
144 | NUM_PRI = PRI_MAX + PRI_BIAS + 1, |
110 | }; |
145 | }; |
111 | |
146 | |
112 | static int next_pri = DEFAULT_PRI + PRI_BIAS; |
147 | static int next_pri = DEFAULT_PRI + PRI_BIAS; |
113 | |
148 | |
114 | static int started, wanted; |
149 | static unsigned int started, wanted; |
115 | static volatile int nreqs; |
|
|
116 | static int max_outstanding = 1<<30; |
|
|
117 | static int respipe [2]; |
|
|
118 | |
150 | |
119 | #if __linux && defined (PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP) |
151 | #if __linux && defined (PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP) |
120 | # define AIO_MUTEX_INIT PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP |
152 | # define AIO_MUTEX_INIT PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP |
121 | #else |
153 | #else |
122 | # define AIO_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER |
154 | # define AIO_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER |
123 | #endif |
155 | #endif |
124 | |
156 | |
|
|
157 | #define LOCK(mutex) pthread_mutex_lock (&(mutex)) |
|
|
158 | #define UNLOCK(mutex) pthread_mutex_unlock (&(mutex)) |
|
|
159 | |
|
|
160 | /* worker threads management */ |
|
|
161 | static pthread_mutex_t wrklock = AIO_MUTEX_INIT; |
|
|
162 | |
|
|
163 | typedef struct worker { |
|
|
164 | /* locked by wrklock */ |
|
|
165 | struct worker *prev, *next; |
|
|
166 | |
|
|
167 | pthread_t tid; |
|
|
168 | |
|
|
169 | /* locked by reslock, reqlock or wrklock */ |
|
|
170 | aio_req req; /* currently processed request */ |
|
|
171 | void *dbuf; |
|
|
172 | DIR *dirp; |
|
|
173 | } worker; |
|
|
174 | |
|
|
175 | static worker wrk_first = { &wrk_first, &wrk_first, 0 }; |
|
|
176 | |
|
|
177 | static void worker_clear (worker *wrk) |
|
|
178 | { |
|
|
179 | if (wrk->dirp) |
|
|
180 | { |
|
|
181 | closedir (wrk->dirp); |
|
|
182 | wrk->dirp = 0; |
|
|
183 | } |
|
|
184 | |
|
|
185 | if (wrk->dbuf) |
|
|
186 | { |
|
|
187 | free (wrk->dbuf); |
|
|
188 | wrk->dbuf = 0; |
|
|
189 | } |
|
|
190 | } |
|
|
191 | |
|
|
192 | static void worker_free (worker *wrk) |
|
|
193 | { |
|
|
194 | wrk->next->prev = wrk->prev; |
|
|
195 | wrk->prev->next = wrk->next; |
|
|
196 | |
|
|
197 | free (wrk); |
|
|
198 | } |
|
|
199 | |
|
|
200 | static volatile unsigned int nreqs, nready, npending; |
|
|
201 | static volatile unsigned int max_outstanding = 0xffffffff; |
|
|
202 | static int respipe [2]; |
|
|
203 | |
125 | static pthread_mutex_t reslock = AIO_MUTEX_INIT; |
204 | static pthread_mutex_t reslock = AIO_MUTEX_INIT; |
126 | static pthread_mutex_t reqlock = AIO_MUTEX_INIT; |
205 | static pthread_mutex_t reqlock = AIO_MUTEX_INIT; |
127 | static pthread_cond_t reqwait = PTHREAD_COND_INITIALIZER; |
206 | static pthread_cond_t reqwait = PTHREAD_COND_INITIALIZER; |
128 | |
207 | |
129 | static volatile aio_req reqs, reqe; /* queue start, queue end */ |
208 | #if WORDREAD_UNSAFE |
130 | static volatile aio_req ress, rese; /* queue start, queue end */ |
|
|
131 | |
209 | |
|
|
210 | static unsigned int get_nready () |
|
|
211 | { |
|
|
212 | unsigned int retval; |
|
|
213 | |
|
|
214 | LOCK (reqlock); |
|
|
215 | retval = nready; |
|
|
216 | UNLOCK (reqlock); |
|
|
217 | |
|
|
218 | return retval; |
|
|
219 | } |
|
|
220 | |
|
|
221 | static unsigned int get_npending () |
|
|
222 | { |
|
|
223 | unsigned int retval; |
|
|
224 | |
|
|
225 | LOCK (reslock); |
|
|
226 | retval = npending; |
|
|
227 | UNLOCK (reslock); |
|
|
228 | |
|
|
229 | return retval; |
|
|
230 | } |
|
|
231 | |
|
|
232 | #else |
|
|
233 | |
|
|
234 | # define get_nready() nready |
|
|
235 | # define get_npending() npending |
|
|
236 | |
|
|
237 | #endif |
|
|
238 | |
|
|
239 | /* |
|
|
240 | * a somewhat faster data structure might be nice, but |
|
|
241 | * with 8 priorities this actually needs <20 insns |
|
|
242 | * per shift, the most expensive operation. |
|
|
243 | */ |
|
|
244 | typedef struct { |
|
|
245 | aio_req qs[NUM_PRI], qe[NUM_PRI]; /* qstart, qend */ |
|
|
246 | int size; |
|
|
247 | } reqq; |
|
|
248 | |
|
|
249 | static reqq req_queue; |
|
|
250 | static reqq res_queue; |
|
|
251 | |
|
|
252 | int reqq_push (reqq *q, aio_req req) |
|
|
253 | { |
|
|
254 | int pri = req->pri; |
|
|
255 | req->next = 0; |
|
|
256 | |
|
|
257 | if (q->qe[pri]) |
|
|
258 | { |
|
|
259 | q->qe[pri]->next = req; |
|
|
260 | q->qe[pri] = req; |
|
|
261 | } |
|
|
262 | else |
|
|
263 | q->qe[pri] = q->qs[pri] = req; |
|
|
264 | |
|
|
265 | return q->size++; |
|
|
266 | } |
|
|
267 | |
|
|
268 | aio_req reqq_shift (reqq *q) |
|
|
269 | { |
|
|
270 | int pri; |
|
|
271 | |
|
|
272 | if (!q->size) |
|
|
273 | return 0; |
|
|
274 | |
|
|
275 | --q->size; |
|
|
276 | |
|
|
277 | for (pri = NUM_PRI; pri--; ) |
|
|
278 | { |
|
|
279 | aio_req req = q->qs[pri]; |
|
|
280 | |
|
|
281 | if (req) |
|
|
282 | { |
|
|
283 | if (!(q->qs[pri] = req->next)) |
|
|
284 | q->qe[pri] = 0; |
|
|
285 | |
|
|
286 | return req; |
|
|
287 | } |
|
|
288 | } |
|
|
289 | |
|
|
290 | abort (); |
|
|
291 | } |
|
|
292 | |
|
|
293 | static int poll_cb (int max); |
132 | static void req_invoke (aio_req req); |
294 | static void req_invoke (aio_req req); |
133 | static void req_free (aio_req req); |
295 | static void req_free (aio_req req); |
|
|
296 | static void req_cancel (aio_req req); |
134 | |
297 | |
135 | /* must be called at most once */ |
298 | /* must be called at most once */ |
136 | static SV *req_sv (aio_req req, const char *klass) |
299 | static SV *req_sv (aio_req req, const char *klass) |
137 | { |
300 | { |
138 | if (!req->self) |
301 | if (!req->self) |
… | |
… | |
169 | ENTER; |
332 | ENTER; |
170 | SAVETMPS; |
333 | SAVETMPS; |
171 | PUSHMARK (SP); |
334 | PUSHMARK (SP); |
172 | XPUSHs (req_sv (grp, AIO_GRP_KLASS)); |
335 | XPUSHs (req_sv (grp, AIO_GRP_KLASS)); |
173 | PUTBACK; |
336 | PUTBACK; |
174 | call_sv (grp->fh2, G_VOID | G_EVAL); |
337 | call_sv (grp->fh2, G_VOID | G_EVAL | G_KEEPERR); |
175 | SPAGAIN; |
338 | SPAGAIN; |
176 | FREETMPS; |
339 | FREETMPS; |
177 | LEAVE; |
340 | LEAVE; |
178 | } |
341 | } |
179 | |
342 | |
… | |
… | |
200 | req_invoke (grp); |
363 | req_invoke (grp); |
201 | req_free (grp); |
364 | req_free (grp); |
202 | } |
365 | } |
203 | } |
366 | } |
204 | |
367 | |
205 | static void poll_wait () |
|
|
206 | { |
|
|
207 | fd_set rfd; |
|
|
208 | |
|
|
209 | while (nreqs) |
|
|
210 | { |
|
|
211 | aio_req req; |
|
|
212 | #if !(__x86 || __x86_64) /* safe without sempahore on this archs */ |
|
|
213 | pthread_mutex_lock (&reslock); |
|
|
214 | #endif |
|
|
215 | req = ress; |
|
|
216 | #if !(__x86 || __x86_64) /* safe without sempahore on this archs */ |
|
|
217 | pthread_mutex_unlock (&reslock); |
|
|
218 | #endif |
|
|
219 | |
|
|
220 | if (req) |
|
|
221 | return; |
|
|
222 | |
|
|
223 | FD_ZERO(&rfd); |
|
|
224 | FD_SET(respipe [0], &rfd); |
|
|
225 | |
|
|
226 | select (respipe [0] + 1, &rfd, 0, 0, 0); |
|
|
227 | } |
|
|
228 | } |
|
|
229 | |
|
|
230 | static void req_invoke (aio_req req) |
368 | static void req_invoke (aio_req req) |
231 | { |
369 | { |
232 | dSP; |
370 | dSP; |
233 | int errorno = errno; |
|
|
234 | |
371 | |
235 | if (req->flags & FLAG_CANCELLED || !SvOK (req->callback)) |
372 | if (!(req->flags & FLAG_CANCELLED) && SvOK (req->callback)) |
236 | return; |
373 | { |
237 | |
|
|
238 | errno = req->errorno; |
|
|
239 | |
|
|
240 | ENTER; |
374 | ENTER; |
241 | SAVETMPS; |
375 | SAVETMPS; |
242 | PUSHMARK (SP); |
376 | PUSHMARK (SP); |
243 | EXTEND (SP, 1); |
377 | EXTEND (SP, 1); |
244 | |
378 | |
245 | switch (req->type) |
379 | switch (req->type) |
246 | { |
|
|
247 | case REQ_READDIR: |
|
|
248 | { |
380 | { |
249 | SV *rv = &PL_sv_undef; |
381 | case REQ_READDIR: |
250 | |
|
|
251 | if (req->result >= 0) |
|
|
252 | { |
382 | { |
253 | char *buf = req->data2ptr; |
383 | SV *rv = &PL_sv_undef; |
254 | AV *av = newAV (); |
|
|
255 | |
384 | |
256 | while (req->result) |
385 | if (req->result >= 0) |
257 | { |
386 | { |
|
|
387 | int i; |
|
|
388 | char *buf = req->data2ptr; |
|
|
389 | AV *av = newAV (); |
|
|
390 | |
|
|
391 | av_extend (av, req->result - 1); |
|
|
392 | |
|
|
393 | for (i = 0; i < req->result; ++i) |
|
|
394 | { |
258 | SV *sv = newSVpv (buf, 0); |
395 | SV *sv = newSVpv (buf, 0); |
259 | |
396 | |
260 | av_push (av, sv); |
397 | av_store (av, i, sv); |
261 | buf += SvCUR (sv) + 1; |
398 | buf += SvCUR (sv) + 1; |
262 | req->result--; |
399 | } |
|
|
400 | |
|
|
401 | rv = sv_2mortal (newRV_noinc ((SV *)av)); |
263 | } |
402 | } |
264 | |
403 | |
265 | rv = sv_2mortal (newRV_noinc ((SV *)av)); |
404 | PUSHs (rv); |
266 | } |
405 | } |
|
|
406 | break; |
267 | |
407 | |
268 | PUSHs (rv); |
408 | case REQ_OPEN: |
|
|
409 | { |
|
|
410 | /* convert fd to fh */ |
|
|
411 | SV *fh; |
|
|
412 | |
|
|
413 | PUSHs (sv_2mortal (newSViv (req->result))); |
|
|
414 | PUTBACK; |
|
|
415 | call_pv ("IO::AIO::_fd2fh", G_SCALAR | G_EVAL); |
|
|
416 | SPAGAIN; |
|
|
417 | |
|
|
418 | fh = SvREFCNT_inc (POPs); |
|
|
419 | |
|
|
420 | PUSHMARK (SP); |
|
|
421 | XPUSHs (sv_2mortal (fh)); |
|
|
422 | } |
|
|
423 | break; |
|
|
424 | |
|
|
425 | case REQ_GROUP: |
|
|
426 | req->fd = 2; /* mark group as finished */ |
|
|
427 | |
|
|
428 | if (req->data) |
|
|
429 | { |
|
|
430 | int i; |
|
|
431 | AV *av = (AV *)req->data; |
|
|
432 | |
|
|
433 | EXTEND (SP, AvFILL (av) + 1); |
|
|
434 | for (i = 0; i <= AvFILL (av); ++i) |
|
|
435 | PUSHs (*av_fetch (av, i, 0)); |
|
|
436 | } |
|
|
437 | break; |
|
|
438 | |
|
|
439 | case REQ_NOP: |
|
|
440 | case REQ_BUSY: |
|
|
441 | break; |
|
|
442 | |
|
|
443 | default: |
|
|
444 | PUSHs (sv_2mortal (newSViv (req->result))); |
|
|
445 | break; |
269 | } |
446 | } |
270 | break; |
|
|
271 | |
447 | |
272 | case REQ_OPEN: |
448 | errno = req->errorno; |
273 | { |
|
|
274 | /* convert fd to fh */ |
|
|
275 | SV *fh; |
|
|
276 | |
449 | |
277 | PUSHs (sv_2mortal (newSViv (req->result))); |
|
|
278 | PUTBACK; |
450 | PUTBACK; |
279 | call_pv ("IO::AIO::_fd2fh", G_SCALAR | G_EVAL); |
|
|
280 | SPAGAIN; |
|
|
281 | |
|
|
282 | fh = SvREFCNT_inc (POPs); |
|
|
283 | |
|
|
284 | PUSHMARK (SP); |
|
|
285 | XPUSHs (sv_2mortal (fh)); |
|
|
286 | } |
|
|
287 | break; |
|
|
288 | |
|
|
289 | case REQ_GROUP: |
|
|
290 | req->fd = 2; /* mark group as finished */ |
|
|
291 | |
|
|
292 | if (req->data) |
|
|
293 | { |
|
|
294 | int i; |
|
|
295 | AV *av = (AV *)req->data; |
|
|
296 | |
|
|
297 | EXTEND (SP, AvFILL (av) + 1); |
|
|
298 | for (i = 0; i <= AvFILL (av); ++i) |
|
|
299 | PUSHs (*av_fetch (av, i, 0)); |
|
|
300 | } |
|
|
301 | break; |
|
|
302 | |
|
|
303 | case REQ_NOP: |
|
|
304 | case REQ_SLEEP: |
|
|
305 | break; |
|
|
306 | |
|
|
307 | default: |
|
|
308 | PUSHs (sv_2mortal (newSViv (req->result))); |
|
|
309 | break; |
|
|
310 | } |
|
|
311 | |
|
|
312 | |
|
|
313 | PUTBACK; |
|
|
314 | call_sv (req->callback, G_VOID | G_EVAL); |
451 | call_sv (req->callback, G_VOID | G_EVAL); |
315 | SPAGAIN; |
452 | SPAGAIN; |
316 | |
453 | |
317 | FREETMPS; |
454 | FREETMPS; |
318 | LEAVE; |
455 | LEAVE; |
319 | |
|
|
320 | errno = errorno; |
|
|
321 | |
|
|
322 | if (SvTRUE (ERRSV)) |
|
|
323 | { |
456 | } |
324 | req_free (req); |
|
|
325 | croak (0); |
|
|
326 | } |
|
|
327 | } |
|
|
328 | |
457 | |
329 | static void req_free (aio_req req) |
|
|
330 | { |
|
|
331 | if (req->grp) |
458 | if (req->grp) |
332 | { |
459 | { |
333 | aio_req grp = req->grp; |
460 | aio_req grp = req->grp; |
334 | |
461 | |
335 | /* unlink request */ |
462 | /* unlink request */ |
… | |
… | |
340 | grp->grp_first = req->grp_next; |
467 | grp->grp_first = req->grp_next; |
341 | |
468 | |
342 | aio_grp_dec (grp); |
469 | aio_grp_dec (grp); |
343 | } |
470 | } |
344 | |
471 | |
|
|
472 | if (SvTRUE (ERRSV)) |
|
|
473 | { |
|
|
474 | req_free (req); |
|
|
475 | croak (0); |
|
|
476 | } |
|
|
477 | } |
|
|
478 | |
|
|
479 | static void req_free (aio_req req) |
|
|
480 | { |
345 | if (req->self) |
481 | if (req->self) |
346 | { |
482 | { |
347 | sv_unmagic (req->self, PERL_MAGIC_ext); |
483 | sv_unmagic (req->self, PERL_MAGIC_ext); |
348 | SvREFCNT_dec (req->self); |
484 | SvREFCNT_dec (req->self); |
349 | } |
485 | } |
… | |
… | |
352 | SvREFCNT_dec (req->fh); |
488 | SvREFCNT_dec (req->fh); |
353 | SvREFCNT_dec (req->fh2); |
489 | SvREFCNT_dec (req->fh2); |
354 | SvREFCNT_dec (req->callback); |
490 | SvREFCNT_dec (req->callback); |
355 | Safefree (req->statdata); |
491 | Safefree (req->statdata); |
356 | |
492 | |
357 | if (req->type == REQ_READDIR && req->result >= 0) |
493 | if (req->type == REQ_READDIR) |
358 | free (req->data2ptr); |
494 | free (req->data2ptr); |
359 | |
495 | |
360 | Safefree (req); |
496 | Safefree (req); |
361 | } |
497 | } |
362 | |
498 | |
|
|
499 | static void req_cancel_subs (aio_req grp) |
|
|
500 | { |
|
|
501 | aio_req sub; |
|
|
502 | |
|
|
503 | if (grp->type != REQ_GROUP) |
|
|
504 | return; |
|
|
505 | |
|
|
506 | SvREFCNT_dec (grp->fh2); |
|
|
507 | grp->fh2 = 0; |
|
|
508 | |
|
|
509 | for (sub = grp->grp_first; sub; sub = sub->grp_next) |
|
|
510 | req_cancel (sub); |
|
|
511 | } |
|
|
512 | |
363 | static void req_cancel (aio_req req) |
513 | static void req_cancel (aio_req req) |
364 | { |
514 | { |
365 | req->flags |= FLAG_CANCELLED; |
515 | req->flags |= FLAG_CANCELLED; |
366 | |
516 | |
367 | if (req->type == REQ_GROUP) |
517 | req_cancel_subs (req); |
368 | { |
518 | } |
369 | aio_req sub; |
|
|
370 | |
519 | |
371 | for (sub = req->grp_first; sub; sub = sub->grp_next) |
520 | static void *aio_proc(void *arg); |
372 | req_cancel (sub); |
521 | |
|
|
522 | static void start_thread (void) |
|
|
523 | { |
|
|
524 | sigset_t fullsigset, oldsigset; |
|
|
525 | pthread_attr_t attr; |
|
|
526 | |
|
|
527 | worker *wrk = calloc (1, sizeof (worker)); |
|
|
528 | |
|
|
529 | if (!wrk) |
|
|
530 | croak ("unable to allocate worker thread data"); |
|
|
531 | |
|
|
532 | pthread_attr_init (&attr); |
|
|
533 | pthread_attr_setstacksize (&attr, STACKSIZE); |
|
|
534 | pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED); |
|
|
535 | #ifdef PTHREAD_SCOPE_PROCESS |
|
|
536 | pthread_attr_setscope (&attr, PTHREAD_SCOPE_PROCESS); |
|
|
537 | #endif |
|
|
538 | |
|
|
539 | sigfillset (&fullsigset); |
|
|
540 | |
|
|
541 | LOCK (wrklock); |
|
|
542 | sigprocmask (SIG_SETMASK, &fullsigset, &oldsigset); |
|
|
543 | |
|
|
544 | if (pthread_create (&wrk->tid, &attr, aio_proc, (void *)wrk) == 0) |
373 | } |
545 | { |
374 | } |
546 | wrk->prev = &wrk_first; |
|
|
547 | wrk->next = wrk_first.next; |
|
|
548 | wrk_first.next->prev = wrk; |
|
|
549 | wrk_first.next = wrk; |
|
|
550 | ++started; |
|
|
551 | } |
|
|
552 | else |
|
|
553 | free (wrk); |
375 | |
554 | |
|
|
555 | sigprocmask (SIG_SETMASK, &oldsigset, 0); |
|
|
556 | UNLOCK (wrklock); |
|
|
557 | } |
|
|
558 | |
|
|
559 | static void maybe_start_thread () |
|
|
560 | { |
|
|
561 | #if 0 |
|
|
562 | static struct timeval last; |
|
|
563 | struct timeval diff, now; |
|
|
564 | #endif |
|
|
565 | |
|
|
566 | if (started >= wanted) |
|
|
567 | return; |
|
|
568 | |
|
|
569 | if (nready <= nreqs - get_nready () - get_npending ()) |
|
|
570 | return; |
|
|
571 | |
|
|
572 | #if 0 |
|
|
573 | gettimeofday (&now, 0); |
|
|
574 | |
|
|
575 | diff.tv_sec = now.tv_sec - last.tv_sec; |
|
|
576 | diff.tv_usec = now.tv_usec - last.tv_usec; |
|
|
577 | |
|
|
578 | if (diff.tv_usec < 0) |
|
|
579 | { |
|
|
580 | --diff.tv_sec; |
|
|
581 | diff.tv_usec += 1000000; |
|
|
582 | } |
|
|
583 | |
|
|
584 | if (!diff.tv_sec && diff.tv_usec < 10000) |
|
|
585 | return; |
|
|
586 | |
|
|
587 | last = now; |
|
|
588 | #endif |
|
|
589 | |
|
|
590 | start_thread (); |
|
|
591 | } |
|
|
592 | |
|
|
593 | static void req_send (aio_req req) |
|
|
594 | { |
|
|
595 | ++nreqs; |
|
|
596 | |
|
|
597 | LOCK (reqlock); |
|
|
598 | ++nready; |
|
|
599 | reqq_push (&req_queue, req); |
|
|
600 | pthread_cond_signal (&reqwait); |
|
|
601 | UNLOCK (reqlock); |
|
|
602 | |
|
|
603 | maybe_start_thread (); |
|
|
604 | } |
|
|
605 | |
|
|
606 | static void end_thread (void) |
|
|
607 | { |
|
|
608 | aio_req req; |
|
|
609 | |
|
|
610 | Newz (0, req, 1, aio_cb); |
|
|
611 | |
|
|
612 | req->type = REQ_QUIT; |
|
|
613 | req->pri = PRI_MAX + PRI_BIAS; |
|
|
614 | |
|
|
615 | LOCK (reqlock); |
|
|
616 | reqq_push (&req_queue, req); |
|
|
617 | pthread_cond_signal (&reqwait); |
|
|
618 | UNLOCK (reqlock); |
|
|
619 | |
|
|
620 | LOCK (wrklock); |
|
|
621 | --started; |
|
|
622 | UNLOCK (wrklock); |
|
|
623 | } |
|
|
624 | |
|
|
625 | static void min_parallel (int nthreads) |
|
|
626 | { |
|
|
627 | if (wanted < nthreads) |
|
|
628 | wanted = nthreads; |
|
|
629 | } |
|
|
630 | |
|
|
631 | static void max_parallel (int nthreads) |
|
|
632 | { |
|
|
633 | if (wanted > nthreads) |
|
|
634 | wanted = nthreads; |
|
|
635 | |
|
|
636 | while (started > wanted) |
|
|
637 | end_thread (); |
|
|
638 | } |
|
|
639 | |
|
|
640 | static void poll_wait () |
|
|
641 | { |
|
|
642 | fd_set rfd; |
|
|
643 | |
|
|
644 | while (nreqs) |
|
|
645 | { |
|
|
646 | int size; |
|
|
647 | if (WORDREAD_UNSAFE) LOCK (reslock); |
|
|
648 | size = res_queue.size; |
|
|
649 | if (WORDREAD_UNSAFE) UNLOCK (reslock); |
|
|
650 | |
|
|
651 | if (size) |
|
|
652 | return; |
|
|
653 | |
|
|
654 | maybe_start_thread (); |
|
|
655 | |
|
|
656 | FD_ZERO(&rfd); |
|
|
657 | FD_SET(respipe [0], &rfd); |
|
|
658 | |
|
|
659 | select (respipe [0] + 1, &rfd, 0, 0, 0); |
|
|
660 | } |
|
|
661 | } |
|
|
662 | |
376 | static int poll_cb () |
663 | static int poll_cb (int max) |
377 | { |
664 | { |
378 | dSP; |
665 | dSP; |
379 | int count = 0; |
666 | int count = 0; |
380 | int do_croak = 0; |
667 | int do_croak = 0; |
381 | aio_req req; |
668 | aio_req req; |
382 | |
669 | |
383 | for (;;) |
670 | for (;;) |
384 | { |
671 | { |
385 | pthread_mutex_lock (&reslock); |
672 | while (max <= 0 || count < max) |
386 | req = ress; |
|
|
387 | |
|
|
388 | if (req) |
|
|
389 | { |
673 | { |
390 | ress = req->next; |
674 | maybe_start_thread (); |
391 | |
675 | |
|
|
676 | LOCK (reslock); |
|
|
677 | req = reqq_shift (&res_queue); |
|
|
678 | |
392 | if (!ress) |
679 | if (req) |
393 | { |
680 | { |
|
|
681 | --npending; |
|
|
682 | |
|
|
683 | if (!res_queue.size) |
|
|
684 | { |
394 | /* read any signals sent by the worker threads */ |
685 | /* read any signals sent by the worker threads */ |
395 | char buf [32]; |
686 | char buf [32]; |
396 | while (read (respipe [0], buf, 32) == 32) |
687 | while (read (respipe [0], buf, 32) == 32) |
|
|
688 | ; |
397 | ; |
689 | } |
398 | |
|
|
399 | rese = 0; |
|
|
400 | } |
690 | } |
|
|
691 | |
|
|
692 | UNLOCK (reslock); |
|
|
693 | |
|
|
694 | if (!req) |
|
|
695 | break; |
|
|
696 | |
|
|
697 | --nreqs; |
|
|
698 | |
|
|
699 | if (req->type == REQ_GROUP && req->length) |
|
|
700 | { |
|
|
701 | req->fd = 1; /* mark request as delayed */ |
|
|
702 | continue; |
|
|
703 | } |
|
|
704 | else |
|
|
705 | { |
|
|
706 | if (req->type == REQ_READ) |
|
|
707 | SvCUR_set (req->data, req->dataoffset + (req->result > 0 ? req->result : 0)); |
|
|
708 | |
|
|
709 | if (req->data2ptr && (req->type == REQ_READ || req->type == REQ_WRITE)) |
|
|
710 | SvREADONLY_off (req->data); |
|
|
711 | |
|
|
712 | if (req->statdata) |
|
|
713 | { |
|
|
714 | PL_laststype = req->type == REQ_LSTAT ? OP_LSTAT : OP_STAT; |
|
|
715 | PL_laststatval = req->result; |
|
|
716 | PL_statcache = *(req->statdata); |
|
|
717 | } |
|
|
718 | |
|
|
719 | req_invoke (req); |
|
|
720 | |
|
|
721 | count++; |
|
|
722 | } |
|
|
723 | |
|
|
724 | req_free (req); |
401 | } |
725 | } |
402 | |
726 | |
403 | pthread_mutex_unlock (&reslock); |
727 | if (nreqs <= max_outstanding) |
404 | |
|
|
405 | if (!req) |
|
|
406 | break; |
728 | break; |
407 | |
729 | |
408 | --nreqs; |
730 | poll_wait (); |
409 | |
731 | |
410 | if (req->type == REQ_QUIT) |
732 | max = 0; |
411 | started--; |
|
|
412 | else if (req->type == REQ_GROUP && req->length) |
|
|
413 | { |
|
|
414 | req->fd = 1; /* mark request as delayed */ |
|
|
415 | continue; |
|
|
416 | } |
|
|
417 | else |
|
|
418 | { |
|
|
419 | if (req->type == REQ_READ) |
|
|
420 | SvCUR_set (req->data, req->dataoffset + (req->result > 0 ? req->result : 0)); |
|
|
421 | |
|
|
422 | if (req->data2ptr && (req->type == REQ_READ || req->type == REQ_WRITE)) |
|
|
423 | SvREADONLY_off (req->data); |
|
|
424 | |
|
|
425 | if (req->statdata) |
|
|
426 | { |
|
|
427 | PL_laststype = req->type == REQ_LSTAT ? OP_LSTAT : OP_STAT; |
|
|
428 | PL_laststatval = req->result; |
|
|
429 | PL_statcache = *(req->statdata); |
|
|
430 | } |
|
|
431 | |
|
|
432 | req_invoke (req); |
|
|
433 | |
|
|
434 | count++; |
|
|
435 | } |
|
|
436 | |
|
|
437 | req_free (req); |
|
|
438 | } |
733 | } |
439 | |
734 | |
440 | return count; |
735 | return count; |
441 | } |
|
|
442 | |
|
|
443 | static void *aio_proc(void *arg); |
|
|
444 | |
|
|
445 | static void start_thread (void) |
|
|
446 | { |
|
|
447 | sigset_t fullsigset, oldsigset; |
|
|
448 | pthread_t tid; |
|
|
449 | pthread_attr_t attr; |
|
|
450 | |
|
|
451 | pthread_attr_init (&attr); |
|
|
452 | pthread_attr_setstacksize (&attr, STACKSIZE); |
|
|
453 | pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED); |
|
|
454 | |
|
|
455 | sigfillset (&fullsigset); |
|
|
456 | sigprocmask (SIG_SETMASK, &fullsigset, &oldsigset); |
|
|
457 | |
|
|
458 | if (pthread_create (&tid, &attr, aio_proc, 0) == 0) |
|
|
459 | started++; |
|
|
460 | |
|
|
461 | sigprocmask (SIG_SETMASK, &oldsigset, 0); |
|
|
462 | } |
|
|
463 | |
|
|
464 | static void req_send (aio_req req) |
|
|
465 | { |
|
|
466 | while (started < wanted && nreqs >= started) |
|
|
467 | start_thread (); |
|
|
468 | |
|
|
469 | ++nreqs; |
|
|
470 | |
|
|
471 | pthread_mutex_lock (&reqlock); |
|
|
472 | |
|
|
473 | req->next = 0; |
|
|
474 | |
|
|
475 | if (reqe) |
|
|
476 | { |
|
|
477 | reqe->next = req; |
|
|
478 | reqe = req; |
|
|
479 | } |
|
|
480 | else |
|
|
481 | reqe = reqs = req; |
|
|
482 | |
|
|
483 | pthread_cond_signal (&reqwait); |
|
|
484 | pthread_mutex_unlock (&reqlock); |
|
|
485 | |
|
|
486 | if (nreqs > max_outstanding) |
|
|
487 | for (;;) |
|
|
488 | { |
|
|
489 | poll_cb (); |
|
|
490 | |
|
|
491 | if (nreqs <= max_outstanding) |
|
|
492 | break; |
|
|
493 | |
|
|
494 | poll_wait (); |
|
|
495 | } |
|
|
496 | } |
|
|
497 | |
|
|
498 | static void end_thread (void) |
|
|
499 | { |
|
|
500 | aio_req req; |
|
|
501 | Newz (0, req, 1, aio_cb); |
|
|
502 | req->type = REQ_QUIT; |
|
|
503 | |
|
|
504 | req_send (req); |
|
|
505 | } |
|
|
506 | |
|
|
507 | static void min_parallel (int nthreads) |
|
|
508 | { |
|
|
509 | if (wanted < nthreads) |
|
|
510 | wanted = nthreads; |
|
|
511 | } |
|
|
512 | |
|
|
513 | static void max_parallel (int nthreads) |
|
|
514 | { |
|
|
515 | int cur = started; |
|
|
516 | |
|
|
517 | if (wanted > nthreads) |
|
|
518 | wanted = nthreads; |
|
|
519 | |
|
|
520 | while (cur > wanted) |
|
|
521 | { |
|
|
522 | end_thread (); |
|
|
523 | cur--; |
|
|
524 | } |
|
|
525 | |
|
|
526 | while (started > wanted) |
|
|
527 | { |
|
|
528 | poll_wait (); |
|
|
529 | poll_cb (); |
|
|
530 | } |
|
|
531 | } |
736 | } |
532 | |
737 | |
533 | static void create_pipe () |
738 | static void create_pipe () |
534 | { |
739 | { |
535 | if (pipe (respipe)) |
740 | if (pipe (respipe)) |
… | |
… | |
559 | static ssize_t pread (int fd, void *buf, size_t count, off_t offset) |
764 | static ssize_t pread (int fd, void *buf, size_t count, off_t offset) |
560 | { |
765 | { |
561 | ssize_t res; |
766 | ssize_t res; |
562 | off_t ooffset; |
767 | off_t ooffset; |
563 | |
768 | |
564 | pthread_mutex_lock (&preadwritelock); |
769 | LOCK (preadwritelock); |
565 | ooffset = lseek (fd, 0, SEEK_CUR); |
770 | ooffset = lseek (fd, 0, SEEK_CUR); |
566 | lseek (fd, offset, SEEK_SET); |
771 | lseek (fd, offset, SEEK_SET); |
567 | res = read (fd, buf, count); |
772 | res = read (fd, buf, count); |
568 | lseek (fd, ooffset, SEEK_SET); |
773 | lseek (fd, ooffset, SEEK_SET); |
569 | pthread_mutex_unlock (&preadwritelock); |
774 | UNLOCK (preadwritelock); |
570 | |
775 | |
571 | return res; |
776 | return res; |
572 | } |
777 | } |
573 | |
778 | |
574 | static ssize_t pwrite (int fd, void *buf, size_t count, off_t offset) |
779 | static ssize_t pwrite (int fd, void *buf, size_t count, off_t offset) |
575 | { |
780 | { |
576 | ssize_t res; |
781 | ssize_t res; |
577 | off_t ooffset; |
782 | off_t ooffset; |
578 | |
783 | |
579 | pthread_mutex_lock (&preadwritelock); |
784 | LOCK (preadwritelock); |
580 | ooffset = lseek (fd, 0, SEEK_CUR); |
785 | ooffset = lseek (fd, 0, SEEK_CUR); |
581 | lseek (fd, offset, SEEK_SET); |
786 | lseek (fd, offset, SEEK_SET); |
582 | res = write (fd, buf, count); |
787 | res = write (fd, buf, count); |
583 | lseek (fd, offset, SEEK_SET); |
788 | lseek (fd, offset, SEEK_SET); |
584 | pthread_mutex_unlock (&preadwritelock); |
789 | UNLOCK (preadwritelock); |
585 | |
790 | |
586 | return res; |
791 | return res; |
587 | } |
792 | } |
588 | #endif |
793 | #endif |
589 | |
794 | |
590 | #if !HAVE_FDATASYNC |
795 | #if !HAVE_FDATASYNC |
591 | # define fdatasync fsync |
796 | # define fdatasync fsync |
592 | #endif |
797 | #endif |
593 | |
798 | |
594 | #if !HAVE_READAHEAD |
799 | #if !HAVE_READAHEAD |
595 | # define readahead aio_readahead |
800 | # define readahead(fd,offset,count) aio_readahead (fd, offset, count, self) |
596 | |
801 | |
597 | static ssize_t readahead (int fd, off_t offset, size_t count) |
802 | static ssize_t aio_readahead (int fd, off_t offset, size_t count, worker *self) |
598 | { |
803 | { |
599 | char readahead_buf[4096]; |
804 | dBUF; |
600 | |
805 | |
601 | while (count > 0) |
806 | while (count > 0) |
602 | { |
807 | { |
603 | size_t len = count < sizeof (readahead_buf) ? count : sizeof (readahead_buf); |
808 | size_t len = count < AIO_BUFSIZE ? count : AIO_BUFSIZE; |
604 | |
809 | |
605 | pread (fd, readahead_buf, len, offset); |
810 | pread (fd, aio_buf, len, offset); |
606 | offset += len; |
811 | offset += len; |
607 | count -= len; |
812 | count -= len; |
608 | } |
813 | } |
609 | |
814 | |
610 | errno = 0; |
815 | errno = 0; |
611 | } |
816 | } |
|
|
817 | |
612 | #endif |
818 | #endif |
613 | |
819 | |
614 | #if !HAVE_READDIR_R |
820 | #if !HAVE_READDIR_R |
615 | # define readdir_r aio_readdir_r |
821 | # define readdir_r aio_readdir_r |
616 | |
822 | |
… | |
… | |
619 | static int readdir_r (DIR *dirp, struct dirent *ent, struct dirent **res) |
825 | static int readdir_r (DIR *dirp, struct dirent *ent, struct dirent **res) |
620 | { |
826 | { |
621 | struct dirent *e; |
827 | struct dirent *e; |
622 | int errorno; |
828 | int errorno; |
623 | |
829 | |
624 | pthread_mutex_lock (&readdirlock); |
830 | LOCK (readdirlock); |
625 | |
831 | |
626 | e = readdir (dirp); |
832 | e = readdir (dirp); |
627 | errorno = errno; |
833 | errorno = errno; |
628 | |
834 | |
629 | if (e) |
835 | if (e) |
… | |
… | |
632 | strcpy (ent->d_name, e->d_name); |
838 | strcpy (ent->d_name, e->d_name); |
633 | } |
839 | } |
634 | else |
840 | else |
635 | *res = 0; |
841 | *res = 0; |
636 | |
842 | |
637 | pthread_mutex_unlock (&readdirlock); |
843 | UNLOCK (readdirlock); |
638 | |
844 | |
639 | errno = errorno; |
845 | errno = errorno; |
640 | return e ? 0 : -1; |
846 | return e ? 0 : -1; |
641 | } |
847 | } |
642 | #endif |
848 | #endif |
643 | |
849 | |
644 | /* sendfile always needs emulation */ |
850 | /* sendfile always needs emulation */ |
645 | static ssize_t sendfile_ (int ofd, int ifd, off_t offset, size_t count) |
851 | static ssize_t sendfile_ (int ofd, int ifd, off_t offset, size_t count, worker *self) |
646 | { |
852 | { |
647 | ssize_t res; |
853 | ssize_t res; |
648 | |
854 | |
649 | if (!count) |
855 | if (!count) |
650 | return 0; |
856 | return 0; |
… | |
… | |
661 | { |
867 | { |
662 | off_t sbytes; |
868 | off_t sbytes; |
663 | res = sendfile (ifd, ofd, offset, count, 0, &sbytes, 0); |
869 | res = sendfile (ifd, ofd, offset, count, 0, &sbytes, 0); |
664 | |
870 | |
665 | if (res < 0 && sbytes) |
871 | if (res < 0 && sbytes) |
666 | /* maybe only on EAGAIN only: as usual, the manpage leaves you guessing */ |
872 | /* maybe only on EAGAIN: as usual, the manpage leaves you guessing */ |
667 | res = sbytes; |
873 | res = sbytes; |
668 | } |
874 | } |
669 | |
875 | |
670 | # elif __hpux |
876 | # elif __hpux |
671 | res = sendfile (ofd, ifd, offset, count, 0, 0); |
877 | res = sendfile (ofd, ifd, offset, count, 0, 0); |
… | |
… | |
699 | #endif |
905 | #endif |
700 | ) |
906 | ) |
701 | ) |
907 | ) |
702 | { |
908 | { |
703 | /* emulate sendfile. this is a major pain in the ass */ |
909 | /* emulate sendfile. this is a major pain in the ass */ |
704 | char buf[4096]; |
910 | dBUF; |
|
|
911 | |
705 | res = 0; |
912 | res = 0; |
706 | |
913 | |
707 | while (count) |
914 | while (count) |
708 | { |
915 | { |
709 | ssize_t cnt; |
916 | ssize_t cnt; |
710 | |
917 | |
711 | cnt = pread (ifd, buf, count > 4096 ? 4096 : count, offset); |
918 | cnt = pread (ifd, aio_buf, count > AIO_BUFSIZE ? AIO_BUFSIZE : count, offset); |
712 | |
919 | |
713 | if (cnt <= 0) |
920 | if (cnt <= 0) |
714 | { |
921 | { |
715 | if (cnt && !res) res = -1; |
922 | if (cnt && !res) res = -1; |
716 | break; |
923 | break; |
717 | } |
924 | } |
718 | |
925 | |
719 | cnt = write (ofd, buf, cnt); |
926 | cnt = write (ofd, aio_buf, cnt); |
720 | |
927 | |
721 | if (cnt <= 0) |
928 | if (cnt <= 0) |
722 | { |
929 | { |
723 | if (cnt && !res) res = -1; |
930 | if (cnt && !res) res = -1; |
724 | break; |
931 | break; |
… | |
… | |
732 | |
939 | |
733 | return res; |
940 | return res; |
734 | } |
941 | } |
735 | |
942 | |
736 | /* read a full directory */ |
943 | /* read a full directory */ |
737 | static int scandir_ (const char *path, void **namesp) |
944 | static void scandir_ (aio_req req, worker *self) |
738 | { |
945 | { |
739 | DIR *dirp = opendir (path); |
946 | DIR *dirp; |
740 | union |
947 | union |
741 | { |
948 | { |
742 | struct dirent d; |
949 | struct dirent d; |
743 | char b [offsetof (struct dirent, d_name) + NAME_MAX + 1]; |
950 | char b [offsetof (struct dirent, d_name) + NAME_MAX + 1]; |
744 | } u; |
951 | } *u; |
745 | struct dirent *entp; |
952 | struct dirent *entp; |
746 | char *name, *names; |
953 | char *name, *names; |
747 | int memlen = 4096; |
954 | int memlen = 4096; |
748 | int memofs = 0; |
955 | int memofs = 0; |
749 | int res = 0; |
956 | int res = 0; |
750 | int errorno; |
957 | int errorno; |
751 | |
958 | |
752 | if (!dirp) |
959 | LOCK (wrklock); |
753 | return -1; |
960 | self->dirp = dirp = opendir (req->dataptr); |
754 | |
961 | self->dbuf = u = malloc (sizeof (*u)); |
755 | names = malloc (memlen); |
962 | req->data2ptr = names = malloc (memlen); |
|
|
963 | UNLOCK (wrklock); |
|
|
964 | |
|
|
965 | if (dirp && u && names) |
|
|
966 | for (;;) |
|
|
967 | { |
|
|
968 | errno = 0; |
|
|
969 | readdir_r (dirp, &u->d, &entp); |
|
|
970 | |
|
|
971 | if (!entp) |
|
|
972 | break; |
|
|
973 | |
|
|
974 | name = entp->d_name; |
|
|
975 | |
|
|
976 | if (name [0] != '.' || (name [1] && (name [1] != '.' || name [2]))) |
|
|
977 | { |
|
|
978 | int len = strlen (name) + 1; |
|
|
979 | |
|
|
980 | res++; |
|
|
981 | |
|
|
982 | while (memofs + len > memlen) |
|
|
983 | { |
|
|
984 | memlen *= 2; |
|
|
985 | LOCK (wrklock); |
|
|
986 | req->data2ptr = names = realloc (names, memlen); |
|
|
987 | UNLOCK (wrklock); |
|
|
988 | |
|
|
989 | if (!names) |
|
|
990 | break; |
|
|
991 | } |
|
|
992 | |
|
|
993 | memcpy (names + memofs, name, len); |
|
|
994 | memofs += len; |
|
|
995 | } |
|
|
996 | } |
|
|
997 | |
|
|
998 | if (errno) |
|
|
999 | res = -1; |
|
|
1000 | |
|
|
1001 | req->result = res; |
|
|
1002 | } |
|
|
1003 | |
|
|
1004 | /*****************************************************************************/ |
|
|
1005 | |
|
|
1006 | static void *aio_proc (void *thr_arg) |
|
|
1007 | { |
|
|
1008 | aio_req req; |
|
|
1009 | worker *self = (worker *)thr_arg; |
756 | |
1010 | |
757 | for (;;) |
1011 | for (;;) |
758 | { |
1012 | { |
759 | errno = 0, readdir_r (dirp, &u.d, &entp); |
1013 | LOCK (reqlock); |
760 | |
|
|
761 | if (!entp) |
|
|
762 | break; |
|
|
763 | |
|
|
764 | name = entp->d_name; |
|
|
765 | |
|
|
766 | if (name [0] != '.' || (name [1] && (name [1] != '.' || name [2]))) |
|
|
767 | { |
|
|
768 | int len = strlen (name) + 1; |
|
|
769 | |
|
|
770 | res++; |
|
|
771 | |
|
|
772 | while (memofs + len > memlen) |
|
|
773 | { |
|
|
774 | memlen *= 2; |
|
|
775 | names = realloc (names, memlen); |
|
|
776 | if (!names) |
|
|
777 | break; |
|
|
778 | } |
|
|
779 | |
|
|
780 | memcpy (names + memofs, name, len); |
|
|
781 | memofs += len; |
|
|
782 | } |
|
|
783 | } |
|
|
784 | |
|
|
785 | errorno = errno; |
|
|
786 | closedir (dirp); |
|
|
787 | |
|
|
788 | if (errorno) |
|
|
789 | { |
|
|
790 | free (names); |
|
|
791 | errno = errorno; |
|
|
792 | res = -1; |
|
|
793 | } |
|
|
794 | |
|
|
795 | *namesp = (void *)names; |
|
|
796 | return res; |
|
|
797 | } |
|
|
798 | |
|
|
799 | /*****************************************************************************/ |
|
|
800 | |
|
|
801 | static void *aio_proc (void *thr_arg) |
|
|
802 | { |
|
|
803 | aio_req req; |
|
|
804 | int type; |
|
|
805 | |
|
|
806 | do |
|
|
807 | { |
|
|
808 | pthread_mutex_lock (&reqlock); |
|
|
809 | |
1014 | |
810 | for (;;) |
1015 | for (;;) |
811 | { |
1016 | { |
812 | req = reqs; |
1017 | self->req = req = reqq_shift (&req_queue); |
813 | |
|
|
814 | if (reqs) |
|
|
815 | { |
|
|
816 | reqs = reqs->next; |
|
|
817 | if (!reqs) reqe = 0; |
|
|
818 | } |
|
|
819 | |
1018 | |
820 | if (req) |
1019 | if (req) |
821 | break; |
1020 | break; |
822 | |
1021 | |
823 | pthread_cond_wait (&reqwait, &reqlock); |
1022 | pthread_cond_wait (&reqwait, &reqlock); |
824 | } |
1023 | } |
825 | |
1024 | |
826 | pthread_mutex_unlock (&reqlock); |
1025 | --nready; |
|
|
1026 | |
|
|
1027 | UNLOCK (reqlock); |
827 | |
1028 | |
828 | errno = 0; /* strictly unnecessary */ |
1029 | errno = 0; /* strictly unnecessary */ |
829 | type = req->type; /* remember type for QUIT check */ |
|
|
830 | |
1030 | |
831 | if (!(req->flags & FLAG_CANCELLED)) |
1031 | if (!(req->flags & FLAG_CANCELLED)) |
832 | switch (type) |
1032 | switch (req->type) |
833 | { |
1033 | { |
834 | case REQ_READ: req->result = pread (req->fd, req->dataptr, req->length, req->offset); break; |
1034 | case REQ_READ: req->result = pread (req->fd, req->dataptr, req->length, req->offset); break; |
835 | case REQ_WRITE: req->result = pwrite (req->fd, req->dataptr, req->length, req->offset); break; |
1035 | case REQ_WRITE: req->result = pwrite (req->fd, req->dataptr, req->length, req->offset); break; |
836 | |
1036 | |
837 | case REQ_READAHEAD: req->result = readahead (req->fd, req->offset, req->length); break; |
1037 | case REQ_READAHEAD: req->result = readahead (req->fd, req->offset, req->length); break; |
838 | case REQ_SENDFILE: req->result = sendfile_ (req->fd, req->fd2, req->offset, req->length); break; |
1038 | case REQ_SENDFILE: req->result = sendfile_ (req->fd, req->fd2, req->offset, req->length, self); break; |
839 | |
1039 | |
840 | case REQ_STAT: req->result = stat (req->dataptr, req->statdata); break; |
1040 | case REQ_STAT: req->result = stat (req->dataptr, req->statdata); break; |
841 | case REQ_LSTAT: req->result = lstat (req->dataptr, req->statdata); break; |
1041 | case REQ_LSTAT: req->result = lstat (req->dataptr, req->statdata); break; |
842 | case REQ_FSTAT: req->result = fstat (req->fd , req->statdata); break; |
1042 | case REQ_FSTAT: req->result = fstat (req->fd , req->statdata); break; |
843 | |
1043 | |
… | |
… | |
846 | case REQ_UNLINK: req->result = unlink (req->dataptr); break; |
1046 | case REQ_UNLINK: req->result = unlink (req->dataptr); break; |
847 | case REQ_RMDIR: req->result = rmdir (req->dataptr); break; |
1047 | case REQ_RMDIR: req->result = rmdir (req->dataptr); break; |
848 | case REQ_RENAME: req->result = rename (req->data2ptr, req->dataptr); break; |
1048 | case REQ_RENAME: req->result = rename (req->data2ptr, req->dataptr); break; |
849 | case REQ_LINK: req->result = link (req->data2ptr, req->dataptr); break; |
1049 | case REQ_LINK: req->result = link (req->data2ptr, req->dataptr); break; |
850 | case REQ_SYMLINK: req->result = symlink (req->data2ptr, req->dataptr); break; |
1050 | case REQ_SYMLINK: req->result = symlink (req->data2ptr, req->dataptr); break; |
|
|
1051 | case REQ_MKNOD: req->result = mknod (req->data2ptr, req->mode, (dev_t)req->offset); break; |
851 | |
1052 | |
852 | case REQ_FDATASYNC: req->result = fdatasync (req->fd); break; |
1053 | case REQ_FDATASYNC: req->result = fdatasync (req->fd); break; |
853 | case REQ_FSYNC: req->result = fsync (req->fd); break; |
1054 | case REQ_FSYNC: req->result = fsync (req->fd); break; |
854 | case REQ_READDIR: req->result = scandir_ (req->dataptr, &req->data2ptr); break; |
1055 | case REQ_READDIR: scandir_ (req, self); break; |
855 | |
1056 | |
856 | case REQ_SLEEP: |
1057 | case REQ_BUSY: |
857 | { |
1058 | { |
858 | struct timeval tv; |
1059 | struct timeval tv; |
859 | |
1060 | |
860 | tv.tv_sec = req->fd; |
1061 | tv.tv_sec = req->fd; |
861 | tv.tv_usec = req->fd2; |
1062 | tv.tv_usec = req->fd2; |
… | |
… | |
863 | req->result = select (0, 0, 0, 0, &tv); |
1064 | req->result = select (0, 0, 0, 0, &tv); |
864 | } |
1065 | } |
865 | |
1066 | |
866 | case REQ_GROUP: |
1067 | case REQ_GROUP: |
867 | case REQ_NOP: |
1068 | case REQ_NOP: |
|
|
1069 | break; |
|
|
1070 | |
868 | case REQ_QUIT: |
1071 | case REQ_QUIT: |
|
|
1072 | LOCK (wrklock); |
|
|
1073 | worker_free (self); |
|
|
1074 | --started; |
|
|
1075 | UNLOCK (wrklock); |
869 | break; |
1076 | return 0; |
870 | |
1077 | |
871 | default: |
1078 | default: |
872 | req->result = ENOSYS; |
1079 | req->result = ENOSYS; |
873 | break; |
1080 | break; |
874 | } |
1081 | } |
875 | |
1082 | |
876 | req->errorno = errno; |
1083 | req->errorno = errno; |
877 | |
1084 | |
878 | pthread_mutex_lock (&reslock); |
1085 | LOCK (reslock); |
879 | |
1086 | |
880 | req->next = 0; |
1087 | ++npending; |
881 | |
1088 | |
882 | if (rese) |
1089 | if (!reqq_push (&res_queue, req)) |
883 | { |
|
|
884 | rese->next = req; |
|
|
885 | rese = req; |
|
|
886 | } |
|
|
887 | else |
|
|
888 | { |
|
|
889 | rese = ress = req; |
|
|
890 | |
|
|
891 | /* write a dummy byte to the pipe so fh becomes ready */ |
1090 | /* write a dummy byte to the pipe so fh becomes ready */ |
892 | write (respipe [1], &respipe, 1); |
1091 | write (respipe [1], &respipe, 1); |
893 | } |
|
|
894 | |
1092 | |
895 | pthread_mutex_unlock (&reslock); |
1093 | self->req = 0; |
896 | } |
1094 | worker_clear (self); |
897 | while (type != REQ_QUIT); |
|
|
898 | |
1095 | |
899 | return 0; |
1096 | UNLOCK (reslock); |
|
|
1097 | } |
900 | } |
1098 | } |
901 | |
1099 | |
902 | /*****************************************************************************/ |
1100 | /*****************************************************************************/ |
903 | |
1101 | |
904 | static void atfork_prepare (void) |
1102 | static void atfork_prepare (void) |
905 | { |
1103 | { |
906 | pthread_mutex_lock (&reqlock); |
1104 | LOCK (wrklock); |
907 | pthread_mutex_lock (&reslock); |
1105 | LOCK (reqlock); |
|
|
1106 | LOCK (reslock); |
908 | #if !HAVE_PREADWRITE |
1107 | #if !HAVE_PREADWRITE |
909 | pthread_mutex_lock (&preadwritelock); |
1108 | LOCK (preadwritelock); |
910 | #endif |
1109 | #endif |
911 | #if !HAVE_READDIR_R |
1110 | #if !HAVE_READDIR_R |
912 | pthread_mutex_lock (&readdirlock); |
1111 | LOCK (readdirlock); |
913 | #endif |
1112 | #endif |
914 | } |
1113 | } |
915 | |
1114 | |
916 | static void atfork_parent (void) |
1115 | static void atfork_parent (void) |
917 | { |
1116 | { |
918 | #if !HAVE_READDIR_R |
1117 | #if !HAVE_READDIR_R |
919 | pthread_mutex_unlock (&readdirlock); |
1118 | UNLOCK (readdirlock); |
920 | #endif |
1119 | #endif |
921 | #if !HAVE_PREADWRITE |
1120 | #if !HAVE_PREADWRITE |
922 | pthread_mutex_unlock (&preadwritelock); |
1121 | UNLOCK (preadwritelock); |
923 | #endif |
1122 | #endif |
924 | pthread_mutex_unlock (&reslock); |
1123 | UNLOCK (reslock); |
925 | pthread_mutex_unlock (&reqlock); |
1124 | UNLOCK (reqlock); |
|
|
1125 | UNLOCK (wrklock); |
926 | } |
1126 | } |
927 | |
1127 | |
928 | static void atfork_child (void) |
1128 | static void atfork_child (void) |
929 | { |
1129 | { |
930 | aio_req prv; |
1130 | aio_req prv; |
931 | |
1131 | |
|
|
1132 | while (prv = reqq_shift (&req_queue)) |
|
|
1133 | req_free (prv); |
|
|
1134 | |
|
|
1135 | while (prv = reqq_shift (&res_queue)) |
|
|
1136 | req_free (prv); |
|
|
1137 | |
|
|
1138 | while (wrk_first.next != &wrk_first) |
|
|
1139 | { |
|
|
1140 | worker *wrk = wrk_first.next; |
|
|
1141 | |
|
|
1142 | if (wrk->req) |
|
|
1143 | req_free (wrk->req); |
|
|
1144 | |
|
|
1145 | worker_clear (wrk); |
|
|
1146 | worker_free (wrk); |
|
|
1147 | } |
|
|
1148 | |
932 | started = 0; |
1149 | started = 0; |
933 | |
1150 | nreqs = 0; |
934 | while (reqs) |
|
|
935 | { |
|
|
936 | prv = reqs; |
|
|
937 | reqs = prv->next; |
|
|
938 | req_free (prv); |
|
|
939 | } |
|
|
940 | |
|
|
941 | reqs = reqe = 0; |
|
|
942 | |
|
|
943 | while (ress) |
|
|
944 | { |
|
|
945 | prv = ress; |
|
|
946 | ress = prv->next; |
|
|
947 | req_free (prv); |
|
|
948 | } |
|
|
949 | |
|
|
950 | ress = rese = 0; |
|
|
951 | |
1151 | |
952 | close (respipe [0]); |
1152 | close (respipe [0]); |
953 | close (respipe [1]); |
1153 | close (respipe [1]); |
954 | create_pipe (); |
1154 | create_pipe (); |
955 | |
1155 | |
… | |
… | |
982 | PROTOTYPES: ENABLE |
1182 | PROTOTYPES: ENABLE |
983 | |
1183 | |
984 | BOOT: |
1184 | BOOT: |
985 | { |
1185 | { |
986 | HV *stash = gv_stashpv ("IO::AIO", 1); |
1186 | HV *stash = gv_stashpv ("IO::AIO", 1); |
|
|
1187 | |
987 | newCONSTSUB (stash, "EXDEV", newSViv (EXDEV)); |
1188 | newCONSTSUB (stash, "EXDEV", newSViv (EXDEV)); |
988 | newCONSTSUB (stash, "O_RDONLY", newSViv (O_RDONLY)); |
1189 | newCONSTSUB (stash, "O_RDONLY", newSViv (O_RDONLY)); |
989 | newCONSTSUB (stash, "O_WRONLY", newSViv (O_WRONLY)); |
1190 | newCONSTSUB (stash, "O_WRONLY", newSViv (O_WRONLY)); |
|
|
1191 | newCONSTSUB (stash, "O_CREAT", newSViv (O_CREAT)); |
|
|
1192 | newCONSTSUB (stash, "O_TRUNC", newSViv (O_TRUNC)); |
|
|
1193 | newCONSTSUB (stash, "S_IFIFO", newSViv (S_IFIFO)); |
990 | |
1194 | |
991 | create_pipe (); |
1195 | create_pipe (); |
992 | pthread_atfork (atfork_prepare, atfork_parent, atfork_child); |
1196 | pthread_atfork (atfork_prepare, atfork_parent, atfork_child); |
993 | } |
|
|
994 | |
1197 | |
|
|
1198 | start_thread (); |
|
|
1199 | } |
|
|
1200 | |
995 | void |
1201 | void |
996 | min_parallel (nthreads) |
1202 | min_parallel (int nthreads) |
997 | int nthreads |
|
|
998 | PROTOTYPE: $ |
1203 | PROTOTYPE: $ |
999 | |
1204 | |
1000 | void |
1205 | void |
1001 | max_parallel (nthreads) |
1206 | max_parallel (int nthreads) |
1002 | int nthreads |
|
|
1003 | PROTOTYPE: $ |
1207 | PROTOTYPE: $ |
1004 | |
1208 | |
1005 | int |
1209 | int |
1006 | max_outstanding (nreqs) |
1210 | max_outstanding (int maxreqs) |
1007 | int nreqs |
1211 | PROTOTYPE: $ |
1008 | PROTOTYPE: $ |
|
|
1009 | CODE: |
1212 | CODE: |
1010 | RETVAL = max_outstanding; |
1213 | RETVAL = max_outstanding; |
1011 | max_outstanding = nreqs; |
1214 | max_outstanding = maxreqs; |
|
|
1215 | OUTPUT: |
|
|
1216 | RETVAL |
1012 | |
1217 | |
1013 | void |
1218 | void |
1014 | aio_open (pathname,flags,mode,callback=&PL_sv_undef) |
1219 | aio_open (pathname,flags,mode,callback=&PL_sv_undef) |
1015 | SV * pathname |
1220 | SV * pathname |
1016 | int flags |
1221 | int flags |
… | |
… | |
1231 | |
1436 | |
1232 | REQ_SEND; |
1437 | REQ_SEND; |
1233 | } |
1438 | } |
1234 | |
1439 | |
1235 | void |
1440 | void |
|
|
1441 | aio_mknod (pathname,mode,dev,callback=&PL_sv_undef) |
|
|
1442 | SV * pathname |
|
|
1443 | SV * callback |
|
|
1444 | UV mode |
|
|
1445 | UV dev |
|
|
1446 | PPCODE: |
|
|
1447 | { |
|
|
1448 | dREQ; |
|
|
1449 | |
|
|
1450 | req->type = REQ_MKNOD; |
|
|
1451 | req->data = newSVsv (pathname); |
|
|
1452 | req->dataptr = SvPVbyte_nolen (req->data); |
|
|
1453 | req->mode = (mode_t)mode; |
|
|
1454 | req->offset = dev; |
|
|
1455 | |
|
|
1456 | REQ_SEND; |
|
|
1457 | } |
|
|
1458 | |
|
|
1459 | void |
1236 | aio_sleep (delay,callback=&PL_sv_undef) |
1460 | aio_busy (delay,callback=&PL_sv_undef) |
1237 | double delay |
1461 | double delay |
1238 | SV * callback |
1462 | SV * callback |
1239 | PPCODE: |
1463 | PPCODE: |
1240 | { |
1464 | { |
1241 | dREQ; |
1465 | dREQ; |
1242 | |
1466 | |
1243 | req->type = REQ_SLEEP; |
1467 | req->type = REQ_BUSY; |
1244 | req->fd = delay < 0. ? 0 : delay; |
1468 | req->fd = delay < 0. ? 0 : delay; |
1245 | req->fd2 = delay < 0. ? 0 : 1000. * (delay - req->fd); |
1469 | req->fd2 = delay < 0. ? 0 : 1000. * (delay - req->fd); |
1246 | |
1470 | |
1247 | REQ_SEND; |
1471 | REQ_SEND; |
1248 | } |
1472 | } |
… | |
… | |
1271 | req->type = REQ_NOP; |
1495 | req->type = REQ_NOP; |
1272 | |
1496 | |
1273 | REQ_SEND; |
1497 | REQ_SEND; |
1274 | } |
1498 | } |
1275 | |
1499 | |
1276 | #if 0 |
1500 | int |
1277 | |
1501 | aioreq_pri (int pri = 0) |
1278 | void |
1502 | PROTOTYPE: ;$ |
1279 | aio_pri (int pri = DEFAULT_PRI) |
|
|
1280 | CODE: |
1503 | CODE: |
|
|
1504 | RETVAL = next_pri - PRI_BIAS; |
|
|
1505 | if (items > 0) |
|
|
1506 | { |
1281 | if (pri < PRI_MIN) pri = PRI_MIN; |
1507 | if (pri < PRI_MIN) pri = PRI_MIN; |
1282 | if (pri > PRI_MAX) pri = PRI_MAX; |
1508 | if (pri > PRI_MAX) pri = PRI_MAX; |
1283 | next_pri = pri + PRI_BIAS; |
1509 | next_pri = pri + PRI_BIAS; |
|
|
1510 | } |
|
|
1511 | OUTPUT: |
|
|
1512 | RETVAL |
1284 | |
1513 | |
1285 | #endif |
1514 | void |
|
|
1515 | aioreq_nice (int nice = 0) |
|
|
1516 | CODE: |
|
|
1517 | nice = next_pri - nice; |
|
|
1518 | if (nice < PRI_MIN) nice = PRI_MIN; |
|
|
1519 | if (nice > PRI_MAX) nice = PRI_MAX; |
|
|
1520 | next_pri = nice + PRI_BIAS; |
1286 | |
1521 | |
1287 | void |
1522 | void |
1288 | flush () |
1523 | flush () |
1289 | PROTOTYPE: |
1524 | PROTOTYPE: |
1290 | CODE: |
1525 | CODE: |
1291 | while (nreqs) |
1526 | while (nreqs) |
1292 | { |
1527 | { |
1293 | poll_wait (); |
1528 | poll_wait (); |
1294 | poll_cb (); |
1529 | poll_cb (0); |
1295 | } |
1530 | } |
1296 | |
1531 | |
1297 | void |
1532 | void |
1298 | poll() |
1533 | poll() |
1299 | PROTOTYPE: |
1534 | PROTOTYPE: |
1300 | CODE: |
1535 | CODE: |
1301 | if (nreqs) |
1536 | if (nreqs) |
1302 | { |
1537 | { |
1303 | poll_wait (); |
1538 | poll_wait (); |
1304 | poll_cb (); |
1539 | poll_cb (0); |
1305 | } |
1540 | } |
1306 | |
1541 | |
1307 | int |
1542 | int |
1308 | poll_fileno() |
1543 | poll_fileno() |
1309 | PROTOTYPE: |
1544 | PROTOTYPE: |
… | |
… | |
1314 | |
1549 | |
1315 | int |
1550 | int |
1316 | poll_cb(...) |
1551 | poll_cb(...) |
1317 | PROTOTYPE: |
1552 | PROTOTYPE: |
1318 | CODE: |
1553 | CODE: |
1319 | RETVAL = poll_cb (); |
1554 | RETVAL = poll_cb (0); |
|
|
1555 | OUTPUT: |
|
|
1556 | RETVAL |
|
|
1557 | |
|
|
1558 | int |
|
|
1559 | poll_some(int max = 0) |
|
|
1560 | PROTOTYPE: $ |
|
|
1561 | CODE: |
|
|
1562 | RETVAL = poll_cb (max); |
1320 | OUTPUT: |
1563 | OUTPUT: |
1321 | RETVAL |
1564 | RETVAL |
1322 | |
1565 | |
1323 | void |
1566 | void |
1324 | poll_wait() |
1567 | poll_wait() |
… | |
… | |
1333 | CODE: |
1576 | CODE: |
1334 | RETVAL = nreqs; |
1577 | RETVAL = nreqs; |
1335 | OUTPUT: |
1578 | OUTPUT: |
1336 | RETVAL |
1579 | RETVAL |
1337 | |
1580 | |
|
|
1581 | int |
|
|
1582 | nready() |
|
|
1583 | PROTOTYPE: |
|
|
1584 | CODE: |
|
|
1585 | RETVAL = get_nready (); |
|
|
1586 | OUTPUT: |
|
|
1587 | RETVAL |
|
|
1588 | |
|
|
1589 | int |
|
|
1590 | npending() |
|
|
1591 | PROTOTYPE: |
|
|
1592 | CODE: |
|
|
1593 | RETVAL = get_npending (); |
|
|
1594 | OUTPUT: |
|
|
1595 | RETVAL |
|
|
1596 | |
1338 | PROTOTYPES: DISABLE |
1597 | PROTOTYPES: DISABLE |
1339 | |
1598 | |
1340 | MODULE = IO::AIO PACKAGE = IO::AIO::REQ |
1599 | MODULE = IO::AIO PACKAGE = IO::AIO::REQ |
1341 | |
1600 | |
1342 | void |
1601 | void |
1343 | cancel (aio_req_ornot req) |
1602 | cancel (aio_req_ornot req) |
1344 | PROTOTYPE: |
|
|
1345 | CODE: |
1603 | CODE: |
1346 | req_cancel (req); |
1604 | req_cancel (req); |
1347 | |
1605 | |
1348 | void |
1606 | void |
1349 | cb (aio_req_ornot req, SV *callback=&PL_sv_undef) |
1607 | cb (aio_req_ornot req, SV *callback=&PL_sv_undef) |
… | |
… | |
1385 | } |
1643 | } |
1386 | } |
1644 | } |
1387 | } |
1645 | } |
1388 | |
1646 | |
1389 | void |
1647 | void |
|
|
1648 | cancel_subs (aio_req_ornot req) |
|
|
1649 | CODE: |
|
|
1650 | req_cancel_subs (req); |
|
|
1651 | |
|
|
1652 | void |
1390 | result (aio_req grp, ...) |
1653 | result (aio_req grp, ...) |
1391 | CODE: |
1654 | CODE: |
1392 | { |
1655 | { |
1393 | int i; |
1656 | int i; |
|
|
1657 | AV *av; |
|
|
1658 | |
|
|
1659 | grp->errorno = errno; |
|
|
1660 | |
1394 | AV *av = newAV (); |
1661 | av = newAV (); |
1395 | |
1662 | |
1396 | for (i = 1; i < items; ++i ) |
1663 | for (i = 1; i < items; ++i ) |
1397 | av_push (av, newSVsv (ST (i))); |
1664 | av_push (av, newSVsv (ST (i))); |
1398 | |
1665 | |
1399 | SvREFCNT_dec (grp->data); |
1666 | SvREFCNT_dec (grp->data); |
1400 | grp->data = (SV *)av; |
1667 | grp->data = (SV *)av; |
1401 | } |
1668 | } |
1402 | |
1669 | |
1403 | void |
1670 | void |
|
|
1671 | errno (aio_req grp, int errorno = errno) |
|
|
1672 | CODE: |
|
|
1673 | grp->errorno = errorno; |
|
|
1674 | |
|
|
1675 | void |
1404 | feed_limit (aio_req grp, int limit) |
1676 | limit (aio_req grp, int limit) |
1405 | CODE: |
1677 | CODE: |
1406 | grp->fd2 = limit; |
1678 | grp->fd2 = limit; |
1407 | aio_grp_feed (grp); |
1679 | aio_grp_feed (grp); |
1408 | |
1680 | |
1409 | void |
1681 | void |