diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2009-06-15 01:39:30 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2009-06-15 01:39:30 +0800 |
commit | 5cb2ead8cae53b3e00b689933ae07ed88656026e (patch) | |
tree | 68b1178f85b2a51836b759d12181a318542e2f00 /common/sys | |
parent | e2b4af20009f9963522b6e31c75b3f79b61f5394 (diff) | |
download | pttbbs-5cb2ead8cae53b3e00b689933ae07ed88656026e.tar pttbbs-5cb2ead8cae53b3e00b689933ae07ed88656026e.tar.gz pttbbs-5cb2ead8cae53b3e00b689933ae07ed88656026e.tar.bz2 pttbbs-5cb2ead8cae53b3e00b689933ae07ed88656026e.tar.lz pttbbs-5cb2ead8cae53b3e00b689933ae07ed88656026e.tar.xz pttbbs-5cb2ead8cae53b3e00b689933ae07ed88656026e.tar.zst pttbbs-5cb2ead8cae53b3e00b689933ae07ed88656026e.zip |
* handle (to)read/write return value more correctly
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4617 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'common/sys')
-rw-r--r-- | common/sys/net.c | 8 |
1 files changed, 4 insertions, 4 deletions
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; |