develooper Front page | perl.perl5.porters | Postings from July 2001

Re: [patch] pthread_atfork bandaid

Thread Previous | Thread Next
From:
Jarkko Hietaniemi
Date:
July 11, 2001 22:19
Subject:
Re: [patch] pthread_atfork bandaid
Message ID:
20010712001922.Q10225@chaos.wustl.edu
On Wed, Jul 11, 2001 at 08:59:12AM -0700, Doug MacEachern wrote:
> current bleedperl is totally unusable with modperl-2.0 since
> PTHREAD_ATFORK causes the server to deadlock.  until the right solution is
> determined, this patch will cure the problem for modperl by moving the
> PTHREAD_ATFORK call to perlmain.c

I had to patch as follows before I even got a compile.
After this it builds and tests 100% for me under ithreads?

Change 11289 by jhi@alpha on 2001/07/12 04:16:41

	Needed for #11281.

Affected files ...

... //depot/perl/embed.h#273 edit
... //depot/perl/embed.pl#257 edit
... //depot/perl/perl.c#346 edit
... //depot/perl/proto.h#318 edit
... //depot/perl/thread.h#74 edit

Differences ...

==== //depot/perl/embed.h#273 (text+w) ====
Index: perl/embed.h
--- perl/embed.h.~1~	Thu Jul 12 08:18:31 2001
+++ perl/embed.h	Thu Jul 12 08:18:31 2001
@@ -73,6 +73,8 @@
 #define append_list		Perl_append_list
 #define apply			Perl_apply
 #define apply_attrs_string	Perl_apply_attrs_string
+#define atfork_lock		Perl_atfork_lock
+#define atfork_unlock		Perl_atfork_unlock
 #define avhv_delete_ent		Perl_avhv_delete_ent
 #define avhv_exists_ent		Perl_avhv_exists_ent
 #define avhv_fetch_ent		Perl_avhv_fetch_ent
@@ -1604,6 +1606,8 @@
 #define append_list(a,b,c)	Perl_append_list(aTHX_ a,b,c)
 #define apply(a,b,c)		Perl_apply(aTHX_ a,b,c)
 #define apply_attrs_string(a,b,c,d)	Perl_apply_attrs_string(aTHX_ a,b,c,d)
+#define atfork_lock(a)		Perl_atfork_lock(aTHX_ a)
+#define atfork_unlock(a)	Perl_atfork_unlock(aTHX_ a)
 #define avhv_delete_ent(a,b,c,d)	Perl_avhv_delete_ent(aTHX_ a,b,c,d)
 #define avhv_exists_ent(a,b,c)	Perl_avhv_exists_ent(aTHX_ a,b,c)
 #define avhv_fetch_ent(a,b,c,d)	Perl_avhv_fetch_ent(aTHX_ a,b,c,d)
@@ -3116,6 +3120,10 @@
 #define apply			Perl_apply
 #define Perl_apply_attrs_string	CPerlObj::Perl_apply_attrs_string
 #define apply_attrs_string	Perl_apply_attrs_string
+#define Perl_atfork_lock	CPerlObj::Perl_atfork_lock
+#define atfork_lock		Perl_atfork_lock
+#define Perl_atfork_unlock	CPerlObj::Perl_atfork_unlock
+#define atfork_unlock		Perl_atfork_unlock
 #define Perl_avhv_delete_ent	CPerlObj::Perl_avhv_delete_ent
 #define avhv_delete_ent		Perl_avhv_delete_ent
 #define Perl_avhv_exists_ent	CPerlObj::Perl_avhv_exists_ent

==== //depot/perl/embed.pl#257 (xtext) ====
Index: perl/embed.pl
--- perl/embed.pl.~1~	Thu Jul 12 08:18:31 2001
+++ perl/embed.pl	Thu Jul 12 08:18:31 2001
@@ -1399,6 +1399,8 @@
 p	|OP*	|append_list	|I32 optype|LISTOP* first|LISTOP* last
 p	|I32	|apply		|I32 type|SV** mark|SV** sp
 Ap	|void	|apply_attrs_string|char *stashpv|CV *cv|char *attrstr|STRLEN len
+p	|void	|atfork_lock
+p	|void	|atfork_unlock
 Ap	|SV*	|avhv_delete_ent|AV *ar|SV* keysv|I32 flags|U32 hash
 Ap	|bool	|avhv_exists_ent|AV *ar|SV* keysv|U32 hash
 Ap	|SV**	|avhv_fetch_ent	|AV *ar|SV* keysv|I32 lval|U32 hash

==== //depot/perl/perl.c#346 (text) ====
Index: perl/perl.c
--- perl/perl.c.~1~	Thu Jul 12 08:18:31 2001
+++ perl/perl.c	Thu Jul 12 08:18:31 2001
@@ -61,7 +61,7 @@
 
 /* this is called in parent before the fork() */
 void
-Perl_atfork_lock(void)
+Perl_atfork_lock(pTHX)
 {
     /* locks must be held in locking order (if any) */
 #ifdef MYMALLOC
@@ -72,7 +72,7 @@
 
 /* this is called in both parent and child after the fork() */
 void
-Perl_atfork_unlock(void)
+Perl_atfork_unlock(pTHX)
 {
     /* locks must be released in same order as in S_atfork_lock() */
 #ifdef MYMALLOC

==== //depot/perl/proto.h#318 (text+w) ====
Index: perl/proto.h
--- perl/proto.h.~1~	Thu Jul 12 08:18:31 2001
+++ perl/proto.h	Thu Jul 12 08:18:31 2001
@@ -63,6 +63,8 @@
 PERL_CALLCONV OP*	Perl_append_list(pTHX_ I32 optype, LISTOP* first, LISTOP* last);
 PERL_CALLCONV I32	Perl_apply(pTHX_ I32 type, SV** mark, SV** sp);
 PERL_CALLCONV void	Perl_apply_attrs_string(pTHX_ char *stashpv, CV *cv, char *attrstr, STRLEN len);
+PERL_CALLCONV void	Perl_atfork_lock(pTHX_ void);
+PERL_CALLCONV void	Perl_atfork_unlock(pTHX_ void);
 PERL_CALLCONV SV*	Perl_avhv_delete_ent(pTHX_ AV *ar, SV* keysv, I32 flags, U32 hash);
 PERL_CALLCONV bool	Perl_avhv_exists_ent(pTHX_ AV *ar, SV* keysv, U32 hash);
 PERL_CALLCONV SV**	Perl_avhv_fetch_ent(pTHX_ AV *ar, SV* keysv, I32 lval, U32 hash);

==== //depot/perl/thread.h#74 (text) ====
Index: perl/thread.h
--- perl/thread.h.~1~	Thu Jul 12 08:18:31 2001
+++ perl/thread.h	Thu Jul 12 08:18:31 2001
@@ -303,8 +303,11 @@
 #endif
 
 #ifndef PTHREAD_ATFORK
+typedef void(*Perl_pthread_atfork_t)(void);
 #  define PTHREAD_ATFORK(prepare,parent,child)			\
-    pthread_atfork(prepare,parent,child)
+    pthread_atfork((Perl_pthread_atfork_t)prepare,\
+	           (Perl_pthread_atfork_t)parent,\
+                   (Perl_pthread_atfork_t)child)
 #endif
 
 #ifndef THREAD_RET_TYPE
End of Patch.

-- 
$jhi++; # http://www.iki.fi/jhi/
        # There is this special biologist word we use for 'stable'.
        # It is 'dead'. -- Jack Cohen

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About