diff options
author | Rich Felker <dalias@aerifal.cx> | 2018-02-24 11:19:54 -0500 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2018-02-24 11:19:54 -0500 |
commit | e7eeeb9f2a4a358fb0bbed81e145ef5538ff60f0 (patch) | |
tree | 0632ca84dcfa25c74f610e74d3241d91291eea88 /src/stdio/__stdio_read.c | |
parent | f92804188eb464536d638548e51e835b6c49e373 (diff) | |
download | musl-e7eeeb9f2a4a358fb0bbed81e145ef5538ff60f0.tar.gz |
avoid use of readv syscall in __stdio_read backend when not needed
formally, calling readv with a zero-length first iov component should
behave identically to calling read on just the second component, but
presence of a zero-length iov component has triggered bugs in some
kernels and performs significantly worse than a simple read on some
file types.
Diffstat (limited to 'src/stdio/__stdio_read.c')
-rw-r--r-- | src/stdio/__stdio_read.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/stdio/__stdio_read.c b/src/stdio/__stdio_read.c index 909c36a9..ea675da3 100644 --- a/src/stdio/__stdio_read.c +++ b/src/stdio/__stdio_read.c @@ -9,7 +9,8 @@ size_t __stdio_read(FILE *f, unsigned char *buf, size_t len) }; ssize_t cnt; - cnt = syscall(SYS_readv, f->fd, iov, 2); + cnt = iov[0].iov_len ? syscall(SYS_readv, f->fd, iov, 2) + : syscall(SYS_read, f->fd, iov[1].iov_base, iov[1].iov_len); if (cnt <= 0) { f->flags |= cnt ? F_ERR : F_EOF; return 0; |