aboutsummaryrefslogtreecommitdiff
path: root/newlib/libc/stdio/fclose.c
diff options
context:
space:
mode:
Diffstat (limited to 'newlib/libc/stdio/fclose.c')
-rw-r--r--newlib/libc/stdio/fclose.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/newlib/libc/stdio/fclose.c b/newlib/libc/stdio/fclose.c
index 983ae2c..4c81cbf 100644
--- a/newlib/libc/stdio/fclose.c
+++ b/newlib/libc/stdio/fclose.c
@@ -72,6 +72,7 @@ _fclose_r (struct _reent *rptr,
int __oldcancel;
pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &__oldcancel);
#endif
+ __sfp_lock_acquire ();
if (!(fp->_flags2 & __SNLK))
_flockfile (fp);
@@ -79,6 +80,7 @@ _fclose_r (struct _reent *rptr,
{
if (!(fp->_flags2 & __SNLK))
_funlockfile (fp);
+ __sfp_lock_release ();
#ifdef _STDIO_WITH_THREAD_CANCELLATION_SUPPORT
pthread_setcancelstate (__oldcancel, &__oldcancel);
#endif
@@ -101,7 +103,6 @@ _fclose_r (struct _reent *rptr,
FREEUB (rptr, fp);
if (HASLB (fp))
FREELB (rptr, fp);
- __sfp_lock_acquire ();
fp->_flags = 0; /* release this FILE for reuse */
if (!(fp->_flags2 & __SNLK))
_funlockfile (fp);