summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorArtur Bergman <sky@nanisky.com>2001-10-29 12:56:12 +0000
committerArtur Bergman <sky@nanisky.com>2001-10-29 12:56:12 +0000
commitcd8c9bf8e75f7ca1681db747e53988762aec8fa2 (patch)
tree57f8b8fe6c9943d77e6b552afe52ae1d052f1253 /ext
parent84414e3e2022eb9024bf2a18e78e66ce71d289e0 (diff)
downloadperl-cd8c9bf8e75f7ca1681db747e53988762aec8fa2.tar.gz
Ugly fix to not die when a thread creator is holding locks.
p4raw-id: //depot/perl@12755
Diffstat (limited to 'ext')
-rw-r--r--ext/threads/shared/shared.pm2
-rw-r--r--ext/threads/shared/shared.xs7
-rwxr-xr-xext/threads/threads.xs7
3 files changed, 14 insertions, 2 deletions
diff --git a/ext/threads/shared/shared.pm b/ext/threads/shared/shared.pm
index 5607186db3..10d2af9df8 100644
--- a/ext/threads/shared/shared.pm
+++ b/ext/threads/shared/shared.pm
@@ -59,7 +59,7 @@ sub CLONE {
return unless($_[0] eq "threads::shared");
foreach my $ptr (keys %shared) {
if($ptr) {
- thrcnt_inc($shared{$ptr});
+ thrcnt_inc($shared{$ptr},$threads::origthread);
}
}
}
diff --git a/ext/threads/shared/shared.xs b/ext/threads/shared/shared.xs
index c00cf15489..2eb2e6cb5d 100644
--- a/ext/threads/shared/shared.xs
+++ b/ext/threads/shared/shared.xs
@@ -171,16 +171,21 @@ _thrcnt(ref)
void
-thrcnt_inc(ref)
+thrcnt_inc(ref,perl)
SV* ref
+ SV* perl
CODE:
shared_sv* shared;
+ PerlInterpreter* origperl = (PerlInterpreter*) SvIV(perl);
+ PerlInterpreter* oldperl = PERL_GET_CONTEXT;
if(SvROK(ref))
ref = SvRV(ref);
shared = Perl_sharedsv_find(aTHX, ref);
if(!shared)
croak("thrcnt can only be used on shared values");
+ PERL_SET_CONTEXT(origperl);
Perl_sharedsv_thrcnt_inc(aTHX_ shared);
+ PERL_SET_CONTEXT(oldperl);
void
_thrcnt_dec(ref)
diff --git a/ext/threads/threads.xs b/ext/threads/threads.xs
index a4e22ec966..75a6b0b68f 100755
--- a/ext/threads/threads.xs
+++ b/ext/threads/threads.xs
@@ -111,6 +111,11 @@ SV* Perl_thread_create(char* class, SV* init_function, SV* params) {
init_function = NULL;
temp_store = NULL;
+ temp_store = Perl_get_sv(current_perl, "threads::origthread", TRUE | GV_ADDMULTI);
+ sv_setiv(temp_store,(IV)current_perl);
+ temp_store = NULL;
+
+
#ifdef WIN32
thread->interp = perl_clone(current_perl, 4);
#else
@@ -122,6 +127,8 @@ SV* Perl_thread_create(char* class, SV* init_function, SV* params) {
thread->params = newSVsv(Perl_get_sv(thread->interp,
"threads::paramtempstore",FALSE));
+
+
/*
* And here we make sure we clean up the data we put in the
* namespace of iThread, both in the new and the calling