diff options
-rw-r--r-- | mg.c | 1 | ||||
-rw-r--r-- | op.c | 2 | ||||
-rw-r--r-- | opcode.h | 2 | ||||
-rwxr-xr-x | opcode.pl | 2 | ||||
-rw-r--r-- | pp.c | 9 | ||||
-rw-r--r-- | pp_hot.c | 1 |
6 files changed, 13 insertions, 4 deletions
@@ -1723,6 +1723,7 @@ MAGIC *mg; croak("panic: magic_mutexfree"); MUTEX_DESTROY(MgMUTEXP(mg)); COND_DESTROY(MgCONDP(mg)); + SvREFCNT_dec(sv); return 0; } #endif /* USE_THREADS */ @@ -1288,7 +1288,7 @@ I32 type; switch (o->op_type) { case OP_ENTERSUB: - if ((type == OP_DEFINED) && + if ((type == OP_DEFINED || type == OP_LOCK) && !(o->op_flags & OPf_STACKED)) { o->op_type = OP_RV2CV; /* entersub => rv2cv */ o->op_ppaddr = ppaddr[OP_RV2CV]; @@ -2137,7 +2137,7 @@ EXT OP * (*check[]) _((OP *op)) = { ck_null, /* egrent */ ck_null, /* getlogin */ ck_fun, /* syscall */ - ck_null, /* lock */ + ck_rfun, /* lock */ }; #endif @@ -654,4 +654,4 @@ getlogin getlogin ck_null st syscall syscall ck_fun imst S L # For multi-threading -lock lock ck_null s S +lock lock ck_rfun s S @@ -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; } @@ -1866,6 +1866,7 @@ PP(pp_entersub) DEBUG_L(PerlIO_printf(PerlIO_stderr(), "%p: pp_entersub lock %p\n", thr, sv);) MUTEX_UNLOCK(MgMUTEXP(mg)); + SvREFCNT_inc(sv); /* Keep alive until magic_mutexfree */ save_destructor(unlock_condpair, sv); } MUTEX_LOCK(CvMUTEXP(cv)); |