[project @ 1998-08-24 10:53:41 by sof]
authorsof <unknown>
Mon, 24 Aug 1998 10:53:41 +0000 (10:53 +0000)
committersof <unknown>
Mon, 24 Aug 1998 10:53:41 +0000 (10:53 +0000)
readChunk:
  last commit may have fixed a bug in the handling of incomplete reads,
  but at the cost of breaking the (common) case of complete
  reads :-/. Should work better in both cases now.

ghc/lib/std/cbits/readFile.lc

index 457db8f..d740fb4 100644 (file)
@@ -158,7 +158,7 @@ StgInt len;
 
     while ((count = read(fd, p, len)) < len) {
        if ( count == 0 ) { /* EOF */
-           return total_count;
+           break;
        } else if ( count == -1 && errno == EAGAIN) {
            errno = 0;
            return FILEOBJ_BLOCKED_READ;
@@ -172,6 +172,7 @@ StgInt len;
        p += count;
     }
 
+    total_count += count;
     fo->bufWPtr = total_count;
     fo->bufRPtr = 0;
     return total_count;