Skip to content

Commit

Permalink
another crack at the refcount
Browse files Browse the repository at this point in the history
  • Loading branch information
FGasper committed Mar 13, 2023
1 parent c7b99c8 commit 1cfe339
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion XS.xs
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,17 @@ void xspr_promise_finish(pTHX_ xspr_promise_t* promise, xspr_result_t* result)
}

if (promise->self_sv_ref != NULL) {
SvREFCNT_dec(SvRV(promise->self_sv_ref));

// After we set self_sv_ref, Future::AsyncAwait manipulates
// things a bit such that WEAKREF is set on the reference and
// the referent’s refcount is decremented. Thus, we can forgo
// the reference-count decrement here. We still check for the
// WEAKREF flag, though, just in case something changed.
//
if (!SvWEAKREF(promise->self_sv_ref)) {
SvREFCNT_dec(SvRV(promise->self_sv_ref));
}

SvREFCNT_dec(promise->self_sv_ref);
promise->self_sv_ref = NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Promise/XS.pm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use warnings;
our $VERSION;

BEGIN {
$VERSION = '0.18_90';
$VERSION = '0.18_91';
}

=encoding utf-8
Expand Down

0 comments on commit 1cfe339

Please sign in to comment.