From: Artur Bergman Date: Thu, 25 Oct 2001 10:18:23 +0000 (+0000) Subject: Fix threadcounts for arrays and hashes. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=866fba466aecf19a94010075e4c72ab79c952441;p=p5sagit%2Fp5-mst-13.2.git Fix threadcounts for arrays and hashes. p4raw-id: //depot/perl@12640 --- diff --git a/ext/threads/shared/shared.pm b/ext/threads/shared/shared.pm index 3fec356..d928d26 100644 --- a/ext/threads/shared/shared.pm +++ b/ext/threads/shared/shared.pm @@ -63,6 +63,7 @@ sub CLONE { sub DESTROY { my $self = shift; + _thrcnt_dec($$self); delete($shared{$$self}); } diff --git a/ext/threads/shared/shared.xs b/ext/threads/shared/shared.xs index bbc6e6e..e2187d7 100644 --- a/ext/threads/shared/shared.xs +++ b/ext/threads/shared/shared.xs @@ -99,7 +99,10 @@ SV* _thrcnt(ref) SV* ref CODE: - shared_sv* shared = Perl_sharedsv_find(aTHX, ref); + shared_sv* shared; + if(SvROK(ref)) + ref = SvRV(ref); + shared = Perl_sharedsv_find(aTHX, ref); if(!shared) croak("thrcnt can only be used on shared values"); SHAREDSvLOCK(shared); @@ -121,6 +124,15 @@ thrcnt_inc(ref) croak("thrcnt can only be used on shared values"); Perl_sharedsv_thrcnt_inc(aTHX_ shared); +void +_thrcnt_dec(ref) + SV* ref + CODE: + shared_sv* shared = (shared_sv*) SvIV(ref); + if(!shared) + croak("thrcnt can only be used on shared values"); + Perl_sharedsv_thrcnt_dec(aTHX_ shared); + MODULE = threads::shared PACKAGE = threads::shared::sv