… | |
… | |
311 | if (req->flags & FLAG_SV2_RO_OFF) |
311 | if (req->flags & FLAG_SV2_RO_OFF) |
312 | SvREADONLY_off (req->sv2); |
312 | SvREADONLY_off (req->sv2); |
313 | |
313 | |
314 | if (!EIO_CANCELLED (req) && req->callback) |
314 | if (!EIO_CANCELLED (req) && req->callback) |
315 | { |
315 | { |
|
|
316 | static SV *sv_result_cache; /* caches the result integer SV */ |
|
|
317 | SV *sv_result; |
|
|
318 | |
316 | ENTER; |
319 | ENTER; |
317 | SAVETMPS; |
320 | SAVETMPS; |
318 | PUSHMARK (SP); |
321 | PUSHMARK (SP); |
319 | EXTEND (SP, 1); |
322 | EXTEND (SP, 1); |
|
|
323 | |
|
|
324 | /* do not recreate the result IV from scratch each time */ |
|
|
325 | if (expect_true (sv_result_cache)) |
|
|
326 | { |
|
|
327 | sv_result = sv_result_cache; sv_result_cache = 0; |
|
|
328 | SvIV_set (sv_result, req->result); |
|
|
329 | } |
|
|
330 | else |
|
|
331 | { |
|
|
332 | sv_result = newSViv (req->result); |
|
|
333 | SvREADONLY_on (sv_result); |
|
|
334 | } |
320 | |
335 | |
321 | switch (req->type) |
336 | switch (req->type) |
322 | { |
337 | { |
323 | case EIO_READDIR: |
338 | case EIO_READDIR: |
324 | { |
339 | { |
… | |
… | |
469 | case EIO_LSTAT: |
484 | case EIO_LSTAT: |
470 | case EIO_FSTAT: |
485 | case EIO_FSTAT: |
471 | PL_laststype = req->type == EIO_LSTAT ? OP_LSTAT : OP_STAT; |
486 | PL_laststype = req->type == EIO_LSTAT ? OP_LSTAT : OP_STAT; |
472 | PL_laststatval = req->result; |
487 | PL_laststatval = req->result; |
473 | PL_statcache = *(EIO_STRUCT_STAT *)(req->ptr2); |
488 | PL_statcache = *(EIO_STRUCT_STAT *)(req->ptr2); |
474 | PUSHs (sv_2mortal (newSViv (req->result))); |
489 | PUSHs (sv_result); |
475 | break; |
490 | break; |
476 | |
491 | |
477 | case EIO_READ: |
492 | case EIO_READ: |
478 | { |
493 | { |
479 | SvCUR_set (req->sv2, req->stroffset + (req->result > 0 ? req->result : 0)); |
494 | SvCUR_set (req->sv2, req->stroffset + (req->result > 0 ? req->result : 0)); |
480 | *SvEND (req->sv2) = 0; |
495 | *SvEND (req->sv2) = 0; |
481 | SvPOK_only (req->sv2); |
496 | SvPOK_only (req->sv2); |
482 | SvSETMAGIC (req->sv2); |
497 | SvSETMAGIC (req->sv2); |
483 | PUSHs (sv_2mortal (newSViv (req->result))); |
498 | PUSHs (sv_result); |
484 | } |
499 | } |
485 | break; |
500 | break; |
486 | |
501 | |
487 | case EIO_DUP2: |
502 | case EIO_DUP2: |
488 | if (req->result > 0) |
503 | if (req->result > 0) |
489 | req->result = 0; |
504 | SvIV_set (sv_result, 0); |
490 | /* FALLTHROUGH */ |
505 | /* FALLTHROUGH */ |
491 | |
506 | |
492 | default: |
507 | default: |
493 | PUSHs (sv_2mortal (newSViv (req->result))); |
508 | PUSHs (sv_result); |
494 | break; |
509 | break; |
495 | } |
510 | } |
496 | |
511 | |
497 | errno = req->errorno; |
512 | errno = req->errorno; |
498 | |
513 | |
499 | PUTBACK; |
514 | PUTBACK; |
500 | call_sv (req->callback, G_VOID | G_EVAL | G_DISCARD); |
515 | call_sv (req->callback, G_VOID | G_EVAL | G_DISCARD); |
501 | SPAGAIN; |
516 | SPAGAIN; |
|
|
517 | |
|
|
518 | if (expect_false (SvREFCNT (sv_result) != 1 || sv_result_cache)) |
|
|
519 | SvREFCNT_dec (sv_result); |
|
|
520 | else |
|
|
521 | sv_result_cache = sv_result; |
502 | |
522 | |
503 | FREETMPS; |
523 | FREETMPS; |
504 | LEAVE; |
524 | LEAVE; |
505 | |
525 | |
506 | PUTBACK; |
526 | PUTBACK; |