summaryrefslogtreecommitdiffstats
path: root/newlib/libc/stdio64/fopen64.c
diff options
context:
space:
mode:
Diffstat (limited to 'newlib/libc/stdio64/fopen64.c')
-rw-r--r--newlib/libc/stdio64/fopen64.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/newlib/libc/stdio64/fopen64.c b/newlib/libc/stdio64/fopen64.c
index 3c69820ee..1feffd1db 100644
--- a/newlib/libc/stdio64/fopen64.c
+++ b/newlib/libc/stdio64/fopen64.c
@@ -91,10 +91,17 @@ _DEFUN (_fopen64_r, (ptr, file, mode),
if ((f = _open64_r (ptr, file, oflags, 0666)) < 0)
{
+ __sfp_lock_acquire ();
fp->_flags = 0; /* release */
+#ifndef __SINGLE_THREAD__
+ __lock_close_recursive (*(_LOCK_RECURSIVE_T *)&fp->_lock);
+#endif
+ __sfp_lock_release ();
return NULL;
}
+ _flockfile(fp);
+
fp->_file = f;
fp->_flags = flags;
fp->_cookie = (_PTR) fp;
@@ -114,10 +121,7 @@ _DEFUN (_fopen64_r, (ptr, file, mode),
fp->_flags |= __SL64;
-#ifndef __SINGLE_THREAD__
- __lock_init_recursive (*(_LOCK_RECURSIVE_T *)&fp->_lock);
-#endif
-
+ _funlockfile(fp);
return fp;
}