diff options
author | Jeff Johnston <jjohnstn@redhat.com> | 2009-04-24 22:52:52 +0000 |
---|---|---|
committer | Jeff Johnston <jjohnstn@redhat.com> | 2009-04-24 22:52:52 +0000 |
commit | bcde12940007e836f7b831f1cdfda8dc2bda0c58 (patch) | |
tree | d9894d46eb51edf603939d8506bf0b5f97b9fa87 /newlib/libc/stdio/fread.c | |
parent | 35f31b6a983710aa9a2bd7e308d1567f326f3f5f (diff) | |
download | cygnal-bcde12940007e836f7b831f1cdfda8dc2bda0c58.tar.gz cygnal-bcde12940007e836f7b831f1cdfda8dc2bda0c58.tar.bz2 cygnal-bcde12940007e836f7b831f1cdfda8dc2bda0c58.zip |
2009-04-24 Jeff johnston <jjohnstn@redhat.com>
* libc/stdio/fgetc.c: Make sure sfp lock is acquired before the
file lock and released before the file lock to avoid a deadlock
scenario.
* libc/stdio/fgets.c: Ditto.
* libc/stdio/fgetwc.c: Ditto.
* libc/stdio/fgetws.c: Ditto.
* libc/stdio/fread.c: Ditto.
* libc/stdio/fseek.c: Ditto.
* libc/stdio/getc.c: Ditto.
* libc/stdio/getdelim.c: Ditto.
* libc/stdio/gets.c: Ditto.
Diffstat (limited to 'newlib/libc/stdio/fread.c')
-rw-r--r-- | newlib/libc/stdio/fread.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/newlib/libc/stdio/fread.c b/newlib/libc/stdio/fread.c index a39e9d85f..dda2044fe 100644 --- a/newlib/libc/stdio/fread.c +++ b/newlib/libc/stdio/fread.c @@ -146,6 +146,7 @@ _DEFUN(_fread_r, (ptr, buf, size, count, fp), CHECK_INIT(ptr, fp); + __sfp_lock_acquire (); _flockfile (fp); ORIENT (fp, -1); if (fp->_r < 0) @@ -196,10 +197,12 @@ _DEFUN(_fread_r, (ptr, buf, size, count, fp), if (fp->_flags & __SCLE) { _funlockfile (fp); + __sfp_lock_release (); return crlf_r (ptr, fp, buf, total-resid, 1) / size; } #endif _funlockfile (fp); + __sfp_lock_release (); return (total - resid) / size; } } @@ -221,10 +224,12 @@ _DEFUN(_fread_r, (ptr, buf, size, count, fp), if (fp->_flags & __SCLE) { _funlockfile (fp); + __sfp_lock_release (); return crlf_r (ptr, fp, buf, total-resid, 1) / size; } #endif _funlockfile (fp); + __sfp_lock_release (); return (total - resid) / size; } } @@ -238,10 +243,12 @@ _DEFUN(_fread_r, (ptr, buf, size, count, fp), if (fp->_flags & __SCLE) { _funlockfile (fp); + __sfp_lock_release (); return crlf_r(ptr, fp, buf, total, 0) / size; } #endif _funlockfile (fp); + __sfp_lock_release (); return count; } |