summaryrefslogtreecommitdiff
path: root/ghc/lib/std/cbits/writeFile.c
diff options
context:
space:
mode:
authorsimonmar <unknown>1999-09-16 13:14:43 +0000
committersimonmar <unknown>1999-09-16 13:14:43 +0000
commit6986b2b2439ce264df153878374f70cee54ef100 (patch)
tree07e1b667f51039b2ee9a2c3859119a23e5afa571 /ghc/lib/std/cbits/writeFile.c
parentcadc82fc0a7a1e640bb04842769ca337dedb8c70 (diff)
downloadhaskell-6986b2b2439ce264df153878374f70cee54ef100.tar.gz
[project @ 1999-09-16 13:14:38 by simonmar]
Cleanup of non-blocking I/O - file descriptors are now always set to non-blocking mode. - we don't do an inputReady operation on descriptors before attempting to read from them any more. - the non-blocking flag on Handles has gone. - the {set,clear}[Conn]NonBlockingFlag() functions have gone. - the socket operations have been made to work properly with threads: accept is now non-blocking (it does a threadWaitRead instead of blocking), and the file descriptors returned by accept are set to non-blocking mode. Win32 will need some adjustments, no doubt.
Diffstat (limited to 'ghc/lib/std/cbits/writeFile.c')
-rw-r--r--ghc/lib/std/cbits/writeFile.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/ghc/lib/std/cbits/writeFile.c b/ghc/lib/std/cbits/writeFile.c
index e69442d994..0b459f33b8 100644
--- a/ghc/lib/std/cbits/writeFile.c
+++ b/ghc/lib/std/cbits/writeFile.c
@@ -1,7 +1,7 @@
/*
* (c) The GRASP/AQUA Project, Glasgow University, 1994-1998
*
- * $Id: writeFile.c,v 1.7 1999/09/12 19:18:22 sof Exp $
+ * $Id: writeFile.c,v 1.8 1999/09/16 13:14:43 simonmar Exp $
*
* hPutStr Runtime Support
*/
@@ -53,9 +53,6 @@ StgInt bytes;
if (bytes == 0 || fo->buf == NULL)
return 0;
- if ( fo->flags & FILEOBJ_NONBLOCKING_IO && inputReady(ptr,0) != 1 )
- return FILEOBJ_BLOCKED_WRITE;
-
while ((count =
(
#ifdef USE_WINSOCK
@@ -121,10 +118,6 @@ StgInt len;
return rc;
}
- if ( fo->flags & FILEOBJ_NONBLOCKING_IO && inputReady(ptr,0) != 1 )
- return FILEOBJ_BLOCKED_WRITE;
-
- /* Disallow short writes */
while ((count =
(
#ifdef USE_WINSOCK
@@ -134,13 +127,18 @@ StgInt len;
#else
write(fo->fd, pBuf, (int)len))) < len ) {
#endif
- if (errno != EINTR) {
+ if ( count >= 0 ) {
+ len -= count;
+ pBuf += count;
+ continue;
+ } else if ( errno == EAGAIN ) {
+ errno = 0;
+ return FILEOBJ_BLOCKED_WRITE;
+ } else if ( errno != EINTR ) {
cvtErrno();
stdErrno();
return -1;
}
- len -= count;
- pBuf += count;
}
return 0;