diff options
author | Steffen Mueller <smueller@cpan.org> | 2010-04-15 15:24:57 +0200 |
---|---|---|
committer | Steffen Mueller <smueller@cpan.org> | 2010-04-15 16:36:07 +0200 |
commit | 1a3f0f1d129333944296d9bd29d1641e7de1a13e (patch) | |
tree | e4953a3db87c102ae18b0fe6331a59b5f05e3dd7 /dist/threads-shared | |
parent | b91a79b929f6eca75f18124340d2f0f89b9588a9 (diff) | |
download | perl-1a3f0f1d129333944296d9bd29d1641e7de1a13e.tar.gz |
Upgrade to threads-shared-1.33
Diffstat (limited to 'dist/threads-shared')
-rw-r--r-- | dist/threads-shared/shared.pm | 9 | ||||
-rw-r--r-- | dist/threads-shared/shared.xs | 45 |
2 files changed, 32 insertions, 22 deletions
diff --git a/dist/threads-shared/shared.pm b/dist/threads-shared/shared.pm index 72192bc7a0..15e7a021be 100644 --- a/dist/threads-shared/shared.pm +++ b/dist/threads-shared/shared.pm @@ -7,7 +7,7 @@ use warnings; use Scalar::Util qw(reftype refaddr blessed); -our $VERSION = '1.32'; +our $VERSION = '1.33'; my $XS_VERSION = $VERSION; $VERSION = eval $VERSION; @@ -187,7 +187,7 @@ threads::shared - Perl extension for sharing data structures between threads =head1 VERSION -This document describes threads::shared version 1.32 +This document describes threads::shared version 1.33 =head1 SYNOPSIS @@ -527,7 +527,8 @@ that the contents of hash-based objects will be lost due to the above mentioned limitation. See F<examples/class.pl> (in the CPAN distribution of this module) for how to create a class that supports object sharing. -Does not support C<splice> on arrays! +Does not support C<splice> on arrays. Does not support explicitly changing +array lengths via $#array -- use C<push> and C<pop> instead. Taking references to the elements of shared arrays and hashes does not autovivify the elements, and neither does slicing a shared array/hash over @@ -588,7 +589,7 @@ L<threads::shared> Discussion Forum on CPAN: L<http://www.cpanforum.com/dist/threads-shared> Annotated POD for L<threads::shared>: -L<http://annocpan.org/~JDHEDDEN/threads-shared-1.32/shared.pm> +L<http://annocpan.org/~JDHEDDEN/threads-shared-1.33/shared.pm> Source repository: L<http://code.google.com/p/threads-shared/> diff --git a/dist/threads-shared/shared.xs b/dist/threads-shared/shared.xs index 7c9526e2bb..a1c6925f29 100644 --- a/dist/threads-shared/shared.xs +++ b/dist/threads-shared/shared.xs @@ -864,29 +864,32 @@ sharedsv_elem_mg_FETCH(pTHX_ SV *sv, MAGIC *mg) { dTHXc; SV *saggregate = S_sharedsv_from_obj(aTHX_ mg->mg_obj); - SV** svp; + SV** svp = NULL; ENTER_LOCK; - if (SvTYPE(saggregate) == SVt_PVAV) { - assert ( mg->mg_ptr == 0 ); - SHARED_CONTEXT; - svp = av_fetch((AV*) saggregate, mg->mg_len, 0); - } else { - char *key = mg->mg_ptr; - I32 len = mg->mg_len; - assert ( mg->mg_ptr != 0 ); - if (mg->mg_len == HEf_SVKEY) { - STRLEN slen; - key = SvPV((SV *)mg->mg_ptr, slen); - len = slen; - if (SvUTF8((SV *)mg->mg_ptr)) { - len = -len; + if (saggregate) { /* During global destruction, underlying + aggregate may no longer exist */ + if (SvTYPE(saggregate) == SVt_PVAV) { + assert ( mg->mg_ptr == 0 ); + SHARED_CONTEXT; + svp = av_fetch((AV*) saggregate, mg->mg_len, 0); + } else { + char *key = mg->mg_ptr; + I32 len = mg->mg_len; + assert ( mg->mg_ptr != 0 ); + if (mg->mg_len == HEf_SVKEY) { + STRLEN slen; + key = SvPV((SV *)mg->mg_ptr, slen); + len = slen; + if (SvUTF8((SV *)mg->mg_ptr)) { + len = -len; + } } + SHARED_CONTEXT; + svp = hv_fetch((HV*) saggregate, key, len, 0); } - SHARED_CONTEXT; - svp = hv_fetch((HV*) saggregate, key, len, 0); + CALLER_CONTEXT; } - CALLER_CONTEXT; if (svp) { /* Exists in the array */ if (SvROK(*svp)) { @@ -957,6 +960,12 @@ sharedsv_elem_mg_DELETE(pTHX_ SV *sv, MAGIC *mg) dTHXc; MAGIC *shmg; SV *saggregate = S_sharedsv_from_obj(aTHX_ mg->mg_obj); + + /* Object may not exist during global destruction */ + if (! saggregate) { + return (0); + } + ENTER_LOCK; sharedsv_elem_mg_FETCH(aTHX_ sv, mg); if ((shmg = mg_find(sv, PERL_MAGIC_shared_scalar))) |