From: Gurusamy Sarathy Date: Sun, 28 Mar 1999 03:37:23 +0000 (+0000) Subject: integrate change#3179 from maint-5.005 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c4e7bd8d7008b59d7502296f4da5ed2d4592e5f9;p=p5sagit%2Fp5-mst-13.2.git integrate change#3179 from maint-5.005 p4raw-link: @3179 on //depot/maint-5.005/perl: 3c798f74a641ef1819699fe5d5c156d30ad033bc p4raw-id: //depot/perl@3181 p4raw-integrated: from //depot/maint-5.005/perl@3180 'merge in' t/lib/thread.t (@1649..) ext/Thread/Thread.xs (@2543..) --- diff --git a/ext/Thread/Thread.xs b/ext/Thread/Thread.xs index 543ecf0..c3b4683 100644 --- a/ext/Thread/Thread.xs +++ b/ext/Thread/Thread.xs @@ -238,6 +238,11 @@ newthread (SV *startsv, AV *initargs, char *classname) savethread = thr; thr = new_struct_thread(thr); + /* temporarily pretend to be the child thread in case the + * XPUSHs() below want to grow the child's stack. This is + * safe, since the other thread is not yet created, and we + * are the only ones who know about it */ + SET_THR(thr); SPAGAIN; DEBUG_S(PerlIO_printf(PerlIO_stderr(), "%p: newthread (%p), tid is %u, preparing stack\n", @@ -251,6 +256,7 @@ newthread (SV *startsv, AV *initargs, char *classname) PUTBACK; /* On your marks... */ + SET_THR(savethread); MUTEX_LOCK(&thr->mutex); #ifdef THREAD_CREATE diff --git a/t/lib/thread.t b/t/lib/thread.t index 61997cf..5cc2eaf 100755 --- a/t/lib/thread.t +++ b/t/lib/thread.t @@ -24,7 +24,7 @@ sub content } # create a thread passing args and immedaietly wait for it. -my $t = new Thread \&content,("ok 2\n","ok 3\n"); +my $t = new Thread \&content,("ok 2\n","ok 3\n", 1..1000); print $t->join; # check that lock works ...