X-Git-Url: http://nsz.repo.hu/git/?p=musl;a=blobdiff_plain;f=src%2Fstdio%2F__stdio_read.c;h=ee17a576c5bb70c66c1def2d9d8f5537d7896059;hp=218bd88d18df42d908dc121600af2cf242cb9abd;hb=58165923890865a6ac042fafce13f440ee986fd9;hpb=4948a24df21c1e80bedc1f302547c9cb26e4dbfe diff --git a/src/stdio/__stdio_read.c b/src/stdio/__stdio_read.c index 218bd88d..ee17a576 100644 --- a/src/stdio/__stdio_read.c +++ b/src/stdio/__stdio_read.c @@ -1,4 +1,11 @@ #include "stdio_impl.h" +#include + +static void cleanup(void *p) +{ + FILE *f = p; + if (!f->lockcount) __unlockfile(f); +} size_t __stdio_read(FILE *f, unsigned char *buf, size_t len) { @@ -8,7 +15,9 @@ size_t __stdio_read(FILE *f, unsigned char *buf, size_t len) }; ssize_t cnt; - cnt = syscall(SYS_readv, f->fd, iov, 2); + pthread_cleanup_push(cleanup, f); + cnt = syscall_cp(SYS_readv, f->fd, iov, 2); + pthread_cleanup_pop(0); if (cnt <= 0) { f->flags |= F_EOF ^ ((F_ERR^F_EOF) & cnt); f->rpos = f->rend = 0;