From: simonmar Date: Tue, 13 Dec 2005 13:28:53 +0000 (+0000) Subject: [project @ 2005-12-13 13:28:53 by simonmar] X-Git-Tag: Initial_conversion_from_CVS_complete~9 X-Git-Url: http://git.megacz.com/?p=ghc-base.git;a=commitdiff_plain;h=b674b3cdb447d2265dccc4e3c343c9625f464a33 [project @ 2005-12-13 13:28:53 by simonmar] Only Streams can be DuplexHandles, not RawDevices. --- diff --git a/GHC/Handle.hs b/GHC/Handle.hs index 0e9b3be..52bf8cd 100644 --- a/GHC/Handle.hs +++ b/GHC/Handle.hs @@ -924,16 +924,21 @@ openFd fd mb_fd_type is_socket filepath mode binary = do "file is locked" Nothing) #endif mkFileHandle fd is_socket filepath ha_type binary - -- Stream or RawDevice - Stream -> mkIt ha_type - RawDevice -> mkIt ha_type + + Stream + -- only *Streams* can be DuplexHandles. Other read/write + -- Handles must share a buffer. + | ReadWriteHandle <- ha_type -> + mkDuplexHandle fd is_socket filepath binary + | otherwise -> + mkFileHandle fd is_socket filepath ha_type binary + + RawDevice -> + mkFileHandle fd is_socket filepath ha_type binary + _ -> ioException (IOError Nothing UnsupportedOperation "openFd" "unknown file type" Nothing) - where - mkIt ht - | isReadWriteHandleType ht = mkDuplexHandle fd is_socket filepath binary - | otherwise = mkFileHandle fd is_socket filepath ht binary fdToHandle :: FD -> IO Handle fdToHandle fd = do