From b61efa3e2b230fb437cd7c0ad1e8513d1e0d298f Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Mon, 26 Aug 2019 09:49:31 +0800 Subject: [PATCH] fix twrite problem --- src/os/linux/src/os.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/os/linux/src/os.c b/src/os/linux/src/os.c index e76f15e9ff..41dee25659 100644 --- a/src/os/linux/src/os.c +++ b/src/os/linux/src/os.c @@ -276,12 +276,12 @@ ssize_t tsendfile(int dfd, int sfd, off_t *offset, size_t size) { } ssize_t twrite(int fd, void *buf, size_t n) { - size_t nleft, nwritten; - - nleft = n; + size_t nleft = n; + ssize_t nwritten = 0; + char *tbuf = (char *)buf while (nleft > 0) { - nwritten = write(fd, buf, nleft); + nwritten = write(fd, (void *)tbuf, nleft); if (nwritten < 0) { if (errno == EINTR) { continue; @@ -289,7 +289,7 @@ ssize_t twrite(int fd, void *buf, size_t n) { return -1; } nleft -= nwritten; - buf += nwritten; + tbuf += nwritten; } return n; -- GitLab