diff options
| author | Elliott Hughes <enh@google.com> | 2015-01-20 16:18:32 -0800 |
|---|---|---|
| committer | Elliott Hughes <enh@google.com> | 2015-01-20 16:18:32 -0800 |
| commit | 8885dcc779bceae5016d5ad96caa73465a7bab90 (patch) | |
| tree | 9a5851adf9ffa5755ff2e99da04e6320fc581f99 | |
| parent | 927d8be76d956fcda630e1088e9b89eb31be5146 (diff) | |
| download | bionic-8885dcc779bceae5016d5ad96caa73465a7bab90.zip bionic-8885dcc779bceae5016d5ad96caa73465a7bab90.tar.gz bionic-8885dcc779bceae5016d5ad96caa73465a7bab90.tar.bz2 | |
Add TEMP_FAILURE_RETRY to stdio's low-level read/write functions.
This is correctness rather than performance, but found while investigating
performance.
Bug: 18593728
Change-Id: Idbdfed89d1931fcfae65db29d662108d4bbd9b65
| -rw-r--r-- | libc/Android.mk | 2 | ||||
| -rw-r--r-- | libc/stdio/stdio.c (renamed from libc/upstream-openbsd/lib/libc/stdio/stdio.c) | 11 |
2 files changed, 7 insertions, 6 deletions
diff --git a/libc/Android.mk b/libc/Android.mk index cc1585c..e96bcff 100644 --- a/libc/Android.mk +++ b/libc/Android.mk @@ -61,6 +61,7 @@ libc_common_src_files := \ stdio/fread.c \ stdio/snprintf.c\ stdio/sprintf.c \ + stdio/stdio.c \ stdio/stdio_ext.cpp \ # Fortify implementations of libc functions. @@ -450,7 +451,6 @@ libc_upstream_openbsd_src_files := \ upstream-openbsd/lib/libc/stdio/setbuffer.c \ upstream-openbsd/lib/libc/stdio/setvbuf.c \ upstream-openbsd/lib/libc/stdio/sscanf.c \ - upstream-openbsd/lib/libc/stdio/stdio.c \ upstream-openbsd/lib/libc/stdio/swprintf.c \ upstream-openbsd/lib/libc/stdio/swscanf.c \ upstream-openbsd/lib/libc/stdio/tempnam.c \ diff --git a/libc/upstream-openbsd/lib/libc/stdio/stdio.c b/libc/stdio/stdio.c index a4a27b5..13b9887 100644 --- a/libc/upstream-openbsd/lib/libc/stdio/stdio.c +++ b/libc/stdio/stdio.c @@ -31,6 +31,7 @@ * SUCH DAMAGE. */ +#include <errno.h> #include <fcntl.h> #include <unistd.h> #include <stdio.h> @@ -46,7 +47,7 @@ __sread(void *cookie, char *buf, int n) FILE *fp = cookie; int ret; - ret = read(fp->_file, buf, n); + ret = TEMP_FAILURE_RETRY(read(fp->_file, buf, n)); /* if the read succeeded, update the current offset */ if (ret >= 0) fp->_offset += ret; @@ -61,9 +62,9 @@ __swrite(void *cookie, const char *buf, int n) FILE *fp = cookie; if (fp->_flags & __SAPP) - (void) lseek(fp->_file, (off_t)0, SEEK_END); + (void) TEMP_FAILURE_RETRY(lseek(fp->_file, (off_t)0, SEEK_END)); fp->_flags &= ~__SOFF; /* in case FAPPEND mode is set */ - return (write(fp->_file, buf, n)); + return TEMP_FAILURE_RETRY(write(fp->_file, buf, n)); } fpos_t @@ -72,7 +73,7 @@ __sseek(void *cookie, fpos_t offset, int whence) FILE *fp = cookie; off_t ret; - ret = lseek(fp->_file, (off_t)offset, whence); + ret = TEMP_FAILURE_RETRY(lseek(fp->_file, (off_t)offset, whence)); if (ret == (off_t)-1) fp->_flags &= ~__SOFF; else { @@ -85,5 +86,5 @@ __sseek(void *cookie, fpos_t offset, int whence) int __sclose(void *cookie) { - return (close(((FILE *)cookie)->_file)); + return TEMP_FAILURE_RETRY(close(((FILE *)cookie)->_file)); } |
