… | |
… | |
3 | #include <errno.h> |
3 | #include <errno.h> |
4 | |
4 | |
5 | #include "EXTERN.h" |
5 | #include "EXTERN.h" |
6 | #include "perl.h" |
6 | #include "perl.h" |
7 | #include "XSUB.h" |
7 | #include "XSUB.h" |
|
|
8 | |
|
|
9 | #include "schmorp.h" |
8 | |
10 | |
9 | #include <stddef.h> |
11 | #include <stddef.h> |
10 | #include <stdlib.h> |
12 | #include <stdlib.h> |
11 | #include <errno.h> |
13 | #include <errno.h> |
12 | #include <sys/types.h> |
14 | #include <sys/types.h> |
13 | #include <sys/stat.h> |
15 | #include <sys/stat.h> |
|
|
16 | #include <sys/statvfs.h> |
14 | #include <limits.h> |
17 | #include <limits.h> |
15 | #include <fcntl.h> |
18 | #include <fcntl.h> |
16 | #include <sched.h> |
19 | #include <sched.h> |
|
|
20 | |
|
|
21 | #if _POSIX_MEMLOCK || _POSIX_MAPPED_FILES |
|
|
22 | # include <sys/mman.h> |
|
|
23 | #endif |
17 | |
24 | |
18 | /* perl namespace pollution */ |
25 | /* perl namespace pollution */ |
19 | #undef VERSION |
26 | #undef VERSION |
20 | |
27 | |
21 | #ifdef _WIN32 |
28 | #ifdef _WIN32 |
… | |
… | |
65 | # include <signal.h> |
72 | # include <signal.h> |
66 | # define EIO_STRUCT_DIRENT struct dirent |
73 | # define EIO_STRUCT_DIRENT struct dirent |
67 | |
74 | |
68 | #endif |
75 | #endif |
69 | |
76 | |
|
|
77 | /* perl stupidly overrides readdir and maybe others */ |
|
|
78 | /* with thread-unsafe versions, imagine that :( */ |
|
|
79 | #undef readdir |
|
|
80 | #undef opendir |
|
|
81 | #undef closedir |
|
|
82 | |
70 | #define EIO_STRUCT_STAT Stat_t |
83 | #define EIO_STRUCT_STAT Stat_t |
71 | |
84 | |
72 | /* use NV for 32 bit perls as it allows larger offsets */ |
85 | /* use NV for 32 bit perls as it allows larger offsets */ |
73 | #if IVSIZE >= 8 |
86 | #if IVSIZE >= 8 |
|
|
87 | # define VAL64 IV |
74 | # define SvVAL64 SvIV |
88 | # define SvVAL64 SvIV |
|
|
89 | # define newSVval64 newSViv |
75 | #else |
90 | #else |
|
|
91 | # define VAL64 NV |
76 | # define SvVAL64 SvNV |
92 | # define SvVAL64 SvNV |
|
|
93 | # define newSVval64 newSVnv |
77 | #endif |
94 | #endif |
78 | |
95 | |
79 | static HV *stash; |
96 | /*****************************************************************************/ |
|
|
97 | |
|
|
98 | #if __GNUC__ >= 3 |
|
|
99 | # define expect(expr,value) __builtin_expect ((expr),(value)) |
|
|
100 | #else |
|
|
101 | # define expect(expr,value) (expr) |
|
|
102 | #endif |
|
|
103 | |
|
|
104 | #define expect_false(expr) expect ((expr) != 0, 0) |
|
|
105 | #define expect_true(expr) expect ((expr) != 0, 1) |
|
|
106 | |
|
|
107 | /*****************************************************************************/ |
|
|
108 | |
80 | typedef SV SV8; /* byte-sv, used for argument-checking */ |
109 | typedef SV SV8; /* byte-sv, used for argument-checking */ |
|
|
110 | typedef int aio_rfd; /* read file desriptor */ |
|
|
111 | typedef int aio_wfd; /* write file descriptor */ |
81 | |
112 | |
82 | #define AIO_REQ_KLASS "IO::AIO::REQ" |
113 | static HV *aio_stash, *aio_req_stash, *aio_grp_stash; |
83 | #define AIO_GRP_KLASS "IO::AIO::GRP" |
|
|
84 | |
114 | |
85 | #define EIO_COMMON \ |
115 | #define EIO_REQ_MEMBERS \ |
86 | SV *callback; \ |
116 | SV *callback; \ |
87 | SV *sv1, *sv2; \ |
117 | SV *sv1, *sv2; \ |
88 | STRLEN stroffset; \ |
118 | STRLEN stroffset; \ |
89 | SV *self |
119 | SV *self; |
|
|
120 | |
|
|
121 | #define EIO_NO_WRAPPERS 1 |
90 | |
122 | |
91 | #include "libeio/eio.h" |
123 | #include "libeio/eio.h" |
|
|
124 | |
|
|
125 | #ifndef POSIX_FADV_NORMAL |
|
|
126 | # define POSIX_FADV_NORMAL 0 |
|
|
127 | # define NO_FADVISE 1 |
|
|
128 | #endif |
|
|
129 | #ifndef POSIX_FADV_SEQUENTIAL |
|
|
130 | # define POSIX_FADV_SEQUENTIAL 0 |
|
|
131 | #endif |
|
|
132 | #ifndef POSIX_FADV_RANDOM |
|
|
133 | # define POSIX_FADV_RANDOM 0 |
|
|
134 | #endif |
|
|
135 | #ifndef POSIX_FADV_NOREUSE |
|
|
136 | # define POSIX_FADV_NOREUSE 0 |
|
|
137 | #endif |
|
|
138 | #ifndef POSIX_FADV_WILLNEED |
|
|
139 | # define POSIX_FADV_WILLNEED 0 |
|
|
140 | #endif |
|
|
141 | #ifndef POSIX_FADV_DONTNEED |
|
|
142 | # define POSIX_FADV_DONTNEED 0 |
|
|
143 | #endif |
|
|
144 | |
|
|
145 | #ifndef POSIX_MADV_NORMAL |
|
|
146 | # define POSIX_MADV_NORMAL 0 |
|
|
147 | # define NO_MADVISE 1 |
|
|
148 | #endif |
|
|
149 | #ifndef POSIX_MADV_SEQUENTIAL |
|
|
150 | # define POSIX_MADV_SEQUENTIAL 0 |
|
|
151 | #endif |
|
|
152 | #ifndef POSIX_MADV_RANDOM |
|
|
153 | # define POSIX_MADV_RANDOM 0 |
|
|
154 | #endif |
|
|
155 | #ifndef POSIX_MADV_WILLNEED |
|
|
156 | # define POSIX_MADV_WILLNEED 0 |
|
|
157 | #endif |
|
|
158 | #ifndef POSIX_MADV_DONTNEED |
|
|
159 | # define POSIX_MADV_DONTNEED 0 |
|
|
160 | #endif |
|
|
161 | |
|
|
162 | #ifndef ST_NODEV |
|
|
163 | # define ST_NODEV 0 |
|
|
164 | #endif |
|
|
165 | #ifndef ST_NOEXEC |
|
|
166 | # define ST_NOEXEC 0 |
|
|
167 | #endif |
|
|
168 | #ifndef ST_SYNCHRONOUS |
|
|
169 | # define ST_SYNCHRONOUS 0 |
|
|
170 | #endif |
|
|
171 | #ifndef ST_MANDLOCK |
|
|
172 | # define ST_MANDLOCK 0 |
|
|
173 | #endif |
|
|
174 | #ifndef ST_WRITE |
|
|
175 | # define ST_WRITE 0 |
|
|
176 | #endif |
|
|
177 | #ifndef ST_APPEND |
|
|
178 | # define ST_APPEND 0 |
|
|
179 | #endif |
|
|
180 | #ifndef ST_IMMUTABLE |
|
|
181 | # define ST_IMMUTABLE 0 |
|
|
182 | #endif |
|
|
183 | #ifndef ST_NOATIME |
|
|
184 | # define ST_NOATIME 0 |
|
|
185 | #endif |
|
|
186 | #ifndef ST_NODIRATIME |
|
|
187 | # define ST_NODIRATIME 0 |
|
|
188 | #endif |
|
|
189 | #ifndef ST_RELATIME |
|
|
190 | # define ST_RELATIME 0 |
|
|
191 | #endif |
|
|
192 | |
|
|
193 | #ifndef MCL_CURRENT |
|
|
194 | # define MCL_CURRENT 0 |
|
|
195 | #endif |
|
|
196 | #ifndef MCL_FUTURE |
|
|
197 | # define MCL_FUTURE 0 |
|
|
198 | #endif |
|
|
199 | |
|
|
200 | #ifndef MAP_ANONYMOUS |
|
|
201 | # ifdef MAP_ANON |
|
|
202 | # define MAP_ANONYMOUS MAP_ANON |
|
|
203 | # else |
|
|
204 | # define MAP_ANONYMOUS MAP_FIXED /* and hope this fails */ |
|
|
205 | # endif |
|
|
206 | #endif |
|
|
207 | #ifndef MAP_HUGETLB |
|
|
208 | # define MAP_HUGETLB 0 |
|
|
209 | #endif |
|
|
210 | #ifndef MAP_LOCKED |
|
|
211 | # define MAP_LOCKED 0 |
|
|
212 | #endif |
|
|
213 | #ifndef MAP_NORESERVE |
|
|
214 | # define MAP_NORESERVE 0 |
|
|
215 | #endif |
|
|
216 | #ifndef MAP_POPULATE |
|
|
217 | # define MAP_POPULATE 0 |
|
|
218 | #endif |
|
|
219 | #ifndef MAP_NONBLOCK |
|
|
220 | # define MAP_NONBLOCK 0 |
|
|
221 | #endif |
|
|
222 | |
|
|
223 | #ifndef PAGESIZE |
|
|
224 | # define PAGESIZE sysconf (_SC_PAGESIZE) |
|
|
225 | #endif |
92 | |
226 | |
93 | static int req_invoke (eio_req *req); |
227 | static int req_invoke (eio_req *req); |
94 | #define EIO_FINISH(req) req_invoke (req) |
228 | #define EIO_FINISH(req) req_invoke (req) |
95 | static void aio_grp_feed (eio_req *grp); |
|
|
96 | #define EIO_FEED(req) aio_grp_feed (req) |
|
|
97 | static void req_destroy (eio_req *grp); |
229 | static void req_destroy (eio_req *grp); |
98 | #define EIO_DESTROY(req) req_destroy (req) |
230 | #define EIO_DESTROY(req) req_destroy (req) |
99 | |
231 | |
100 | enum { |
232 | enum { |
101 | FLAG_SV2_RO_OFF = 0x40, /* data was set readonly */ |
233 | FLAG_SV2_RO_OFF = 0x40, /* data was set readonly */ |
… | |
… | |
105 | |
237 | |
106 | typedef eio_req *aio_req; |
238 | typedef eio_req *aio_req; |
107 | typedef eio_req *aio_req_ornot; |
239 | typedef eio_req *aio_req_ornot; |
108 | |
240 | |
109 | static SV *on_next_submit; |
241 | static SV *on_next_submit; |
110 | static int next_pri = EIO_DEFAULT_PRI + EIO_PRI_BIAS; |
242 | static int next_pri = EIO_PRI_DEFAULT; |
111 | static int max_outstanding; |
243 | static int max_outstanding; |
112 | |
244 | |
113 | static int respipe_osf [2], respipe [2] = { -1, -1 }; |
245 | static s_epipe respipe; |
114 | |
246 | |
115 | static void req_destroy (aio_req req); |
247 | static void req_destroy (aio_req req); |
116 | static void req_cancel (aio_req req); |
248 | static void req_cancel (aio_req req); |
117 | |
249 | |
118 | static void want_poll (void) |
250 | static void want_poll (void) |
119 | { |
251 | { |
120 | /* write a dummy byte to the pipe so fh becomes ready */ |
252 | /* write a dummy byte to the pipe so fh becomes ready */ |
121 | respipe_write (respipe_osf [1], (const void *)&respipe_osf, 1); |
253 | s_epipe_signal (&respipe); |
122 | } |
254 | } |
123 | |
255 | |
124 | static void done_poll (void) |
256 | static void done_poll (void) |
125 | { |
257 | { |
126 | /* read any signals sent by the worker threads */ |
258 | /* read any signals sent by the worker threads */ |
127 | char buf [4]; |
259 | s_epipe_drain (&respipe); |
128 | while (respipe_read (respipe [0], buf, 4) == 4) |
|
|
129 | ; |
|
|
130 | } |
260 | } |
131 | |
261 | |
132 | /* must be called at most once */ |
262 | /* must be called at most once */ |
133 | static SV *req_sv (aio_req req, const char *klass) |
263 | static SV *req_sv (aio_req req, HV *stash) |
134 | { |
264 | { |
135 | if (!req->self) |
265 | if (!req->self) |
136 | { |
266 | { |
137 | req->self = (SV *)newHV (); |
267 | req->self = (SV *)newHV (); |
138 | sv_magic (req->self, 0, PERL_MAGIC_ext, (char *)req, 0); |
268 | sv_magic (req->self, 0, PERL_MAGIC_ext, (char *)req, 0); |
139 | } |
269 | } |
140 | |
270 | |
141 | return sv_2mortal (sv_bless (newRV_inc (req->self), gv_stashpv (klass, 1))); |
271 | return sv_2mortal (sv_bless (newRV_inc (req->self), stash)); |
142 | } |
272 | } |
143 | |
273 | |
144 | static aio_req SvAIO_REQ (SV *sv) |
274 | static aio_req SvAIO_REQ (SV *sv) |
145 | { |
275 | { |
146 | MAGIC *mg; |
276 | MAGIC *mg; |
147 | |
277 | |
148 | if (!sv_derived_from (sv, AIO_REQ_KLASS) || !SvROK (sv)) |
278 | if (!SvROK (sv) |
|
|
279 | || (SvSTASH (SvRV (sv)) != aio_grp_stash |
|
|
280 | && SvSTASH (SvRV (sv)) != aio_req_stash |
|
|
281 | && !sv_derived_from (sv, "IO::AIO::REQ"))) |
149 | croak ("object of class " AIO_REQ_KLASS " expected"); |
282 | croak ("object of class IO::AIO::REQ expected"); |
150 | |
283 | |
151 | mg = mg_find (SvRV (sv), PERL_MAGIC_ext); |
284 | mg = mg_find (SvRV (sv), PERL_MAGIC_ext); |
152 | |
285 | |
153 | return mg ? (aio_req)mg->mg_ptr : 0; |
286 | return mg ? (aio_req)mg->mg_ptr : 0; |
154 | } |
287 | } |
… | |
… | |
160 | dSP; |
293 | dSP; |
161 | |
294 | |
162 | ENTER; |
295 | ENTER; |
163 | SAVETMPS; |
296 | SAVETMPS; |
164 | PUSHMARK (SP); |
297 | PUSHMARK (SP); |
165 | XPUSHs (req_sv (grp, AIO_GRP_KLASS)); |
298 | XPUSHs (req_sv (grp, aio_grp_stash)); |
166 | PUTBACK; |
299 | PUTBACK; |
167 | call_sv (grp->sv2, G_VOID | G_EVAL | G_KEEPERR); |
300 | call_sv (grp->sv2, G_VOID | G_EVAL | G_KEEPERR); |
168 | SPAGAIN; |
301 | SPAGAIN; |
169 | FREETMPS; |
302 | FREETMPS; |
170 | LEAVE; |
303 | LEAVE; |
… | |
… | |
173 | |
306 | |
174 | static void req_submit (eio_req *req) |
307 | static void req_submit (eio_req *req) |
175 | { |
308 | { |
176 | eio_submit (req); |
309 | eio_submit (req); |
177 | |
310 | |
178 | if (on_next_submit) |
311 | if (expect_false (on_next_submit)) |
179 | { |
312 | { |
180 | dSP; |
313 | dSP; |
181 | SV *cb = sv_2mortal (on_next_submit); |
314 | SV *cb = sv_2mortal (on_next_submit); |
182 | |
315 | |
183 | on_next_submit = 0; |
316 | on_next_submit = 0; |
… | |
… | |
188 | } |
321 | } |
189 | } |
322 | } |
190 | |
323 | |
191 | static int req_invoke (eio_req *req) |
324 | static int req_invoke (eio_req *req) |
192 | { |
325 | { |
193 | dSP; |
|
|
194 | |
|
|
195 | if (req->flags & FLAG_SV2_RO_OFF) |
326 | if (req->flags & FLAG_SV2_RO_OFF) |
196 | SvREADONLY_off (req->sv2); |
327 | SvREADONLY_off (req->sv2); |
197 | |
328 | |
198 | if (!EIO_CANCELLED (req) && SvOK (req->callback)) |
329 | if (!EIO_CANCELLED (req) && req->callback) |
199 | { |
330 | { |
|
|
331 | dSP; |
|
|
332 | static SV *sv_result_cache; /* caches the result integer SV */ |
|
|
333 | SV *sv_result; |
|
|
334 | |
200 | ENTER; |
335 | ENTER; |
201 | SAVETMPS; |
336 | SAVETMPS; |
202 | PUSHMARK (SP); |
337 | PUSHMARK (SP); |
203 | EXTEND (SP, 1); |
338 | EXTEND (SP, 1); |
|
|
339 | |
|
|
340 | /* do not recreate the result IV from scratch each time */ |
|
|
341 | if (expect_true (sv_result_cache)) |
|
|
342 | { |
|
|
343 | sv_result = sv_result_cache; sv_result_cache = 0; |
|
|
344 | SvIV_set (sv_result, req->result); |
|
|
345 | } |
|
|
346 | else |
|
|
347 | { |
|
|
348 | sv_result = newSViv (req->result); |
|
|
349 | SvREADONLY_on (sv_result); |
|
|
350 | } |
204 | |
351 | |
205 | switch (req->type) |
352 | switch (req->type) |
206 | { |
353 | { |
207 | case EIO_READDIR: |
354 | case EIO_READDIR: |
208 | { |
355 | { |
209 | SV *rv = &PL_sv_undef; |
356 | SV *rv = &PL_sv_undef; |
210 | |
357 | |
211 | if (req->result >= 0) |
358 | if (req->result >= 0) |
212 | { |
359 | { |
213 | int i; |
360 | int i; |
214 | char *buf = req->ptr2; |
361 | char *names = (char *)req->ptr2; |
|
|
362 | eio_dirent *ent = (eio_dirent *)req->ptr1; /* might be 0 */ |
215 | AV *av = newAV (); |
363 | AV *av = newAV (); |
216 | |
364 | |
217 | av_extend (av, req->result - 1); |
365 | av_extend (av, req->result - 1); |
218 | |
366 | |
219 | for (i = 0; i < req->result; ++i) |
367 | for (i = 0; i < req->result; ++i) |
220 | { |
368 | { |
221 | SV *sv = newSVpv (buf, 0); |
369 | if (req->int1 & EIO_READDIR_DENTS) |
|
|
370 | { |
|
|
371 | SV *namesv = newSVpvn (names + ent->nameofs, ent->namelen); |
222 | |
372 | |
|
|
373 | if (req->int1 & EIO_READDIR_CUSTOM2) |
|
|
374 | { |
|
|
375 | static SV *sv_type [EIO_DT_MAX + 1]; /* type sv cache */ |
|
|
376 | AV *avent = newAV (); |
|
|
377 | |
|
|
378 | av_extend (avent, 2); |
|
|
379 | |
|
|
380 | if (!sv_type [ent->type]) |
|
|
381 | { |
|
|
382 | sv_type [ent->type] = newSViv (ent->type); |
|
|
383 | SvREADONLY_on (sv_type [ent->type]); |
|
|
384 | } |
|
|
385 | |
|
|
386 | av_store (avent, 0, namesv); |
|
|
387 | av_store (avent, 1, SvREFCNT_inc (sv_type [ent->type])); |
|
|
388 | av_store (avent, 2, IVSIZE >= 8 ? newSVuv (ent->inode) : newSVnv (ent->inode)); |
|
|
389 | |
|
|
390 | av_store (av, i, newRV_noinc ((SV *)avent)); |
|
|
391 | } |
|
|
392 | else |
223 | av_store (av, i, sv); |
393 | av_store (av, i, namesv); |
|
|
394 | |
|
|
395 | ++ent; |
|
|
396 | } |
|
|
397 | else |
|
|
398 | { |
|
|
399 | SV *name = newSVpv (names, 0); |
|
|
400 | av_store (av, i, name); |
224 | buf += SvCUR (sv) + 1; |
401 | names += SvCUR (name) + 1; |
|
|
402 | } |
225 | } |
403 | } |
226 | |
404 | |
227 | rv = sv_2mortal (newRV_noinc ((SV *)av)); |
405 | rv = sv_2mortal (newRV_noinc ((SV *)av)); |
228 | } |
406 | } |
229 | |
407 | |
230 | PUSHs (rv); |
408 | PUSHs (rv); |
|
|
409 | |
|
|
410 | if (req->int1 & EIO_READDIR_CUSTOM1) |
|
|
411 | XPUSHs (sv_2mortal (newSViv (req->int1 & ~(EIO_READDIR_CUSTOM1 | EIO_READDIR_CUSTOM2)))); |
231 | } |
412 | } |
232 | break; |
413 | break; |
233 | |
414 | |
234 | case EIO_OPEN: |
415 | case EIO_OPEN: |
235 | { |
416 | { |
… | |
… | |
241 | GV *gv = (GV *)sv_newmortal (); |
422 | GV *gv = (GV *)sv_newmortal (); |
242 | int flags = req->int1 & (O_RDONLY | O_WRONLY | O_RDWR); |
423 | int flags = req->int1 & (O_RDONLY | O_WRONLY | O_RDWR); |
243 | char sym [64]; |
424 | char sym [64]; |
244 | int symlen; |
425 | int symlen; |
245 | |
426 | |
246 | symlen = snprintf (sym, sizeof (sym), "fd#%d", req->result); |
427 | symlen = snprintf (sym, sizeof (sym), "fd#%d", (int)req->result); |
247 | gv_init (gv, stash, sym, symlen, 0); |
428 | gv_init (gv, aio_stash, sym, symlen, 0); |
248 | |
429 | |
249 | symlen = snprintf ( |
430 | symlen = snprintf ( |
250 | sym, |
431 | sym, |
251 | sizeof (sym), |
432 | sizeof (sym), |
252 | "%s&=%d", |
433 | "%s&=%d", |
253 | flags == O_RDONLY ? "<" : flags == O_WRONLY ? ">" : "+<", |
434 | flags == O_RDONLY ? "<" : flags == O_WRONLY ? ">" : "+<", |
254 | req->result |
435 | (int)req->result |
255 | ); |
436 | ); |
256 | |
437 | |
257 | if (do_open (gv, sym, symlen, 0, 0, 0, 0)) |
438 | if (do_open (gv, sym, symlen, 0, 0, 0, 0)) |
258 | fh = (SV *)gv; |
439 | fh = (SV *)gv; |
259 | } |
440 | } |
260 | |
441 | |
261 | PUSHs (fh); |
442 | PUSHs (fh); |
262 | } |
443 | } |
|
|
444 | break; |
|
|
445 | |
|
|
446 | case EIO_STATVFS: |
|
|
447 | case EIO_FSTATVFS: |
|
|
448 | { |
|
|
449 | SV *rv = &PL_sv_undef; |
|
|
450 | |
|
|
451 | if (req->result >= 0) |
|
|
452 | { |
|
|
453 | EIO_STRUCT_STATVFS *f = EIO_STATVFS_BUF (req); |
|
|
454 | HV *hv = newHV (); |
|
|
455 | |
|
|
456 | rv = sv_2mortal (newRV_noinc ((SV *)hv)); |
|
|
457 | |
|
|
458 | hv_store (hv, "bsize" , sizeof ("bsize" ) - 1, newSVval64 (f->f_bsize ), 0); |
|
|
459 | hv_store (hv, "frsize" , sizeof ("frsize" ) - 1, newSVval64 (f->f_frsize ), 0); |
|
|
460 | hv_store (hv, "blocks" , sizeof ("blocks" ) - 1, newSVval64 (f->f_blocks ), 0); |
|
|
461 | hv_store (hv, "bfree" , sizeof ("bfree" ) - 1, newSVval64 (f->f_bfree ), 0); |
|
|
462 | hv_store (hv, "bavail" , sizeof ("bavail" ) - 1, newSVval64 (f->f_bavail ), 0); |
|
|
463 | hv_store (hv, "files" , sizeof ("files" ) - 1, newSVval64 (f->f_files ), 0); |
|
|
464 | hv_store (hv, "ffree" , sizeof ("ffree" ) - 1, newSVval64 (f->f_ffree ), 0); |
|
|
465 | hv_store (hv, "favail" , sizeof ("favail" ) - 1, newSVval64 (f->f_favail ), 0); |
|
|
466 | hv_store (hv, "fsid" , sizeof ("fsid" ) - 1, newSVval64 (f->f_fsid ), 0); |
|
|
467 | hv_store (hv, "flag" , sizeof ("flag" ) - 1, newSVval64 (f->f_flag ), 0); |
|
|
468 | hv_store (hv, "namemax", sizeof ("namemax") - 1, newSVval64 (f->f_namemax), 0); |
|
|
469 | } |
|
|
470 | |
|
|
471 | PUSHs (rv); |
|
|
472 | } |
|
|
473 | |
263 | break; |
474 | break; |
264 | |
475 | |
265 | case EIO_GROUP: |
476 | case EIO_GROUP: |
266 | req->int1 = 2; /* mark group as finished */ |
477 | req->int1 = 2; /* mark group as finished */ |
267 | |
478 | |
… | |
… | |
289 | case EIO_LSTAT: |
500 | case EIO_LSTAT: |
290 | case EIO_FSTAT: |
501 | case EIO_FSTAT: |
291 | PL_laststype = req->type == EIO_LSTAT ? OP_LSTAT : OP_STAT; |
502 | PL_laststype = req->type == EIO_LSTAT ? OP_LSTAT : OP_STAT; |
292 | PL_laststatval = req->result; |
503 | PL_laststatval = req->result; |
293 | PL_statcache = *(EIO_STRUCT_STAT *)(req->ptr2); |
504 | PL_statcache = *(EIO_STRUCT_STAT *)(req->ptr2); |
294 | PUSHs (sv_2mortal (newSViv (req->result))); |
505 | PUSHs (sv_result); |
295 | break; |
506 | break; |
296 | |
507 | |
297 | case EIO_READ: |
508 | case EIO_READ: |
|
|
509 | { |
298 | SvCUR_set (req->sv2, req->stroffset + (req->result > 0 ? req->result : 0)); |
510 | SvCUR_set (req->sv2, req->stroffset + (req->result > 0 ? req->result : 0)); |
299 | *SvEND (req->sv2) = 0; |
511 | *SvEND (req->sv2) = 0; |
300 | PUSHs (sv_2mortal (newSViv (req->result))); |
512 | SvPOK_only (req->sv2); |
|
|
513 | SvSETMAGIC (req->sv2); |
|
|
514 | PUSHs (sv_result); |
|
|
515 | } |
301 | break; |
516 | break; |
302 | |
517 | |
303 | case EIO_DUP2: |
518 | case EIO_DUP2: /* EIO_DUP2 actually means aio_close(), su fudge result value */ |
304 | if (req->result > 0) |
519 | if (req->result > 0) |
305 | req->result = 0; |
520 | SvIV_set (sv_result, 0); |
306 | /* FALLTHROUGH */ |
521 | /* FALLTHROUGH */ |
307 | |
522 | |
308 | default: |
523 | default: |
309 | PUSHs (sv_2mortal (newSViv (req->result))); |
524 | PUSHs (sv_result); |
310 | break; |
525 | break; |
311 | } |
526 | } |
312 | |
527 | |
313 | errno = req->errorno; |
528 | errno = req->errorno; |
314 | |
529 | |
315 | PUTBACK; |
530 | PUTBACK; |
316 | call_sv (req->callback, G_VOID | G_EVAL | G_DISCARD); |
531 | call_sv (req->callback, G_VOID | G_EVAL | G_DISCARD); |
317 | SPAGAIN; |
532 | SPAGAIN; |
|
|
533 | |
|
|
534 | if (expect_false (SvREFCNT (sv_result) != 1 || sv_result_cache)) |
|
|
535 | SvREFCNT_dec (sv_result); |
|
|
536 | else |
|
|
537 | sv_result_cache = sv_result; |
318 | |
538 | |
319 | FREETMPS; |
539 | FREETMPS; |
320 | LEAVE; |
540 | LEAVE; |
321 | |
541 | |
322 | PUTBACK; |
542 | PUTBACK; |
… | |
… | |
351 | grp->sv2 = 0; |
571 | grp->sv2 = 0; |
352 | |
572 | |
353 | eio_grp_cancel (grp); |
573 | eio_grp_cancel (grp); |
354 | } |
574 | } |
355 | |
575 | |
356 | #ifdef USE_SOCKETS_AS_HANDLES |
|
|
357 | # define TO_SOCKET(x) (win32_get_osfhandle (x)) |
|
|
358 | #else |
|
|
359 | # define TO_SOCKET(x) (x) |
|
|
360 | #endif |
|
|
361 | |
|
|
362 | static void |
576 | static void |
363 | create_respipe (void) |
577 | create_respipe (void) |
364 | { |
578 | { |
365 | int old_readfd = respipe [0]; |
|
|
366 | |
|
|
367 | if (respipe [1] >= 0) |
|
|
368 | respipe_close (TO_SOCKET (respipe [1])); |
|
|
369 | |
|
|
370 | #ifdef _WIN32 |
|
|
371 | if (PerlSock_socketpair (AF_UNIX, SOCK_STREAM, 0, respipe)) |
|
|
372 | #else |
|
|
373 | if (pipe (respipe)) |
579 | if (s_epipe_renew (&respipe)) |
374 | #endif |
|
|
375 | croak ("unable to initialize result pipe"); |
580 | croak ("IO::AIO: unable to initialize result pipe"); |
376 | |
|
|
377 | if (old_readfd >= 0) |
|
|
378 | { |
|
|
379 | if (dup2 (TO_SOCKET (respipe [0]), TO_SOCKET (old_readfd)) < 0) |
|
|
380 | croak ("unable to initialize result pipe(2)"); |
|
|
381 | |
|
|
382 | respipe_close (respipe [0]); |
|
|
383 | respipe [0] = old_readfd; |
|
|
384 | } |
|
|
385 | |
|
|
386 | #ifdef _WIN32 |
|
|
387 | int arg = 1; |
|
|
388 | if (ioctlsocket (TO_SOCKET (respipe [0]), FIONBIO, &arg) |
|
|
389 | || ioctlsocket (TO_SOCKET (respipe [1]), FIONBIO, &arg)) |
|
|
390 | #else |
|
|
391 | if (fcntl (respipe [0], F_SETFL, O_NONBLOCK) |
|
|
392 | || fcntl (respipe [1], F_SETFL, O_NONBLOCK)) |
|
|
393 | #endif |
|
|
394 | croak ("unable to initialize result pipe(3)"); |
|
|
395 | |
|
|
396 | respipe_osf [0] = TO_SOCKET (respipe [0]); |
|
|
397 | respipe_osf [1] = TO_SOCKET (respipe [1]); |
|
|
398 | } |
581 | } |
399 | |
582 | |
400 | static void poll_wait (void) |
583 | static void poll_wait (void) |
401 | { |
584 | { |
402 | fd_set rfd; |
|
|
403 | |
|
|
404 | while (eio_nreqs ()) |
585 | while (eio_nreqs ()) |
405 | { |
586 | { |
406 | int size; |
587 | int size; |
407 | |
588 | |
408 | X_LOCK (reslock); |
589 | X_LOCK (reslock); |
… | |
… | |
410 | X_UNLOCK (reslock); |
591 | X_UNLOCK (reslock); |
411 | |
592 | |
412 | if (size) |
593 | if (size) |
413 | return; |
594 | return; |
414 | |
595 | |
415 | maybe_start_thread (); |
596 | etp_maybe_start_thread (); |
416 | |
597 | |
417 | FD_ZERO (&rfd); |
598 | s_epipe_wait (&respipe); |
418 | FD_SET (respipe [0], &rfd); |
|
|
419 | |
|
|
420 | PerlSock_select (respipe [0] + 1, &rfd, 0, 0, 0); |
|
|
421 | } |
599 | } |
422 | } |
600 | } |
423 | |
601 | |
424 | static int poll_cb (void) |
602 | static int poll_cb (void) |
425 | { |
603 | { |
426 | int res; |
604 | for (;;) |
427 | |
|
|
428 | do |
|
|
429 | { |
605 | { |
430 | res = eio_poll (); |
606 | int res = eio_poll (); |
431 | |
607 | |
432 | if (res > 0) |
608 | if (res > 0) |
433 | croak (0); |
609 | croak (0); |
|
|
610 | |
|
|
611 | if (!max_outstanding || max_outstanding > eio_nreqs ()) |
|
|
612 | return res; |
|
|
613 | |
|
|
614 | poll_wait (); |
434 | } |
615 | } |
435 | while (max_outstanding && max_outstanding <= eio_nreqs ()); |
|
|
436 | |
|
|
437 | return res; |
|
|
438 | } |
616 | } |
439 | |
617 | |
440 | static void atfork_child (void) |
618 | static void atfork_child (void) |
441 | { |
619 | { |
442 | create_respipe (); |
620 | create_respipe (); |
443 | } |
621 | } |
444 | |
622 | |
|
|
623 | /*****************************************************************************/ |
|
|
624 | |
|
|
625 | #if !_POSIX_MAPPED_FILES |
|
|
626 | # define mmap(addr,length,prot,flags,fd,offs) (errno = ENOSYS, -1) |
|
|
627 | # define munmap(addr,length) (errno = ENOSYS, -1) |
|
|
628 | #endif |
|
|
629 | |
|
|
630 | #define MMAP_MAGIC PERL_MAGIC_ext |
|
|
631 | |
|
|
632 | static int |
|
|
633 | mmap_free (pTHX_ SV *sv, MAGIC *mg) |
|
|
634 | { |
|
|
635 | int old_errno = errno; |
|
|
636 | munmap (mg->mg_ptr, (size_t)mg->mg_obj); |
|
|
637 | errno = old_errno; |
|
|
638 | |
|
|
639 | mg->mg_obj = 0; /* just in case */ |
|
|
640 | |
|
|
641 | SvREADONLY_off (sv); |
|
|
642 | |
|
|
643 | if (SvPVX (sv) != mg->mg_ptr) |
|
|
644 | croak ("ERROR: IO::AIO::mmap-mapped scalar changed location, detected"); |
|
|
645 | |
|
|
646 | SvCUR_set (sv, 0); |
|
|
647 | SvPVX (sv) = 0; |
|
|
648 | SvOK_off (sv); |
|
|
649 | |
|
|
650 | return 0; |
|
|
651 | } |
|
|
652 | |
|
|
653 | static MGVTBL mmap_vtbl = { |
|
|
654 | 0, 0, 0, 0, mmap_free |
|
|
655 | }; |
|
|
656 | |
|
|
657 | /*****************************************************************************/ |
|
|
658 | |
|
|
659 | static SV * |
|
|
660 | get_cb (SV *cb_sv) |
|
|
661 | { |
|
|
662 | SvGETMAGIC (cb_sv); |
|
|
663 | return SvOK (cb_sv) ? s_get_cv_croak (cb_sv) : 0; |
|
|
664 | } |
|
|
665 | |
445 | #define dREQ \ |
666 | #define dREQ \ |
|
|
667 | SV *cb_cv; \ |
446 | aio_req req; \ |
668 | aio_req req; \ |
447 | int req_pri = next_pri; \ |
669 | int req_pri = next_pri; \ |
448 | next_pri = EIO_DEFAULT_PRI + EIO_PRI_BIAS; \ |
670 | next_pri = EIO_PRI_DEFAULT; \ |
449 | \ |
671 | \ |
450 | if (SvOK (callback) && !SvROK (callback)) \ |
672 | cb_cv = get_cb (callback); \ |
451 | croak ("callback must be undef or of reference type"); \ |
|
|
452 | \ |
673 | \ |
453 | Newz (0, req, 1, eio_req); \ |
674 | Newz (0, req, 1, eio_req); \ |
454 | if (!req) \ |
675 | if (!req) \ |
455 | croak ("out of memory during eio_req allocation"); \ |
676 | croak ("out of memory during eio_req allocation"); \ |
456 | \ |
677 | \ |
457 | req->callback = newSVsv (callback); \ |
678 | req->callback = SvREFCNT_inc (cb_cv); \ |
458 | req->pri = req_pri |
679 | req->pri = req_pri |
459 | |
680 | |
460 | #define REQ_SEND \ |
681 | #define REQ_SEND \ |
|
|
682 | PUTBACK; \ |
461 | req_submit (req); \ |
683 | req_submit (req); \ |
|
|
684 | SPAGAIN; \ |
462 | \ |
685 | \ |
463 | if (GIMME_V != G_VOID) \ |
686 | if (GIMME_V != G_VOID) \ |
464 | XPUSHs (req_sv (req, AIO_REQ_KLASS)); |
687 | XPUSHs (req_sv (req, aio_req_stash)); |
465 | |
688 | |
466 | MODULE = IO::AIO PACKAGE = IO::AIO |
689 | MODULE = IO::AIO PACKAGE = IO::AIO |
467 | |
690 | |
468 | PROTOTYPES: ENABLE |
691 | PROTOTYPES: ENABLE |
469 | |
692 | |
470 | BOOT: |
693 | BOOT: |
471 | { |
694 | { |
472 | stash = gv_stashpv ("IO::AIO", 1); |
695 | static const struct { |
473 | |
696 | const char *name; |
474 | newCONSTSUB (stash, "EXDEV", newSViv (EXDEV)); |
697 | IV iv; |
475 | newCONSTSUB (stash, "O_RDONLY", newSViv (O_RDONLY)); |
698 | } *civ, const_iv[] = { |
476 | newCONSTSUB (stash, "O_WRONLY", newSViv (O_WRONLY)); |
699 | # define const_niv(name, value) { # name, (IV) value }, |
477 | newCONSTSUB (stash, "O_CREAT", newSViv (O_CREAT)); |
700 | # define const_iv(name) { # name, (IV) name }, |
478 | newCONSTSUB (stash, "O_TRUNC", newSViv (O_TRUNC)); |
701 | # define const_eio(name) { # name, (IV) EIO_ ## name }, |
|
|
702 | const_iv (EXDEV) |
|
|
703 | const_iv (ENOSYS) |
|
|
704 | const_iv (O_RDONLY) |
|
|
705 | const_iv (O_WRONLY) |
|
|
706 | const_iv (O_RDWR) |
|
|
707 | const_iv (O_CREAT) |
|
|
708 | const_iv (O_TRUNC) |
|
|
709 | const_iv (O_EXCL) |
|
|
710 | const_iv (O_APPEND) |
479 | #ifdef _WIN32 |
711 | #ifndef _WIN32 |
480 | X_MUTEX_CHECK (wrklock); |
712 | const_iv (S_IFIFO) |
481 | X_MUTEX_CHECK (reslock); |
|
|
482 | X_MUTEX_CHECK (reqlock); |
|
|
483 | X_MUTEX_CHECK (reqwait); |
|
|
484 | X_MUTEX_CHECK (preadwritelock); |
|
|
485 | X_MUTEX_CHECK (readdirlock); |
|
|
486 | |
|
|
487 | X_COND_CHECK (reqwait); |
|
|
488 | #else |
|
|
489 | newCONSTSUB (stash, "S_IFIFO", newSViv (S_IFIFO)); |
|
|
490 | #endif |
713 | #endif |
|
|
714 | const_niv (FADV_NORMAL , POSIX_FADV_NORMAL) |
|
|
715 | const_niv (FADV_SEQUENTIAL, POSIX_FADV_SEQUENTIAL) |
|
|
716 | const_niv (FADV_RANDOM , POSIX_FADV_RANDOM) |
|
|
717 | const_niv (FADV_NOREUSE , POSIX_FADV_NOREUSE) |
|
|
718 | const_niv (FADV_WILLNEED , POSIX_FADV_WILLNEED) |
|
|
719 | const_niv (FADV_DONTNEED , POSIX_FADV_DONTNEED) |
491 | |
720 | |
|
|
721 | const_niv (MADV_NORMAL , POSIX_MADV_NORMAL) |
|
|
722 | const_niv (MADV_SEQUENTIAL, POSIX_MADV_SEQUENTIAL) |
|
|
723 | const_niv (MADV_RANDOM , POSIX_MADV_RANDOM) |
|
|
724 | const_niv (MADV_WILLNEED , POSIX_MADV_WILLNEED) |
|
|
725 | const_niv (MADV_DONTNEED , POSIX_MADV_DONTNEED) |
|
|
726 | |
|
|
727 | const_iv (ST_RDONLY) |
|
|
728 | const_iv (ST_NOSUID) |
|
|
729 | const_iv (ST_NODEV) |
|
|
730 | const_iv (ST_NOEXEC) |
|
|
731 | const_iv (ST_SYNCHRONOUS) |
|
|
732 | const_iv (ST_MANDLOCK) |
|
|
733 | const_iv (ST_WRITE) |
|
|
734 | const_iv (ST_APPEND) |
|
|
735 | const_iv (ST_IMMUTABLE) |
|
|
736 | const_iv (ST_NOATIME) |
|
|
737 | const_iv (ST_NODIRATIME) |
|
|
738 | const_iv (ST_RELATIME) |
|
|
739 | |
|
|
740 | const_iv (PROT_EXEC) |
|
|
741 | const_iv (PROT_NONE) |
|
|
742 | const_iv (PROT_READ) |
|
|
743 | const_iv (PROT_WRITE) |
|
|
744 | |
|
|
745 | /*const_iv (MAP_FIXED)*/ |
|
|
746 | const_iv (MAP_PRIVATE) |
|
|
747 | const_iv (MAP_SHARED) |
|
|
748 | const_iv (MAP_ANONYMOUS) |
|
|
749 | |
|
|
750 | /* linuxish */ |
|
|
751 | const_iv (MAP_HUGETLB) |
|
|
752 | const_iv (MAP_LOCKED) |
|
|
753 | const_iv (MAP_NORESERVE) |
|
|
754 | const_iv (MAP_POPULATE) |
|
|
755 | const_iv (MAP_NONBLOCK) |
|
|
756 | |
|
|
757 | const_iv (MCL_FUTURE) |
|
|
758 | const_iv (MCL_CURRENT) |
|
|
759 | |
|
|
760 | const_eio (MS_ASYNC) |
|
|
761 | const_eio (MS_INVALIDATE) |
|
|
762 | const_eio (MS_SYNC) |
|
|
763 | |
|
|
764 | const_eio (MT_MODIFY) |
|
|
765 | |
|
|
766 | const_eio (SYNC_FILE_RANGE_WAIT_BEFORE) |
|
|
767 | const_eio (SYNC_FILE_RANGE_WRITE) |
|
|
768 | const_eio (SYNC_FILE_RANGE_WAIT_AFTER) |
|
|
769 | |
|
|
770 | const_eio (READDIR_DENTS) |
|
|
771 | const_eio (READDIR_DIRS_FIRST) |
|
|
772 | const_eio (READDIR_STAT_ORDER) |
|
|
773 | const_eio (READDIR_FOUND_UNKNOWN) |
|
|
774 | |
|
|
775 | const_eio (DT_UNKNOWN) |
|
|
776 | const_eio (DT_FIFO) |
|
|
777 | const_eio (DT_CHR) |
|
|
778 | const_eio (DT_DIR) |
|
|
779 | const_eio (DT_BLK) |
|
|
780 | const_eio (DT_REG) |
|
|
781 | const_eio (DT_LNK) |
|
|
782 | const_eio (DT_SOCK) |
|
|
783 | const_eio (DT_WHT) |
|
|
784 | }; |
|
|
785 | |
|
|
786 | aio_stash = gv_stashpv ("IO::AIO" , 1); |
|
|
787 | aio_req_stash = gv_stashpv ("IO::AIO::REQ", 1); |
|
|
788 | aio_grp_stash = gv_stashpv ("IO::AIO::GRP", 1); |
|
|
789 | |
|
|
790 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
|
|
791 | newCONSTSUB (aio_stash, (char *)civ->name, newSViv (civ->iv)); |
|
|
792 | |
|
|
793 | newCONSTSUB (aio_stash, "PAGESIZE", newSViv (PAGESIZE)); |
|
|
794 | |
492 | create_respipe (); |
795 | create_respipe (); |
493 | |
796 | |
494 | if (eio_init (want_poll, done_poll) < 0) |
797 | if (eio_init (want_poll, done_poll) < 0) |
495 | croak ("IO::AIO: unable to initialise eio library"); |
798 | croak ("IO::AIO: unable to initialise eio library"); |
496 | |
799 | |
497 | /* atfork child called in fifo order, so before eio's handler */ |
800 | /* atfork child called in fifo order, so before eio's handler */ |
498 | X_THREAD_ATFORK (0, 0, atfork_child); |
801 | X_THREAD_ATFORK (0, 0, atfork_child); |
499 | } |
802 | } |
500 | |
803 | |
501 | void |
804 | void |
502 | max_poll_reqs (int nreqs) |
805 | max_poll_reqs (int nreqs) |
503 | PROTOTYPE: $ |
806 | PROTOTYPE: $ |
… | |
… | |
556 | ALIAS: |
859 | ALIAS: |
557 | aio_fsync = EIO_FSYNC |
860 | aio_fsync = EIO_FSYNC |
558 | aio_fdatasync = EIO_FDATASYNC |
861 | aio_fdatasync = EIO_FDATASYNC |
559 | PPCODE: |
862 | PPCODE: |
560 | { |
863 | { |
|
|
864 | int fd = s_fileno_croak (fh, 0); |
561 | dREQ; |
865 | dREQ; |
562 | |
866 | |
563 | req->type = ix; |
867 | req->type = ix; |
564 | req->sv1 = newSVsv (fh); |
868 | req->sv1 = newSVsv (fh); |
565 | req->int1 = PerlIO_fileno (IoIFP (sv_2io (fh))); |
869 | req->int1 = fd; |
|
|
870 | |
|
|
871 | REQ_SEND (req); |
|
|
872 | } |
|
|
873 | |
|
|
874 | void |
|
|
875 | aio_sync_file_range (SV *fh, off_t offset, size_t nbytes, UV flags, SV *callback=&PL_sv_undef) |
|
|
876 | PROTOTYPE: $$$$;$ |
|
|
877 | PPCODE: |
|
|
878 | { |
|
|
879 | int fd = s_fileno_croak (fh, 0); |
|
|
880 | dREQ; |
|
|
881 | |
|
|
882 | req->type = EIO_SYNC_FILE_RANGE; |
|
|
883 | req->sv1 = newSVsv (fh); |
|
|
884 | req->int1 = fd; |
|
|
885 | req->offs = offset; |
|
|
886 | req->size = nbytes; |
|
|
887 | req->int2 = flags; |
566 | |
888 | |
567 | REQ_SEND (req); |
889 | REQ_SEND (req); |
568 | } |
890 | } |
569 | |
891 | |
570 | void |
892 | void |
571 | aio_close (SV *fh, SV *callback=&PL_sv_undef) |
893 | aio_close (SV *fh, SV *callback=&PL_sv_undef) |
572 | PROTOTYPE: $;$ |
894 | PROTOTYPE: $;$ |
573 | PPCODE: |
895 | PPCODE: |
574 | { |
896 | { |
575 | static int close_pipe = -1; /* dummy fd to close fds via dup2 */ |
897 | static int close_pipe = -1; /* dummy fd to close fds via dup2 */ |
|
|
898 | int fd = s_fileno_croak (fh, 0); |
576 | dREQ; |
899 | dREQ; |
577 | |
900 | |
578 | if (close_pipe < 0) |
901 | if (close_pipe < 0) |
579 | { |
902 | { |
580 | int pipefd [2]; |
903 | int pipefd [2]; |
… | |
… | |
588 | } |
911 | } |
589 | |
912 | |
590 | req->type = EIO_DUP2; |
913 | req->type = EIO_DUP2; |
591 | req->int1 = close_pipe; |
914 | req->int1 = close_pipe; |
592 | req->sv2 = newSVsv (fh); |
915 | req->sv2 = newSVsv (fh); |
593 | req->int2 = PerlIO_fileno (IoIFP (sv_2io (fh))); |
916 | req->int2 = fd; |
594 | |
917 | |
595 | REQ_SEND (req); |
918 | REQ_SEND (req); |
596 | } |
919 | } |
597 | |
920 | |
598 | void |
921 | void |
… | |
… | |
602 | aio_write = EIO_WRITE |
925 | aio_write = EIO_WRITE |
603 | PROTOTYPE: $$$$$;$ |
926 | PROTOTYPE: $$$$$;$ |
604 | PPCODE: |
927 | PPCODE: |
605 | { |
928 | { |
606 | STRLEN svlen; |
929 | STRLEN svlen; |
|
|
930 | int fd = s_fileno_croak (fh, ix == EIO_WRITE); |
607 | char *svptr = SvPVbyte (data, svlen); |
931 | char *svptr = SvPVbyte (data, svlen); |
608 | UV len = SvUV (length); |
932 | UV len = SvUV (length); |
609 | |
|
|
610 | SvUPGRADE (data, SVt_PV); |
|
|
611 | SvPOK_on (data); |
|
|
612 | |
933 | |
613 | if (dataoffset < 0) |
934 | if (dataoffset < 0) |
614 | dataoffset += svlen; |
935 | dataoffset += svlen; |
615 | |
936 | |
616 | if (dataoffset < 0 || dataoffset > svlen) |
937 | if (dataoffset < 0 || dataoffset > svlen) |
… | |
… | |
622 | if (!SvOK (length) || len + dataoffset > svlen) |
943 | if (!SvOK (length) || len + dataoffset > svlen) |
623 | len = svlen - dataoffset; |
944 | len = svlen - dataoffset; |
624 | } |
945 | } |
625 | else |
946 | else |
626 | { |
947 | { |
627 | /* read: grow scalar as necessary */ |
948 | /* read: check type and grow scalar as necessary */ |
|
|
949 | SvUPGRADE (data, SVt_PV); |
628 | svptr = SvGROW (data, len + dataoffset + 1); |
950 | svptr = SvGROW (data, len + dataoffset + 1); |
629 | } |
951 | } |
630 | |
952 | |
631 | if (len < 0) |
|
|
632 | croak ("length must not be negative"); |
|
|
633 | |
|
|
634 | { |
953 | { |
635 | dREQ; |
954 | dREQ; |
636 | |
955 | |
637 | req->type = ix; |
956 | req->type = ix; |
638 | req->sv1 = newSVsv (fh); |
957 | req->sv1 = newSVsv (fh); |
639 | req->int1 = PerlIO_fileno (ix == EIO_READ ? IoIFP (sv_2io (fh)) |
958 | req->int1 = fd; |
640 | : IoOFP (sv_2io (fh))); |
|
|
641 | req->offs = SvOK (offset) ? SvVAL64 (offset) : -1; |
959 | req->offs = SvOK (offset) ? SvVAL64 (offset) : -1; |
642 | req->size = len; |
960 | req->size = len; |
643 | req->sv2 = SvREFCNT_inc (data); |
961 | req->sv2 = SvREFCNT_inc (data); |
644 | req->ptr2 = (char *)svptr + dataoffset; |
962 | req->ptr2 = (char *)svptr + dataoffset; |
645 | req->stroffset = dataoffset; |
963 | req->stroffset = dataoffset; |
… | |
… | |
668 | |
986 | |
669 | REQ_SEND; |
987 | REQ_SEND; |
670 | } |
988 | } |
671 | |
989 | |
672 | void |
990 | void |
673 | aio_sendfile (SV *out_fh, SV *in_fh, SV *in_offset, UV length, SV *callback=&PL_sv_undef) |
991 | aio_sendfile (SV *out_fh, SV *in_fh, off_t in_offset, size_t length, SV *callback=&PL_sv_undef) |
674 | PROTOTYPE: $$$$;$ |
992 | PROTOTYPE: $$$$;$ |
675 | PPCODE: |
993 | PPCODE: |
676 | { |
994 | { |
|
|
995 | int ifd = s_fileno_croak (in_fh , 0); |
|
|
996 | int ofd = s_fileno_croak (out_fh, 1); |
677 | dREQ; |
997 | dREQ; |
678 | |
998 | |
679 | req->type = EIO_SENDFILE; |
999 | req->type = EIO_SENDFILE; |
680 | req->sv1 = newSVsv (out_fh); |
1000 | req->sv1 = newSVsv (out_fh); |
681 | req->int1 = PerlIO_fileno (IoIFP (sv_2io (out_fh))); |
1001 | req->int1 = ofd; |
682 | req->sv2 = newSVsv (in_fh); |
1002 | req->sv2 = newSVsv (in_fh); |
683 | req->int2 = PerlIO_fileno (IoIFP (sv_2io (in_fh))); |
1003 | req->int2 = ifd; |
684 | req->offs = SvVAL64 (in_offset); |
1004 | req->offs = in_offset; |
685 | req->size = length; |
1005 | req->size = length; |
686 | |
1006 | |
687 | REQ_SEND; |
1007 | REQ_SEND; |
688 | } |
1008 | } |
689 | |
1009 | |
690 | void |
1010 | void |
691 | aio_readahead (SV *fh, SV *offset, IV length, SV *callback=&PL_sv_undef) |
1011 | aio_readahead (SV *fh, off_t offset, size_t length, SV *callback=&PL_sv_undef) |
692 | PROTOTYPE: $$$;$ |
1012 | PROTOTYPE: $$$;$ |
693 | PPCODE: |
1013 | PPCODE: |
694 | { |
1014 | { |
|
|
1015 | int fd = s_fileno_croak (fh, 0); |
695 | dREQ; |
1016 | dREQ; |
696 | |
1017 | |
697 | req->type = EIO_READAHEAD; |
1018 | req->type = EIO_READAHEAD; |
698 | req->sv1 = newSVsv (fh); |
1019 | req->sv1 = newSVsv (fh); |
699 | req->int1 = PerlIO_fileno (IoIFP (sv_2io (fh))); |
1020 | req->int1 = fd; |
700 | req->offs = SvVAL64 (offset); |
1021 | req->offs = offset; |
701 | req->size = length; |
1022 | req->size = length; |
702 | |
1023 | |
703 | REQ_SEND; |
1024 | REQ_SEND; |
704 | } |
1025 | } |
705 | |
1026 | |
706 | void |
1027 | void |
707 | aio_stat (SV8 *fh_or_path, SV *callback=&PL_sv_undef) |
1028 | aio_stat (SV8 *fh_or_path, SV *callback=&PL_sv_undef) |
708 | ALIAS: |
1029 | ALIAS: |
709 | aio_stat = EIO_STAT |
1030 | aio_stat = EIO_STAT |
710 | aio_lstat = EIO_LSTAT |
1031 | aio_lstat = EIO_LSTAT |
|
|
1032 | aio_statvfs = EIO_STATVFS |
711 | PPCODE: |
1033 | PPCODE: |
712 | { |
1034 | { |
713 | dREQ; |
1035 | dREQ; |
714 | |
1036 | |
715 | req->sv1 = newSVsv (fh_or_path); |
1037 | req->sv1 = newSVsv (fh_or_path); |
… | |
… | |
719 | req->type = ix; |
1041 | req->type = ix; |
720 | req->ptr1 = SvPVbyte_nolen (req->sv1); |
1042 | req->ptr1 = SvPVbyte_nolen (req->sv1); |
721 | } |
1043 | } |
722 | else |
1044 | else |
723 | { |
1045 | { |
724 | req->type = EIO_FSTAT; |
1046 | req->type = ix == EIO_STATVFS ? EIO_FSTATVFS : EIO_FSTAT; |
725 | req->int1 = PerlIO_fileno (IoIFP (sv_2io (fh_or_path))); |
1047 | req->int1 = PerlIO_fileno (IoIFP (sv_2io (fh_or_path))); |
726 | } |
1048 | } |
727 | |
1049 | |
728 | REQ_SEND; |
1050 | REQ_SEND; |
729 | } |
1051 | } |
… | |
… | |
787 | req->int2 = mode; |
1109 | req->int2 = mode; |
788 | req->sv1 = newSVsv (fh_or_path); |
1110 | req->sv1 = newSVsv (fh_or_path); |
789 | |
1111 | |
790 | if (SvPOK (req->sv1)) |
1112 | if (SvPOK (req->sv1)) |
791 | { |
1113 | { |
792 | req->type = EIO_FCHMOD; |
1114 | req->type = ix; |
793 | req->int1 = PerlIO_fileno (IoIFP (sv_2io (fh_or_path))); |
1115 | req->ptr1 = SvPVbyte_nolen (req->sv1); |
794 | } |
1116 | } |
795 | else |
1117 | else |
796 | { |
1118 | { |
797 | req->type = ix; |
1119 | req->type = EIO_FCHMOD; |
798 | req->ptr1 = SvPVbyte_nolen (req->sv1); |
1120 | req->int1 = PerlIO_fileno (IoIFP (sv_2io (fh_or_path))); |
799 | } |
1121 | } |
800 | |
1122 | |
801 | REQ_SEND; |
1123 | REQ_SEND; |
802 | } |
1124 | } |
803 | |
1125 | |
… | |
… | |
824 | |
1146 | |
825 | REQ_SEND; |
1147 | REQ_SEND; |
826 | } |
1148 | } |
827 | |
1149 | |
828 | void |
1150 | void |
|
|
1151 | aio_readdirx (SV8 *pathname, IV flags, SV *callback=&PL_sv_undef) |
|
|
1152 | PPCODE: |
|
|
1153 | { |
|
|
1154 | dREQ; |
|
|
1155 | |
|
|
1156 | req->type = EIO_READDIR; |
|
|
1157 | req->sv1 = newSVsv (pathname); |
|
|
1158 | req->ptr1 = SvPVbyte_nolen (req->sv1); |
|
|
1159 | req->int1 = flags | EIO_READDIR_DENTS | EIO_READDIR_CUSTOM1; |
|
|
1160 | |
|
|
1161 | if (flags & EIO_READDIR_DENTS) |
|
|
1162 | req->int1 |= EIO_READDIR_CUSTOM2; |
|
|
1163 | |
|
|
1164 | REQ_SEND; |
|
|
1165 | } |
|
|
1166 | |
|
|
1167 | void |
829 | aio_unlink (SV8 *pathname, SV *callback=&PL_sv_undef) |
1168 | aio_unlink (SV8 *pathname, SV *callback=&PL_sv_undef) |
830 | ALIAS: |
1169 | ALIAS: |
831 | aio_unlink = EIO_UNLINK |
1170 | aio_unlink = EIO_UNLINK |
832 | aio_rmdir = EIO_RMDIR |
1171 | aio_rmdir = EIO_RMDIR |
833 | aio_readdir = EIO_READDIR |
1172 | aio_readdir = EIO_READDIR |
… | |
… | |
875 | |
1214 | |
876 | REQ_SEND; |
1215 | REQ_SEND; |
877 | } |
1216 | } |
878 | |
1217 | |
879 | void |
1218 | void |
|
|
1219 | aio_mtouch (SV8 *data, IV offset = 0, SV *length = &PL_sv_undef, int flags = 0, SV *callback=&PL_sv_undef) |
|
|
1220 | ALIAS: |
|
|
1221 | aio_mtouch = EIO_MTOUCH |
|
|
1222 | aio_msync = EIO_MSYNC |
|
|
1223 | PROTOTYPE: $$$$;$ |
|
|
1224 | PPCODE: |
|
|
1225 | { |
|
|
1226 | STRLEN svlen; |
|
|
1227 | UV len = SvUV (length); |
|
|
1228 | char *svptr = SvPVbyte (data, svlen); |
|
|
1229 | |
|
|
1230 | if (offset < 0) |
|
|
1231 | offset += svlen; |
|
|
1232 | |
|
|
1233 | if (offset < 0 || offset > svlen) |
|
|
1234 | croak ("offset outside of scalar"); |
|
|
1235 | |
|
|
1236 | if (!SvOK (length) || len + offset > svlen) |
|
|
1237 | len = svlen - offset; |
|
|
1238 | |
|
|
1239 | { |
|
|
1240 | dREQ; |
|
|
1241 | |
|
|
1242 | req->type = ix; |
|
|
1243 | req->size = len; |
|
|
1244 | req->sv2 = SvREFCNT_inc (data); |
|
|
1245 | req->ptr2 = (char *)svptr + offset; |
|
|
1246 | req->int1 = flags; |
|
|
1247 | |
|
|
1248 | REQ_SEND; |
|
|
1249 | } |
|
|
1250 | } |
|
|
1251 | |
|
|
1252 | void |
880 | aio_busy (double delay, SV *callback=&PL_sv_undef) |
1253 | aio_busy (double delay, SV *callback=&PL_sv_undef) |
881 | PPCODE: |
1254 | PPCODE: |
882 | { |
1255 | { |
883 | dREQ; |
1256 | dREQ; |
884 | |
1257 | |
… | |
… | |
895 | { |
1268 | { |
896 | dREQ; |
1269 | dREQ; |
897 | |
1270 | |
898 | req->type = EIO_GROUP; |
1271 | req->type = EIO_GROUP; |
899 | |
1272 | |
900 | eio_submit (req); |
1273 | req_submit (req); |
901 | XPUSHs (req_sv (req, AIO_GRP_KLASS)); |
1274 | XPUSHs (req_sv (req, aio_grp_stash)); |
902 | } |
1275 | } |
903 | |
1276 | |
904 | void |
1277 | void |
905 | aio_nop (SV *callback=&PL_sv_undef) |
1278 | aio_nop (SV *callback=&PL_sv_undef) |
906 | ALIAS: |
1279 | ALIAS: |
… | |
… | |
917 | |
1290 | |
918 | int |
1291 | int |
919 | aioreq_pri (int pri = 0) |
1292 | aioreq_pri (int pri = 0) |
920 | PROTOTYPE: ;$ |
1293 | PROTOTYPE: ;$ |
921 | CODE: |
1294 | CODE: |
922 | RETVAL = next_pri - EIO_PRI_BIAS; |
1295 | RETVAL = next_pri; |
923 | if (items > 0) |
1296 | if (items > 0) |
924 | { |
1297 | { |
925 | if (pri < EIO_PRI_MIN) pri = EIO_PRI_MIN; |
1298 | if (pri < EIO_PRI_MIN) pri = EIO_PRI_MIN; |
926 | if (pri > EIO_PRI_MAX) pri = EIO_PRI_MAX; |
1299 | if (pri > EIO_PRI_MAX) pri = EIO_PRI_MAX; |
927 | next_pri = pri + EIO_PRI_BIAS; |
1300 | next_pri = pri; |
928 | } |
1301 | } |
929 | OUTPUT: |
1302 | OUTPUT: |
930 | RETVAL |
1303 | RETVAL |
931 | |
1304 | |
932 | void |
1305 | void |
933 | aioreq_nice (int nice = 0) |
1306 | aioreq_nice (int nice = 0) |
934 | CODE: |
1307 | CODE: |
935 | nice = next_pri - nice; |
1308 | nice = next_pri - nice; |
936 | if (nice < EIO_PRI_MIN) nice = EIO_PRI_MIN; |
1309 | if (nice < EIO_PRI_MIN) nice = EIO_PRI_MIN; |
937 | if (nice > EIO_PRI_MAX) nice = EIO_PRI_MAX; |
1310 | if (nice > EIO_PRI_MAX) nice = EIO_PRI_MAX; |
938 | next_pri = nice + EIO_PRI_BIAS; |
1311 | next_pri = nice; |
939 | |
1312 | |
940 | void |
1313 | void |
941 | flush () |
1314 | flush () |
942 | PROTOTYPE: |
1315 | PROTOTYPE: |
943 | CODE: |
1316 | CODE: |
… | |
… | |
958 | |
1331 | |
959 | int |
1332 | int |
960 | poll_fileno() |
1333 | poll_fileno() |
961 | PROTOTYPE: |
1334 | PROTOTYPE: |
962 | CODE: |
1335 | CODE: |
963 | RETVAL = respipe [0]; |
1336 | RETVAL = s_epipe_fd (&respipe); |
964 | OUTPUT: |
1337 | OUTPUT: |
965 | RETVAL |
1338 | RETVAL |
966 | |
1339 | |
967 | int |
1340 | int |
968 | poll_cb(...) |
1341 | poll_cb(...) |
… | |
… | |
1004 | |
1377 | |
1005 | int |
1378 | int |
1006 | nthreads() |
1379 | nthreads() |
1007 | PROTOTYPE: |
1380 | PROTOTYPE: |
1008 | CODE: |
1381 | CODE: |
1009 | if (WORDACCESS_UNSAFE) X_LOCK (wrklock); |
1382 | RETVAL = eio_nthreads (); |
1010 | RETVAL = started; |
|
|
1011 | if (WORDACCESS_UNSAFE) X_UNLOCK (wrklock); |
|
|
1012 | OUTPUT: |
1383 | OUTPUT: |
1013 | RETVAL |
1384 | RETVAL |
1014 | |
1385 | |
|
|
1386 | int |
|
|
1387 | fadvise (aio_rfd fh, off_t offset, off_t length, IV advice) |
|
|
1388 | PROTOTYPE: $$$$ |
|
|
1389 | CODE: |
|
|
1390 | #if _XOPEN_SOURCE >= 600 && !NO_FADVISE |
|
|
1391 | RETVAL = posix_fadvise (fh, offset, length, advice); |
|
|
1392 | #else |
|
|
1393 | RETVAL = errno = ENOSYS; /* yes, this is actually correct */ |
|
|
1394 | #endif |
|
|
1395 | OUTPUT: |
|
|
1396 | RETVAL |
|
|
1397 | |
|
|
1398 | ssize_t |
|
|
1399 | sendfile (aio_wfd ofh, aio_rfd ifh, off_t offset, size_t count) |
|
|
1400 | PROTOTYPE: $$$$ |
|
|
1401 | CODE: |
|
|
1402 | RETVAL = eio_sendfile_sync (ofh, ifh, offset, count); |
|
|
1403 | OUTPUT: |
|
|
1404 | RETVAL |
|
|
1405 | |
|
|
1406 | void |
|
|
1407 | mmap (SV *scalar, size_t length, int prot, int flags, SV *fh, off_t offset = 0) |
|
|
1408 | PROTOTYPE: $$$$$;$ |
|
|
1409 | PPCODE: |
|
|
1410 | sv_unmagic (scalar, MMAP_MAGIC); |
|
|
1411 | { |
|
|
1412 | int fd = SvOK (fh) ? s_fileno_croak (fh, flags & PROT_WRITE) : -1; |
|
|
1413 | void *addr = (void *)mmap (0, length, prot, flags, fd, offset); |
|
|
1414 | if (addr == (void *)-1) |
|
|
1415 | XSRETURN_NO; |
|
|
1416 | |
|
|
1417 | sv_force_normal (scalar); |
|
|
1418 | |
|
|
1419 | /* we store the length in mg_obj, as namlen is I32 :/ */ |
|
|
1420 | sv_magicext (scalar, 0, MMAP_MAGIC, &mmap_vtbl, (char *)addr, 0) |
|
|
1421 | ->mg_obj = (SV *)length; |
|
|
1422 | |
|
|
1423 | SvUPGRADE (scalar, SVt_PV); /* nop... */ |
|
|
1424 | |
|
|
1425 | if (!(prot & PROT_WRITE)) |
|
|
1426 | SvREADONLY_on (scalar); |
|
|
1427 | |
|
|
1428 | if (SvLEN (scalar)) |
|
|
1429 | Safefree (SvPVX (scalar)); |
|
|
1430 | |
|
|
1431 | SvPVX (scalar) = (char *)addr; |
|
|
1432 | SvCUR_set (scalar, length); |
|
|
1433 | SvLEN_set (scalar, 0); |
|
|
1434 | SvPOK_only (scalar); |
|
|
1435 | |
|
|
1436 | XSRETURN_YES; |
|
|
1437 | } |
|
|
1438 | |
|
|
1439 | void |
|
|
1440 | munmap (SV *scalar) |
|
|
1441 | PROTOTYPE: $ |
|
|
1442 | CODE: |
|
|
1443 | sv_unmagic (scalar, MMAP_MAGIC); |
|
|
1444 | |
|
|
1445 | int |
|
|
1446 | madvise (SV *scalar, off_t offset, off_t length, IV advice) |
|
|
1447 | PROTOTYPE: $$$$ |
|
|
1448 | CODE: |
|
|
1449 | { |
|
|
1450 | char *addr = SvPV_nolen (scalar) + offset; |
|
|
1451 | |
|
|
1452 | if (!SvOK (ST (2))) |
|
|
1453 | length = SvCUR (scalar) - offset; |
|
|
1454 | |
|
|
1455 | if (addr >= SvEND (scalar) || length <= 0) |
|
|
1456 | XSRETURN_EMPTY; |
|
|
1457 | |
|
|
1458 | #if _XOPEN_SOURCE >= 600 && !NO_MADVISE |
|
|
1459 | RETVAL = posix_madvise (addr, length, advice); |
|
|
1460 | #else |
|
|
1461 | RETVAL = errno = ENOSYS; /* yes, this is actually correct */ |
|
|
1462 | #endif |
|
|
1463 | } |
|
|
1464 | OUTPUT: |
|
|
1465 | RETVAL |
|
|
1466 | |
|
|
1467 | int |
|
|
1468 | mlockall (int flags) |
|
|
1469 | PROTOTYPE: $ |
|
|
1470 | CODE: |
|
|
1471 | #if _POSIX_MEMLOCK |
|
|
1472 | #if __GLIBC__ == 2 && __GLIBC_MINOR__ <= 7 |
|
|
1473 | extern int mallopt (int, int); |
|
|
1474 | mallopt (-6, 238); /* http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=473812 */ |
|
|
1475 | #endif |
|
|
1476 | mlockall (flags); |
|
|
1477 | #else |
|
|
1478 | RETVAL = -1; |
|
|
1479 | errno = ENOSYS; |
|
|
1480 | #endif |
|
|
1481 | OUTPUT: |
|
|
1482 | RETVAL |
|
|
1483 | |
|
|
1484 | int |
|
|
1485 | munlockall () |
|
|
1486 | PROTOTYPE: |
|
|
1487 | CODE: |
|
|
1488 | #if _POSIX_MEMLOCK |
|
|
1489 | munlockall (); |
|
|
1490 | #else |
|
|
1491 | RETVAL = -1; |
|
|
1492 | errno = ENOSYS; |
|
|
1493 | #endif |
|
|
1494 | OUTPUT: |
|
|
1495 | RETVAL |
|
|
1496 | |
1015 | void _on_next_submit (SV *cb) |
1497 | void _on_next_submit (SV *cb) |
1016 | CODE: |
1498 | CODE: |
1017 | SvREFCNT_dec (on_next_submit); |
1499 | SvREFCNT_dec (on_next_submit); |
1018 | on_next_submit = SvOK (cb) ? newSVsv (cb) : 0; |
1500 | on_next_submit = SvOK (cb) ? newSVsv (cb) : 0; |
1019 | |
1501 | |
… | |
… | |
1026 | CODE: |
1508 | CODE: |
1027 | eio_cancel (req); |
1509 | eio_cancel (req); |
1028 | |
1510 | |
1029 | void |
1511 | void |
1030 | cb (aio_req_ornot req, SV *callback=&PL_sv_undef) |
1512 | cb (aio_req_ornot req, SV *callback=&PL_sv_undef) |
1031 | CODE: |
1513 | PPCODE: |
|
|
1514 | { |
|
|
1515 | if (GIMME_V != G_VOID) |
|
|
1516 | XPUSHs (req->callback ? sv_2mortal (newRV_inc (req->callback)) : &PL_sv_undef); |
|
|
1517 | |
|
|
1518 | if (items > 1) |
|
|
1519 | { |
|
|
1520 | SV *cb_cv =get_cb (callback); |
|
|
1521 | |
1032 | SvREFCNT_dec (req->callback); |
1522 | SvREFCNT_dec (req->callback); |
1033 | req->callback = newSVsv (callback); |
1523 | req->callback = SvREFCNT_inc (cb_cv); |
|
|
1524 | } |
|
|
1525 | } |
1034 | |
1526 | |
1035 | MODULE = IO::AIO PACKAGE = IO::AIO::GRP |
1527 | MODULE = IO::AIO PACKAGE = IO::AIO::GRP |
1036 | |
1528 | |
1037 | void |
1529 | void |
1038 | add (aio_req grp, ...) |
1530 | add (aio_req grp, ...) |
… | |
… | |
1070 | AV *av; |
1562 | AV *av; |
1071 | |
1563 | |
1072 | grp->errorno = errno; |
1564 | grp->errorno = errno; |
1073 | |
1565 | |
1074 | av = newAV (); |
1566 | av = newAV (); |
|
|
1567 | av_extend (av, items - 1); |
1075 | |
1568 | |
1076 | for (i = 1; i < items; ++i ) |
1569 | for (i = 1; i < items; ++i ) |
1077 | av_push (av, newSVsv (ST (i))); |
1570 | av_push (av, newSVsv (ST (i))); |
1078 | |
1571 | |
1079 | SvREFCNT_dec (grp->sv1); |
1572 | SvREFCNT_dec (grp->sv1); |
… | |
… | |
1093 | void |
1586 | void |
1094 | feed (aio_req grp, SV *callback=&PL_sv_undef) |
1587 | feed (aio_req grp, SV *callback=&PL_sv_undef) |
1095 | CODE: |
1588 | CODE: |
1096 | { |
1589 | { |
1097 | SvREFCNT_dec (grp->sv2); |
1590 | SvREFCNT_dec (grp->sv2); |
1098 | grp->sv2 = newSVsv (callback); |
1591 | grp->sv2 = newSVsv (callback); |
|
|
1592 | grp->feed = aio_grp_feed; |
1099 | |
1593 | |
1100 | if (grp->int2 <= 0) |
1594 | if (grp->int2 <= 0) |
1101 | grp->int2 = 2; |
1595 | grp->int2 = 2; |
1102 | |
1596 | |
1103 | eio_grp_limit (grp, grp->int2); |
1597 | eio_grp_limit (grp, grp->int2); |