… | |
… | |
1859 | |
1859 | |
1860 | static int ecb_cold |
1860 | static int ecb_cold |
1861 | coro_state_dup (pTHX_ MAGIC *mg, CLONE_PARAMS *params) |
1861 | coro_state_dup (pTHX_ MAGIC *mg, CLONE_PARAMS *params) |
1862 | { |
1862 | { |
1863 | /* called when perl clones the current process the slow way (windows process emulation) */ |
1863 | /* called when perl clones the current process the slow way (windows process emulation) */ |
1864 | /* WE SIMply nuke the pointers in the copy, causing perl to croak */ |
1864 | /* we simply nuke the pointers in the copy, causing perl to croak */ |
1865 | mg->mg_ptr = 0; |
1865 | mg->mg_ptr = 0; |
1866 | mg->mg_virtual = 0; |
1866 | mg->mg_virtual = 0; |
1867 | |
1867 | |
1868 | return 0; |
1868 | return 0; |
1869 | } |
1869 | } |
… | |
… | |
2481 | |
2481 | |
2482 | if (ecb_expect_false (coro->cctx) && ecb_expect_false (coro->cctx->flags & CC_TRACE)) |
2482 | if (ecb_expect_false (coro->cctx) && ecb_expect_false (coro->cctx->flags & CC_TRACE)) |
2483 | api_trace (aTHX_ coro_current, 0); |
2483 | api_trace (aTHX_ coro_current, 0); |
2484 | |
2484 | |
2485 | frame->prepare = prepare_schedule; |
2485 | frame->prepare = prepare_schedule; |
2486 | av_push (av_async_pool, SvREFCNT_inc (hv)); |
2486 | av_push (av_async_pool, SvREFCNT_inc_NN (hv)); |
2487 | } |
2487 | } |
2488 | } |
2488 | } |
2489 | else |
2489 | else |
2490 | { |
2490 | { |
2491 | /* first iteration, simply fall through */ |
2491 | /* first iteration, simply fall through */ |
… | |
… | |
2505 | coro_rouse_callback (pTHX_ CV *cv) |
2505 | coro_rouse_callback (pTHX_ CV *cv) |
2506 | { |
2506 | { |
2507 | dXSARGS; |
2507 | dXSARGS; |
2508 | SV *data = (SV *)S_GENSUB_ARG; |
2508 | SV *data = (SV *)S_GENSUB_ARG; |
2509 | |
2509 | |
|
|
2510 | /* data starts being the coro, and is replaced by the results when done */ |
2510 | if (SvTYPE (SvRV (data)) != SVt_PVAV) |
2511 | if (SvTYPE (SvRV (data)) != SVt_PVAV) |
2511 | { |
2512 | { |
2512 | /* first call, set args */ |
2513 | /* first call, set args */ |
2513 | SV *coro = SvRV (data); |
2514 | SV *coro = SvRV (data); |
2514 | AV *av = newAV (); |
2515 | AV *av = newAV (); |
… | |
… | |
2518 | /* better take a full copy of the arguments */ |
2519 | /* better take a full copy of the arguments */ |
2519 | while (items--) |
2520 | while (items--) |
2520 | av_store (av, items, newSVsv (ST (items))); |
2521 | av_store (av, items, newSVsv (ST (items))); |
2521 | |
2522 | |
2522 | api_ready (aTHX_ coro); |
2523 | api_ready (aTHX_ coro); |
2523 | SvREFCNT_dec (coro); |
2524 | SvREFCNT_dec_NN (coro); |
2524 | } |
2525 | } |
2525 | |
2526 | |
2526 | XSRETURN_EMPTY; |
2527 | XSRETURN_EMPTY; |
2527 | } |
2528 | } |
2528 | |
2529 | |
… | |
… | |
2597 | struct coro *coro = SvSTATE_hv (hv); |
2598 | struct coro *coro = SvSTATE_hv (hv); |
2598 | SV *data = newRV_inc ((SV *)hv); |
2599 | SV *data = newRV_inc ((SV *)hv); |
2599 | SV *cb = s_gensub (aTHX_ coro_rouse_callback, (void *)data); |
2600 | SV *cb = s_gensub (aTHX_ coro_rouse_callback, (void *)data); |
2600 | |
2601 | |
2601 | sv_magicext (SvRV (cb), data, CORO_MAGIC_type_rouse, 0, 0, 0); |
2602 | sv_magicext (SvRV (cb), data, CORO_MAGIC_type_rouse, 0, 0, 0); |
2602 | SvREFCNT_dec (data); /* magicext increases the refcount */ |
2603 | SvREFCNT_dec_NN (data); /* magicext increases the refcount */ |
2603 | |
2604 | |
2604 | SvREFCNT_dec (coro->rouse_cb); |
2605 | SvREFCNT_dec (coro->rouse_cb); |
2605 | coro->rouse_cb = SvREFCNT_inc_NN (cb); |
2606 | coro->rouse_cb = SvREFCNT_inc_NN (cb); |
2606 | |
2607 | |
2607 | return cb; |
2608 | return cb; |