diff options
author | Gurusamy Sarathy <gsar@cpan.org> | 2000-07-11 17:36:42 +0000 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 2000-07-11 17:36:42 +0000 |
commit | 3d35f11b2518ea9ea787f5db97c6c3e7cff04dbf (patch) | |
tree | 734aa6592529265daf086a04e80910a6ed0c7650 /util.c | |
parent | f3b469aff5df6578898d16737a9550f4e9b8ee54 (diff) | |
download | perl-3d35f11b2518ea9ea787f5db97c6c3e7cff04dbf.tar.gz |
integrate cfgperl changes#6207..6210 into mainline
p4raw-link: @6210 on //depot/cfgperl: b8b4c9f3cf6ef09c878a80ff97526a69902a44ca
p4raw-link: @6207 on //depot/cfgperl: b37a7757477319a5fcdd5131db15046064f631c4
p4raw-id: //depot/perl@6345
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 34 |
1 files changed, 34 insertions, 0 deletions
@@ -2402,7 +2402,9 @@ Perl_my_popen(pTHX_ char *cmd, char *mode) PerlLIO_close(p[This]); p[This] = p[that]; } + FDPID_LOCK; sv = *av_fetch(PL_fdpid,p[This],TRUE); + FDPID_UNLOCK; (void)SvUPGRADE(sv,SVt_IV); SvIVX(sv) = pid; PL_forkprocess = pid; @@ -2620,7 +2622,9 @@ Perl_my_pclose(pTHX_ PerlIO *ptr) int saved_win32_errno; #endif + FDPID_LOCK; svp = av_fetch(PL_fdpid,PerlIO_fileno(ptr),TRUE); + FDPID_UNLOCK; pid = SvIVX(*svp); SvREFCNT_dec(*svp); *svp = &PL_sv_undef; @@ -3492,6 +3496,36 @@ Perl_condpair_magic(pTHX_ SV *sv) return mg; } +SV * +Perl_lock(pTHX_ SV *osv) +{ + MAGIC *mg; + SV *sv = osv; + + SvLOCK(osv); + if (SvROK(sv)) { + sv = SvRV(sv); + SvUNLOCK(osv); + SvLOCK(sv); + } + + mg = condpair_magic(sv); + MUTEX_LOCK(MgMUTEXP(mg)); + if (MgOWNER(mg) == thr) + MUTEX_UNLOCK(MgMUTEXP(mg)); + else { + while (MgOWNER(mg)) + COND_WAIT(MgOWNERCONDP(mg), MgMUTEXP(mg)); + MgOWNER(mg) = thr; + DEBUG_S(PerlIO_printf(Perl_debug_log, "0x%"UVxf": Perl_lock lock 0x%"UVxf"\n", + PTR2UV(thr), PTR2UV(sv));) + MUTEX_UNLOCK(MgMUTEXP(mg)); + SAVEDESTRUCTOR_X(Perl_unlock_condpair, sv); + } + SvUNLOCK(sv); + return sv; +} + /* * Make a new perl thread structure using t as a prototype. Some of the * fields for the new thread are copied from the prototype thread, t, |