diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2006-12-05 11:08:33 -0500 |
---|---|---|
committer | Steve Hay <SteveHay@planit.com> | 2006-12-06 14:08:49 +0000 |
commit | eae082a0f03d579c4d57624c9d7432c4e6eb6e82 (patch) | |
tree | 05c64c829deae16e79a95be86bf5642c022c81ff /perlio.c | |
parent | 581888587cc86bb21abcd35374b8f9e3c2857fa0 (diff) | |
download | perl-eae082a0f03d579c4d57624c9d7432c4e6eb6e82.tar.gz |
Re: When should PERL_SYS_TERM() be called? [was: Re: [PATCH] Re: [PATCH] Re: [PATCH] abstract mempool header testing]
Message-ID: <4575DFD1.1060108@iki.fi>
Fixes a problem spotted by Jan Dubois:
The PerlMemShared pool is only shared between the interpreters that
can share data structures (interpreters created by perl_clone(), which
mean pseudo-fork, and threads.xs). The pool is not shared between
interpreters that are created separately by perl_alloc().
[...]
I guess this means PL_perlio_fd_refcnt needs to be allocated and
freed by standard malloc() and not go through any abstraction.
p4raw-id: //depot/perl@29477
Diffstat (limited to 'perlio.c')
-rw-r--r-- | perlio.c | 16 |
1 files changed, 6 insertions, 10 deletions
@@ -2278,8 +2278,9 @@ S_more_refcounted_fds(pTHX_ const int new_fd) { assert (new_max > new_fd); - new_array = - (int*) PerlMemShared_realloc(PL_perlio_fd_refcnt, new_max * sizeof(int)); + /* Use plain realloc() since we need this memory to be really + * global and visible to all the interpreters and/or threads. */ + new_array = (int*) realloc(PL_perlio_fd_refcnt, new_max * sizeof(int)); if (!new_array) { #ifdef USE_ITHREADS @@ -2412,19 +2413,14 @@ void PerlIO_teardown(pTHX) /* Call only from PERL_SYS_TERM(). */ } } #endif -#if !defined(WIN32) || !defined(PERL_IMPLICIT_SYS) - /* On Windows, under PERL_IMPLICIT_SYS, all memory allocated by - * PerlMemShared_...() will be freed anyways when PL_curinterp - * is being destroyed. */ + /* Not bothering with PL_perlio_mutex since by now + * all the interpreters are gone. */ if (PL_perlio_fd_refcnt_size /* Assuming initial size of zero. */ && PL_perlio_fd_refcnt) { - /* Not bothering with PL_perlio_mutex since by now all the - * interpreters are gone. */ - PerlMemShared_free(PL_perlio_fd_refcnt); + free(PL_perlio_fd_refcnt); /* To match realloc() in S_more_refcounted_fds(). */ PL_perlio_fd_refcnt = NULL; PL_perlio_fd_refcnt_size = 0; } -#endif } |