X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl.c;h=25cdcd6e4ba3f3cb3fa02b777ac28987d22a8424;hb=83ea2aad1336e3391e134c006ffdacaf0b5bd14a;hp=34da642d819ad9b82ca4d16978cbba3ef5c73378;hpb=4f0c37ba8a5ec95c6a79b1e0deea87d200d9357a;p=p5sagit%2Fp5-mst-13.2.git diff --git a/perl.c b/perl.c index 34da642..25cdcd6 100644 --- a/perl.c +++ b/perl.c @@ -58,6 +58,29 @@ static I32 read_e_script(pTHXo_ int idx, SV *buf_sv, int maxlen); } STMT_END #else # if defined(USE_ITHREADS) + +/* this is called in parent before the fork() */ +void +Perl_atfork_lock(void) +{ + /* locks must be held in locking order (if any) */ +#ifdef MYMALLOC + MUTEX_LOCK(&PL_malloc_mutex); +#endif + OP_REFCNT_LOCK; +} + +/* this is called in both parent and child after the fork() */ +void +Perl_atfork_unlock(void) +{ + /* locks must be released in same order as in S_atfork_lock() */ +#ifdef MYMALLOC + MUTEX_UNLOCK(&PL_malloc_mutex); +#endif + OP_REFCNT_UNLOCK; +} + # define INIT_TLS_AND_INTERP \ STMT_START { \ if (!PL_curinterp) { \ @@ -226,8 +249,8 @@ perl_construct(pTHXx) * space. The other alternative would be to provide STDAUX and STDPRN * filehandles. */ - (void)fclose(stdaux); - (void)fclose(stdprn); + (void)PerlIO_close(PerlIO_importFILE(stdaux, 0)); + (void)PerlIO_close(PerlIO_importFILE(stdprn, 0)); #endif } @@ -283,7 +306,13 @@ perl_construct(pTHXx) PL_fdpid = newAV(); /* for remembering popen pids by fd */ PL_modglobal = newHV(); /* pointers to per-interpreter module globals */ PL_errors = newSVpvn("",0); - +#ifdef USE_ITHREADS + PL_regex_padav = newAV(); +#endif +#ifdef USE_REENTRANT_API + New(31337, PL_reentrant_buffer,1, REBUF); + New(31337, PL_reentrant_buffer->tmbuff,1, struct tm); +#endif ENTER; } @@ -776,6 +805,11 @@ perl_destruct(pTHXx) PL_thrsv = Nullsv; #endif /* USE_THREADS */ +#ifdef USE_REENTRANT_API + Safefree(PL_reentrant_buffer->tmbuff); + Safefree(PL_reentrant_buffer); +#endif + sv_free_arenas(); /* As the absolutely last thing, free the non-arena SV for mess() */ @@ -2037,7 +2071,7 @@ STATIC void S_usage(pTHX_ char *name) /* XXX move this out into a module ? */ { /* This message really ought to be max 23 lines. - * Removed -h because the user already knows that opton. Others? */ + * Removed -h because the user already knows that option. Others? */ static char *usage_msg[] = { "-0[octal] specify record separator (\\0, if no argument)",