diff options
author | simonmar <unknown> | 1999-09-16 13:14:43 +0000 |
---|---|---|
committer | simonmar <unknown> | 1999-09-16 13:14:43 +0000 |
commit | 6986b2b2439ce264df153878374f70cee54ef100 (patch) | |
tree | 07e1b667f51039b2ee9a2c3859119a23e5afa571 /ghc/lib/misc/cbits/createSocket.c | |
parent | cadc82fc0a7a1e640bb04842769ca337dedb8c70 (diff) | |
download | haskell-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/misc/cbits/createSocket.c')
-rw-r--r-- | ghc/lib/misc/cbits/createSocket.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/ghc/lib/misc/cbits/createSocket.c b/ghc/lib/misc/cbits/createSocket.c index 8b30d7278f..297fcb21b5 100644 --- a/ghc/lib/misc/cbits/createSocket.c +++ b/ghc/lib/misc/cbits/createSocket.c @@ -16,6 +16,7 @@ StgInt createSocket(I_ family, I_ type, I_ protocol) { int fd; + long flags; if ((fd = socket((int)family, (int)type, (int)protocol)) < 0) { if (errno != EINTR) { @@ -48,5 +49,10 @@ createSocket(I_ family, I_ type, I_ protocol) return (StgInt)-1; } } + + /* set the non-blocking flag on this file descriptor */ + flags = fcntl(fd, F_GETFL); + fcntl(fd, F_SETFL, flags | O_NONBLOCK); + return (StgInt)fd; } |