This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
cleanup the mutex use of PerlIOStdio_close
authorJarkko Hietaniemi <jhi@iki.fi>
Fri, 6 Nov 2015 00:00:01 +0000 (19:00 -0500)
committerJarkko Hietaniemi <jhi@iki.fi>
Mon, 23 Nov 2015 11:55:12 +0000 (06:55 -0500)
commitd88f7f65327a827e00ba021f9c6f474e64aa97b0
tree71f7b15abb4b4c823ee126f9876885ef51adf4da
parentff25d7bcdd32f227c1d1926c13e0ca78af0e3c04
cleanup the mutex use of PerlIOStdio_close

Before: clang -Wthread-safety found the flow quite suspect:
one conditional mutex lock, with two conditional unlocks.
The code *looked* like the being okay logic-wise now, but
rather fragile, so let's make it clearer and more solid
by hoisting the locking earlier.

This is a fd close, this should not be a performance sensitive spot.

And it's in PerlIOStdio, so it should be pretty dead anyway.

perlio.c:3283:18: warning: mutex 'PL_perlio_mutex' is not held on every path through here [-Wthread-safety-analysis]
        result = PerlSIO_fclose(stdio);

perlio.c:3299:6: warning: releasing mutex 'PL_perlio_mutex' that was not held [-Wthread-safety-analysis]
            MUTEX_UNLOCK(&PL_perlio_mutex);
perlio.c