summaryrefslogtreecommitdiff
path: root/pp.c
diff options
context:
space:
mode:
authorMalcolm Beattie <mbeattie@sable.ox.ac.uk>1997-10-23 09:22:40 +0000
committerMalcolm Beattie <mbeattie@sable.ox.ac.uk>1997-10-23 09:22:40 +0000
commite55aaa0ea8ae9df2251fb793d58ce52f2d4ed736 (patch)
tree3ebcd6bf8d63887173e00a8588bb2eb51e1c07d3 /pp.c
parentf81e73367db8ca5c7f6b9b2cd46247cf88cf9e89 (diff)
downloadperl-e55aaa0ea8ae9df2251fb793d58ce52f2d4ed736.tar.gz
Fix refcounts for lock/magic_mutexfree. Make OP_LOCK auto-ref
its argument using ck_rfun as OP_DEFINED. Make pp_lock return a ref to its argument for AV, HV, CV. p4raw-id: //depot/perl@170
Diffstat (limited to 'pp.c')
-rw-r--r--pp.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/pp.c b/pp.c
index d002a1f0c5..649506fa89 100644
--- a/pp.c
+++ b/pp.c
@@ -4266,8 +4266,9 @@ void *svv;
PP(pp_lock)
{
dSP;
-#ifdef USE_THREADS
dTOPss;
+ SV *retsv = sv;
+#ifdef USE_THREADS
MAGIC *mg;
if (SvROK(sv))
@@ -4284,8 +4285,14 @@ PP(pp_lock)
DEBUG_L(PerlIO_printf(PerlIO_stderr(), "0x%lx: pp_lock lock 0x%lx\n",
(unsigned long)thr, (unsigned long)sv);)
MUTEX_UNLOCK(MgMUTEXP(mg));
+ SvREFCNT_inc(sv); /* keep alive until magic_mutexfree */
save_destructor(unlock_condpair, sv);
}
#endif /* USE_THREADS */
+ if (SvTYPE(retsv) == SVt_PVAV || SvTYPE(retsv) == SVt_PVHV
+ || SvTYPE(retsv) == SVt_PVCV) {
+ retsv = refto(retsv);
+ }
+ SETs(retsv);
RETURN;
}