summaryrefslogtreecommitdiffstats
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.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/newlib/libc/stdio/fclose.c b/newlib/libc/stdio/fclose.c
index cd271c490..0ce112306 100644
--- a/newlib/libc/stdio/fclose.c
+++ b/newlib/libc/stdio/fclose.c
@@ -82,11 +82,13 @@ _DEFUN(_fclose_r, (rptr, fp),
int __oldcancel;
pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, &__oldcancel);
#endif
- _flockfile (fp);
+ if (!(fp->_flags2 & __SNLK))
+ _flockfile (fp);
if (fp->_flags == 0) /* not open! */
{
- _funlockfile (fp);
+ if (!(fp->_flags2 & __SNLK))
+ _funlockfile (fp);
#ifdef _STDIO_WITH_THREAD_CANCELLATION_SUPPORT
pthread_setcancelstate (__oldcancel, &__oldcancel);
#endif
@@ -111,7 +113,8 @@ _DEFUN(_fclose_r, (rptr, fp),
FREELB (rptr, fp);
__sfp_lock_acquire ();
fp->_flags = 0; /* release this FILE for reuse */
- _funlockfile (fp);
+ if (!(fp->_flags2 & __SNLK))
+ _funlockfile (fp);
#ifndef __SINGLE_THREAD__
__lock_close_recursive (fp->_lock);
#endif