From b674b3cdb447d2265dccc4e3c343c9625f464a33 Mon Sep 17 00:00:00 2001 From: simonmar Date: Tue, 13 Dec 2005 13:28:53 +0000 Subject: [PATCH] [project @ 2005-12-13 13:28:53 by simonmar] Only Streams can be DuplexHandles, not RawDevices. --- GHC/Handle.hs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) 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 -- 1.7.10.4