From 5cb2ead8cae53b3e00b689933ae07ed88656026e Mon Sep 17 00:00:00 2001 From: piaip Date: Sun, 14 Jun 2009 17:39:30 +0000 Subject: * handle (to)read/write return value more correctly git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4617 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- common/sys/net.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'common') diff --git a/common/sys/net.c b/common/sys/net.c index efeda16a..5bf9dc5e 100644 --- a/common/sys/net.c +++ b/common/sys/net.c @@ -189,9 +189,9 @@ int toread(int fd, void *buf, int len) int l; for( l = 0 ; len > 0 ; ) if( (l = read(fd, buf, len)) <= 0 ) { - if (errno == EINTR || errno == EAGAIN) + if (l < 0 && (errno == EINTR || errno == EAGAIN)) continue; - return -1; + return l; }else{ buf += l; len -= l; @@ -207,9 +207,9 @@ int towrite(int fd, const void *buf, int len) int l; for( l = 0 ; len > 0 ; ) if( (l = write(fd, buf, len)) <= 0){ - if (errno == EINTR || errno == EAGAIN) + if (l < 0 && (errno == EINTR || errno == EAGAIN)) continue; - return -1; + return l; }else{ buf += l; len -= l; -- cgit v1.2.3