… | |
… | |
304 | } |
304 | } |
305 | } |
305 | } |
306 | |
306 | |
307 | static int req_invoke (eio_req *req) |
307 | static int req_invoke (eio_req *req) |
308 | { |
308 | { |
309 | dSP; |
|
|
310 | |
|
|
311 | if (req->flags & FLAG_SV2_RO_OFF) |
309 | if (req->flags & FLAG_SV2_RO_OFF) |
312 | SvREADONLY_off (req->sv2); |
310 | SvREADONLY_off (req->sv2); |
313 | |
311 | |
314 | if (!EIO_CANCELLED (req) && req->callback) |
312 | if (!EIO_CANCELLED (req) && req->callback) |
315 | { |
313 | { |
|
|
314 | dSP; |
316 | static SV *sv_result_cache; /* caches the result integer SV */ |
315 | static SV *sv_result_cache; /* caches the result integer SV */ |
317 | SV *sv_result; |
316 | SV *sv_result; |
318 | |
317 | |
319 | ENTER; |
318 | ENTER; |
320 | SAVETMPS; |
319 | SAVETMPS; |
… | |
… | |
497 | SvSETMAGIC (req->sv2); |
496 | SvSETMAGIC (req->sv2); |
498 | PUSHs (sv_result); |
497 | PUSHs (sv_result); |
499 | } |
498 | } |
500 | break; |
499 | break; |
501 | |
500 | |
502 | case EIO_DUP2: |
501 | case EIO_DUP2: /* EIO_DUP2 actually means aio_close(), su fudge result value */ |
503 | if (req->result > 0) |
502 | if (req->result > 0) |
504 | SvIV_set (sv_result, 0); |
503 | SvIV_set (sv_result, 0); |
505 | /* FALLTHROUGH */ |
504 | /* FALLTHROUGH */ |
506 | |
505 | |
507 | default: |
506 | default: |
… | |
… | |
621 | errno = old_errno; |
620 | errno = old_errno; |
622 | |
621 | |
623 | mg->mg_obj = 0; /* just in case */ |
622 | mg->mg_obj = 0; /* just in case */ |
624 | |
623 | |
625 | SvREADONLY_off (sv); |
624 | SvREADONLY_off (sv); |
|
|
625 | |
|
|
626 | if (SvPVX (sv) != mg->mg_ptr) |
|
|
627 | croak ("ERROR: IO::AIO::mmap-mapped scalar changed location, detected"); |
|
|
628 | |
626 | SvCUR_set (sv, 0); |
629 | SvCUR_set (sv, 0); |
627 | SvLEN_set (sv, 0); |
|
|
628 | SvPVX (sv) = 0; |
630 | SvPVX (sv) = 0; |
629 | SvOK_off (sv); |
631 | SvOK_off (sv); |
630 | |
632 | |
631 | return 0; |
633 | return 0; |
632 | } |
634 | } |
… | |
… | |
1387 | int fd = SvOK (fh) ? s_fileno_croak (fh, flags & PROT_WRITE) : -1; |
1389 | int fd = SvOK (fh) ? s_fileno_croak (fh, flags & PROT_WRITE) : -1; |
1388 | void *addr = (void *)mmap (0, length, prot, flags, fd, offset); |
1390 | void *addr = (void *)mmap (0, length, prot, flags, fd, offset); |
1389 | if (addr == (void *)-1) |
1391 | if (addr == (void *)-1) |
1390 | XSRETURN_NO; |
1392 | XSRETURN_NO; |
1391 | |
1393 | |
|
|
1394 | sv_force_normal (scalar); |
|
|
1395 | |
1392 | /* we store the length in mg_obj, as namlen is I32 :/ */ |
1396 | /* we store the length in mg_obj, as namlen is I32 :/ */ |
1393 | sv_magicext (scalar, 0, MMAP_MAGIC, &mmap_vtbl, (char *)addr, 0) |
1397 | sv_magicext (scalar, 0, MMAP_MAGIC, &mmap_vtbl, (char *)addr, 0) |
1394 | ->mg_obj = (SV *)length; |
1398 | ->mg_obj = (SV *)length; |
1395 | |
1399 | |
1396 | SvUPGRADE (scalar, SVt_PV); /* nop... */ |
1400 | SvUPGRADE (scalar, SVt_PV); /* nop... */ |
|
|
1401 | |
1397 | if (!(prot & PROT_WRITE)) |
1402 | if (!(prot & PROT_WRITE)) |
1398 | SvREADONLY_on (scalar); |
1403 | SvREADONLY_on (scalar); |
|
|
1404 | |
|
|
1405 | if (SvLEN (scalar)) |
|
|
1406 | Safefree (SvPVX (scalar)); |
1399 | |
1407 | |
1400 | SvPVX (scalar) = (char *)addr; |
1408 | SvPVX (scalar) = (char *)addr; |
1401 | SvCUR_set (scalar, length); |
1409 | SvCUR_set (scalar, length); |
1402 | SvLEN_set (scalar, 0); |
1410 | SvLEN_set (scalar, 0); |
1403 | SvPOK_only (scalar); |
1411 | SvPOK_only (scalar); |