Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package ghc-network for openSUSE:Factory checked in at 2023-06-22 23:25:29 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/ghc-network (Old) and /work/SRC/openSUSE:Factory/.ghc-network.new.15902 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ghc-network" Thu Jun 22 23:25:29 2023 rev:32 rq:1094439 version:3.1.4.0 Changes: -------- --- /work/SRC/openSUSE:Factory/ghc-network/ghc-network.changes 2023-04-04 21:21:47.809664658 +0200 +++ /work/SRC/openSUSE:Factory/.ghc-network.new.15902/ghc-network.changes 2023-06-22 23:25:55.141798109 +0200 @@ -1,0 +2,31 @@ +Wed May 24 23:57:29 UTC 2023 - Peter Simons <[email protected]> + +- Update network to version 3.1.4.0. + ## Version 3.1.4.0 + + * Install and use afunix_compat.h header. + [#556](https://github.com/haskell/network/pull/556) + * Supporting SO_SNDTIMEO and SO_RCVTIMEO. + [#555](https://github.com/haskell/network/pull/555) + * Emulating socketPair on Windows. + [#554](https://github.com/haskell/network/pull/554) + +------------------------------------------------------------------- +Tue May 16 04:28:50 UTC 2023 - Peter Simons <[email protected]> + +- Update network to version 3.1.3.0. + ## Version 3.1.3.0 + + * Supporting AF_UNIX on Windows + [#553](https://github.com/haskell/network/issues/553) + +------------------------------------------------------------------- +Mon May 1 13:54:13 UTC 2023 - Peter Simons <[email protected]> + +- Update network to version 3.1.2.9. + ## Version 3.1.2.9 + + * Resolving the runtime linker problem on Windows. + [#552](https://github.com/haskell/network/issues/552) + +------------------------------------------------------------------- Old: ---- network-3.1.2.8.tar.gz New: ---- network-3.1.4.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ ghc-network.spec ++++++ --- /var/tmp/diff_new_pack.pAT0MJ/_old 2023-06-22 23:25:55.665800781 +0200 +++ /var/tmp/diff_new_pack.pAT0MJ/_new 2023-06-22 23:25:55.669800801 +0200 @@ -20,7 +20,7 @@ %global pkgver %{pkg_name}-%{version} %bcond_with tests Name: ghc-%{pkg_name} -Version: 3.1.2.8 +Version: 3.1.4.0 Release: 0 Summary: Low-level networking interface License: BSD-3-Clause ++++++ network-3.1.2.8.tar.gz -> network-3.1.4.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/network-3.1.2.8/CHANGELOG.md new/network-3.1.4.0/CHANGELOG.md --- old/network-3.1.2.8/CHANGELOG.md 2001-09-09 03:46:40.000000000 +0200 +++ new/network-3.1.4.0/CHANGELOG.md 2001-09-09 03:46:40.000000000 +0200 @@ -1,3 +1,22 @@ +## Version 3.1.4.0 + +* Install and use afunix_compat.h header. + [#556](https://github.com/haskell/network/pull/556) +* Supporting SO_SNDTIMEO and SO_RCVTIMEO. + [#555](https://github.com/haskell/network/pull/555) +* Emulating socketPair on Windows. + [#554](https://github.com/haskell/network/pull/554) + +## Version 3.1.3.0 + +* Supporting AF_UNIX on Windows + [#553](https://github.com/haskell/network/issues/553) + +## Version 3.1.2.9 + +* Resolving the runtime linker problem on Windows. + [#552](https://github.com/haskell/network/issues/552) + ## Version 3.1.2.8 * Ignoring error from shutdown in gracefulClose diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/network-3.1.2.8/Network/Socket/ByteString/IO.hsc new/network-3.1.4.0/Network/Socket/ByteString/IO.hsc --- old/network-3.1.2.8/Network/Socket/ByteString/IO.hsc 2001-09-09 03:46:40.000000000 +0200 +++ new/network-3.1.4.0/Network/Socket/ByteString/IO.hsc 2001-09-09 03:46:40.000000000 +0200 @@ -232,6 +232,11 @@ -- -- For TCP sockets, a zero length return value means the peer has -- closed its half side of the connection. +-- +-- Currently, the 'recv' family is blocked on Windows because a proper +-- IO manager is not implemented. To use with 'System.Timeout.timeout' +-- on Windows, use 'Network.Socket.setSocketOption' with +-- 'Network.Socket.RecvTimeOut' as well. recv :: Socket -- ^ Connected socket -> Int -- ^ Maximum number of bytes to receive -> IO ByteString -- ^ Data received diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/network-3.1.2.8/Network/Socket/Info.hsc new/network-3.1.4.0/Network/Socket/Info.hsc --- old/network-3.1.2.8/Network/Socket/Info.hsc 2001-09-09 03:46:40.000000000 +0200 +++ new/network-3.1.4.0/Network/Socket/Info.hsc 2001-09-09 03:46:40.000000000 +0200 @@ -413,11 +413,7 @@ -- SockAddr instance Show SockAddr where -#if defined(DOMAIN_SOCKET_SUPPORT) showsPrec _ (SockAddrUnix str) = showString str -#else - showsPrec _ SockAddrUnix{} = error "showsPrec: not supported" -#endif showsPrec _ (SockAddrInet port ha) = showHostAddress ha . showString ":" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/network-3.1.2.8/Network/Socket/Options.hsc new/network-3.1.4.0/Network/Socket/Options.hsc --- old/network-3.1.2.8/Network/Socket/Options.hsc 2001-09-09 03:46:40.000000000 +0200 +++ new/network-3.1.4.0/Network/Socket/Options.hsc 2001-09-09 03:46:40.000000000 +0200 @@ -26,6 +26,7 @@ , getSockOpt , setSockOpt , StructLinger (..) + , SocketTimeout (..) ) where import qualified Text.Read as P @@ -38,7 +39,9 @@ import Network.Socket.Types import Network.Socket.ReadShow ------------------------------------------------------------------------------ +#include <sys/time.h> + +---------------------------------------------------------------- -- Socket Properties -- | Socket options for use with 'setSocketOption' and 'getSocketOption'. @@ -55,18 +58,75 @@ #endif deriving (Eq) +---------------------------------------------------------------- + +socketOptionBijection :: Bijection SocketOption String +socketOptionBijection = + [ (UnsupportedSocketOption, "UnsupportedSocketOption") + , (Debug, "Debug") + , (ReuseAddr, "ReuseAddr") + , (SoDomain, "SoDomain") + , (Type, "Type") + , (SoProtocol, "SoProtocol") + , (SoError, "SoError") + , (DontRoute, "DontRoute") + , (Broadcast, "Broadcast") + , (SendBuffer, "SendBuffer") + , (RecvBuffer, "RecvBuffer") + , (KeepAlive, "KeepAlive") + , (OOBInline, "OOBInline") + , (Linger, "Linger") + , (ReusePort, "ReusePort") + , (RecvLowWater, "RecvLowWater") + , (SendLowWater, "SendLowWater") + , (RecvTimeOut, "RecvTimeOut") + , (SendTimeOut, "SendTimeOut") + , (UseLoopBack, "UseLoopBack") + , (MaxSegment, "MaxSegment") + , (NoDelay, "NoDelay") + , (UserTimeout, "UserTimeout") + , (Cork, "Cork") + , (TimeToLive, "TimeToLive") + , (RecvIPv4TTL, "RecvIPv4TTL") + , (RecvIPv4TOS, "RecvIPv4TOS") + , (RecvIPv4PktInfo, "RecvIPv4PktInfo") + , (IPv6Only, "IPv6Only") + , (RecvIPv6HopLimit, "RecvIPv6HopLimit") + , (RecvIPv6TClass, "RecvIPv6TClass") + , (RecvIPv6PktInfo, "RecvIPv6PktInfo") + ] + +instance Show SocketOption where + showsPrec = bijectiveShow socketOptionBijection def + where + defname = "SockOpt" + unwrap = \(CustomSockOpt nm) -> nm + def = defShow defname unwrap showIntInt + + +instance Read SocketOption where + readPrec = bijectiveRead socketOptionBijection def + where + defname = "SockOpt" + def = defRead defname CustomSockOpt readIntInt + +---------------------------------------------------------------- + +pattern UnsupportedSocketOption :: SocketOption +pattern UnsupportedSocketOption = SockOpt (-1) (-1) + -- | Does the 'SocketOption' exist on this system? isSupportedSocketOption :: SocketOption -> Bool isSupportedSocketOption opt = opt /= SockOpt (-1) (-1) --- | Get the 'SocketType' of an active socket. --- --- Since: 3.0.1.0 -getSocketType :: Socket -> IO SocketType -getSocketType s = unpackSocketType <$> getSockOpt s Type +-- | Execute the given action only when the specified socket option is +-- supported. Any return value is ignored. +whenSupported :: SocketOption -> IO a -> IO () +whenSupported s action + | isSupportedSocketOption s = action >> return () + | otherwise = return () -pattern UnsupportedSocketOption :: SocketOption -pattern UnsupportedSocketOption = SockOpt (-1) (-1) +---------------------------------------------------------------- #ifdef SOL_SOCKET -- | SO_ACCEPTCONN, read-only @@ -192,14 +252,14 @@ #else pattern SendLowWater = SockOpt (-1) (-1) #endif --- | SO_RCVTIMEO: this does not work at this moment. +-- | SO_RCVTIMEO: timeout in microseconds pattern RecvTimeOut :: SocketOption #ifdef SO_RCVTIMEO pattern RecvTimeOut = SockOpt (#const SOL_SOCKET) (#const SO_RCVTIMEO) #else pattern RecvTimeOut = SockOpt (-1) (-1) #endif --- | SO_SNDTIMEO: this does not work at this moment. +-- | SO_SNDTIMEO: timeout in microseconds pattern SendTimeOut :: SocketOption #ifdef SO_SNDTIMEO pattern SendTimeOut = SockOpt (#const SOL_SOCKET) (#const SO_SNDTIMEO) @@ -317,44 +377,9 @@ where CustomSockOpt (x, y) = SockOpt x y -#if __GLASGOW_HASKELL__ >= 806 -{-# COMPLETE CustomSockOpt #-} -#endif -#ifdef SO_LINGER --- | Low level 'SO_LINBER' option value, which can be used with 'setSockOpt'. --- -data StructLinger = StructLinger { - -- | Set the linger option on. - sl_onoff :: CInt, - - -- | Linger timeout. - sl_linger :: CInt - } - deriving (Eq, Ord, Show) +---------------------------------------------------------------- -instance Storable StructLinger where - sizeOf _ = (#const sizeof(struct linger)) - alignment _ = alignment (0 :: CInt) - - peek p = do - onoff <- (#peek struct linger, l_onoff) p - linger <- (#peek struct linger, l_linger) p - return $ StructLinger onoff linger - - poke p (StructLinger onoff linger) = do - (#poke struct linger, l_onoff) p onoff - (#poke struct linger, l_linger) p linger -#endif - --- | Execute the given action only when the specified socket option is --- supported. Any return value is ignored. -whenSupported :: SocketOption -> IO a -> IO () -whenSupported s action - | isSupportedSocketOption s = action >> return () - | otherwise = return () - --- | Set a socket option that expects an Int value. --- There is currently no API to set e.g. the timeval socket options +-- | Set a socket option that expects an 'Int' value. setSocketOption :: Socket -> SocketOption -- Option Name -> Int -- Option Value @@ -364,6 +389,8 @@ let arg = if v == 0 then StructLinger 0 0 else StructLinger 1 (fromIntegral v) setSockOpt s so arg #endif +setSocketOption s so@RecvTimeOut v = setSockOpt s so $ SocketTimeout $ fromIntegral v +setSocketOption s so@SendTimeOut v = setSockOpt s so $ SocketTimeout $ fromIntegral v setSocketOption s sa v = setSockOpt s sa (fromIntegral v :: CInt) -- | Set a socket option. @@ -379,8 +406,9 @@ throwSocketErrorIfMinus1_ "Network.Socket.setSockOpt" $ c_setsockopt fd level opt ptr sz --- | Get a socket option that gives an Int value. --- There is currently no API to get e.g. the timeval socket options +---------------------------------------------------------------- + +-- | Get a socket option that gives an 'Int' value. getSocketOption :: Socket -> SocketOption -- Option Name -> IO Int -- Option Value @@ -389,6 +417,12 @@ StructLinger onoff linger <- getSockOpt s so return $ fromIntegral $ if onoff == 0 then 0 else linger #endif +getSocketOption s so@RecvTimeOut = do + SocketTimeout to <- getSockOpt s so + return $ fromIntegral to +getSocketOption s so@SendTimeOut = do + SocketTimeout to <- getSockOpt s so + return $ fromIntegral to getSocketOption s so = do n :: CInt <- getSockOpt s so return $ fromIntegral n @@ -396,8 +430,8 @@ -- | Get a socket option. getSockOpt :: forall a . Storable a => Socket - -> SocketOption -- Option Name - -> IO a -- Option Value + -> SocketOption -- Option Name + -> IO a -- Option Value getSockOpt s (SockOpt level opt) = do alloca $ \ptr -> do let sz = fromIntegral $ sizeOf (undefined :: a) @@ -406,56 +440,75 @@ c_getsockopt fd level opt ptr ptr_sz peek ptr +---------------------------------------------------------------- -socketOptionBijection :: Bijection SocketOption String -socketOptionBijection = - [ (UnsupportedSocketOption, "UnsupportedSocketOption") - , (Debug, "Debug") - , (ReuseAddr, "ReuseAddr") - , (SoDomain, "SoDomain") - , (Type, "Type") - , (SoProtocol, "SoProtocol") - , (SoError, "SoError") - , (DontRoute, "DontRoute") - , (Broadcast, "Broadcast") - , (SendBuffer, "SendBuffer") - , (RecvBuffer, "RecvBuffer") - , (KeepAlive, "KeepAlive") - , (OOBInline, "OOBInline") - , (Linger, "Linger") - , (ReusePort, "ReusePort") - , (RecvLowWater, "RecvLowWater") - , (SendLowWater, "SendLowWater") - , (RecvTimeOut, "RecvTimeOut") - , (SendTimeOut, "SendTimeOut") - , (UseLoopBack, "UseLoopBack") - , (MaxSegment, "MaxSegment") - , (NoDelay, "NoDelay") - , (UserTimeout, "UserTimeout") - , (Cork, "Cork") - , (TimeToLive, "TimeToLive") - , (RecvIPv4TTL, "RecvIPv4TTL") - , (RecvIPv4TOS, "RecvIPv4TOS") - , (RecvIPv4PktInfo, "RecvIPv4PktInfo") - , (IPv6Only, "IPv6Only") - , (RecvIPv6HopLimit, "RecvIPv6HopLimit") - , (RecvIPv6TClass, "RecvIPv6TClass") - , (RecvIPv6PktInfo, "RecvIPv6PktInfo") - ] +-- | Get the 'SocketType' of an active socket. +-- +-- Since: 3.0.1.0 +getSocketType :: Socket -> IO SocketType +getSocketType s = unpackSocketType <$> getSockOpt s Type -instance Show SocketOption where - showsPrec = bijectiveShow socketOptionBijection def - where - defname = "SockOpt" - unwrap = \(CustomSockOpt nm) -> nm - def = defShow defname unwrap showIntInt +---------------------------------------------------------------- +#if __GLASGOW_HASKELL__ >= 806 +{-# COMPLETE CustomSockOpt #-} +#endif +#ifdef SO_LINGER +-- | Low level 'SO_LINBER' option value, which can be used with 'setSockOpt'. +-- +data StructLinger = StructLinger { + -- | Set the linger option on. + sl_onoff :: CInt, -instance Read SocketOption where - readPrec = bijectiveRead socketOptionBijection def - where - defname = "SockOpt" - def = defRead defname CustomSockOpt readIntInt + -- | Linger timeout. + sl_linger :: CInt + } + deriving (Eq, Ord, Show) + +instance Storable StructLinger where + sizeOf _ = (#const sizeof(struct linger)) + alignment _ = alignment (0 :: CInt) + + peek p = do + onoff <- (#peek struct linger, l_onoff) p + linger <- (#peek struct linger, l_linger) p + return $ StructLinger onoff linger + + poke p (StructLinger onoff linger) = do + (#poke struct linger, l_onoff) p onoff + (#poke struct linger, l_linger) p linger +#endif + +---------------------------------------------------------------- + +-- | Timeout in microseconds. +-- This will be converted into struct timeval on Unix and +-- DWORD (as milliseconds) on Windows. +newtype SocketTimeout = SocketTimeout Word32 deriving (Eq, Ord, Show) + +#if defined(mingw32_HOST_OS) +instance Storable SocketTimeout where + sizeOf (SocketTimeout to) = sizeOf to -- DWORD as milliseconds + alignment _ = 0 + peek ptr = do + to <- peek (castPtr ptr) + return $ SocketTimeout (to * 1000) + poke ptr (SocketTimeout to) = poke (castPtr ptr) (to `div` 1000) +#else +instance Storable SocketTimeout where + sizeOf _ = (#size struct timeval) + alignment _ = (#const offsetof(struct {char x__; struct timeval (y__); }, y__)) + peek ptr = do + sec <- (#peek struct timeval, tv_sec) ptr + usec <- (#peek struct timeval, tv_usec) ptr + return $ SocketTimeout (sec * 1000000 + usec) + poke ptr (SocketTimeout to) = do + let (sec, usec) = to `divMod` 1000000 + (#poke struct timeval, tv_sec) ptr sec + (#poke struct timeval, tv_usec) ptr usec +#endif + +---------------------------------------------------------------- foreign import CALLCONV unsafe "getsockopt" c_getsockopt :: CInt -> CInt -> CInt -> Ptr a -> Ptr CInt -> IO CInt diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/network-3.1.2.8/Network/Socket/Types.hsc new/network-3.1.4.0/Network/Socket/Types.hsc --- old/network-3.1.2.8/Network/Socket/Types.hsc 2001-09-09 03:46:40.000000000 +0200 +++ new/network-3.1.4.0/Network/Socket/Types.hsc 2001-09-09 03:46:40.000000000 +0200 @@ -93,9 +93,7 @@ import qualified Text.Read as P -#if defined(DOMAIN_SOCKET_SUPPORT) import Foreign.Marshal.Array -#endif import Network.Socket.Imports @@ -1075,11 +1073,7 @@ isSupportedSockAddr addr = case addr of SockAddrInet{} -> True SockAddrInet6{} -> True -#if defined(DOMAIN_SOCKET_SUPPORT) SockAddrUnix{} -> True -#else - SockAddrUnix{} -> False -#endif instance SocketAddress SockAddr where sizeOfSocketAddress = sizeOfSockAddr @@ -1098,7 +1092,6 @@ -- 'SockAddr'. This function differs from 'Foreign.Storable.sizeOf' -- in that the value of the argument /is/ used. sizeOfSockAddr :: SockAddr -> Int -#if defined(DOMAIN_SOCKET_SUPPORT) # ifdef linux_HOST_OS -- http://man7.org/linux/man-pages/man7/unix.7.html says: -- "an abstract socket address is distinguished (from a @@ -1118,9 +1111,6 @@ # else sizeOfSockAddr SockAddrUnix{} = #const sizeof(struct sockaddr_un) # endif -#else -sizeOfSockAddr SockAddrUnix{} = error "sizeOfSockAddr: not supported" -#endif sizeOfSockAddr SockAddrInet{} = #const sizeof(struct sockaddr_in) sizeOfSockAddr SockAddrInet6{} = #const sizeof(struct sockaddr_in6) @@ -1135,10 +1125,8 @@ -- structure, and attempting to do so could overflow the allocated storage -- space. This constant holds the maximum allowable path length. -- -#if defined(DOMAIN_SOCKET_SUPPORT) unixPathMax :: Int unixPathMax = #const sizeof(((struct sockaddr_un *)NULL)->sun_path) -#endif -- We can't write an instance of 'Storable' for 'SockAddr' because -- @sockaddr@ is a sum type of variable size but @@ -1149,9 +1137,10 @@ -- | Write the given 'SockAddr' to the given memory location. pokeSockAddr :: Ptr a -> SockAddr -> IO () -#if defined(DOMAIN_SOCKET_SUPPORT) pokeSockAddr p sa@(SockAddrUnix path) = do - when (length path > unixPathMax) $ error "pokeSockAddr: path is too long" + when (length path > unixPathMax) $ error + $ "pokeSockAddr: path is too long in SockAddrUnix " <> show path + <> ", length " <> show (length path) <> ", unixPathMax " <> show unixPathMax zeroMemory p $ fromIntegral $ sizeOfSockAddr sa # if defined(HAVE_STRUCT_SOCKADDR_SA_LEN) (#poke struct sockaddr_un, sun_len) p ((#const sizeof(struct sockaddr_un)) :: Word8) @@ -1160,9 +1149,6 @@ let pathC = map castCharToCChar path -- the buffer is already filled with nulls. pokeArray ((#ptr struct sockaddr_un, sun_path) p) pathC -#else -pokeSockAddr _ SockAddrUnix{} = error "pokeSockAddr: not supported" -#endif pokeSockAddr p (SockAddrInet port addr) = do zeroMemory p (#const sizeof(struct sockaddr_in)) #if defined(HAVE_STRUCT_SOCKADDR_SA_LEN) @@ -1187,11 +1173,9 @@ peekSockAddr p = do family <- (#peek struct sockaddr, sa_family) p case family :: CSaFamily of -#if defined(DOMAIN_SOCKET_SUPPORT) (#const AF_UNIX) -> do str <- peekCAString ((#ptr struct sockaddr_un, sun_path) p) return (SockAddrUnix str) -#endif (#const AF_INET) -> do addr <- (#peek struct sockaddr_in, sin_addr) p port <- (#peek struct sockaddr_in, sin_port) p @@ -1318,7 +1302,7 @@ socktypeBijection = [ (UnsupportedSocketType, "UnsupportedSocketType") , (Stream, "Stream") - , (Datagram, "Datagram") + , (Datagram, "Datagram") , (Raw, "Raw") , (RDM, "RDM") , (SeqPacket, "SeqPacket") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/network-3.1.2.8/Network/Socket/Unix.hsc new/network-3.1.4.0/Network/Socket/Unix.hsc --- old/network-3.1.2.8/Network/Socket/Unix.hsc 2001-09-09 03:46:40.000000000 +0200 +++ new/network-3.1.4.0/Network/Socket/Unix.hsc 2001-09-09 03:46:40.000000000 +0200 @@ -1,4 +1,5 @@ {-# LANGUAGE CPP #-} +{-# LANGUAGE ScopedTypeVariables #-} #include "HsNet.h" ##include "HsNetDef.h" @@ -13,14 +14,24 @@ , getPeerEid ) where -import System.Posix.Types (Fd(..)) - +import Foreign.Marshal.Alloc (allocaBytes) import Network.Socket.Buffer +import Network.Socket.Fcntl import Network.Socket.Imports -#if !defined(mingw32_HOST_OS) +import Network.Socket.Types +import System.Posix.Types (Fd(..)) + +#if defined(mingw32_HOST_OS) +import Network.Socket.Syscall +import Network.Socket.Win32.Cmsg +import System.Directory +import System.IO +import System.IO.Temp +#else +import Foreign.Marshal.Array (peekArray) +import Network.Socket.Internal import Network.Socket.Posix.Cmsg #endif -import Network.Socket.Types #if defined(HAVE_GETPEEREID) import System.IO.Error (catchIOError) @@ -28,13 +39,7 @@ #ifdef HAVE_GETPEEREID import Foreign.Marshal.Alloc (alloca) #endif -#ifdef DOMAIN_SOCKET_SUPPORT -import Foreign.Marshal.Alloc (allocaBytes) -import Foreign.Marshal.Array (peekArray) -import Network.Socket.Fcntl -import Network.Socket.Internal -#endif #ifdef HAVE_STRUCT_UCRED_SO_PEERCRED import Network.Socket.Options #endif @@ -121,14 +126,12 @@ {-# Deprecated getPeerEid "Use getPeerCredential instead" #-} -- | Whether or not UNIX-domain sockets are available. +-- 'AF_UNIX' is supported on Windows since 3.1.3.0. +-- So, this variable is 'True` on all platforms. -- -- Since 2.7.0.0. isUnixDomainSocketAvailable :: Bool -#if defined(DOMAIN_SOCKET_SUPPORT) isUnixDomainSocketAvailable = True -#else -isUnixDomainSocketAvailable = False -#endif data NullSockAddr = NullSockAddr @@ -138,26 +141,19 @@ pokeSocketAddress _ _ = return () -- | Send a file descriptor over a UNIX-domain socket. --- Use this function in the case where 'isUnixDomainSocketAvailable' is --- 'True'. +-- This function does not work on Windows. sendFd :: Socket -> CInt -> IO () -#if defined(DOMAIN_SOCKET_SUPPORT) sendFd s outfd = void $ allocaBytes dummyBufSize $ \buf -> do let cmsg = encodeCmsg $ Fd outfd sendBufMsg s NullSockAddr [(buf,dummyBufSize)] [cmsg] mempty where dummyBufSize = 1 -#else -sendFd _ _ = error "Network.Socket.sendFd" -#endif -- | Receive a file descriptor over a UNIX-domain socket. Note that the resulting -- file descriptor may have to be put into non-blocking mode in order to be -- used safely. See 'setNonBlockIfNeeded'. --- Use this function in the case where 'isUnixDomainSocketAvailable' is --- 'True'. +-- This function does not work on Windows. recvFd :: Socket -> IO CInt -#if defined(DOMAIN_SOCKET_SUPPORT) recvFd s = allocaBytes dummyBufSize $ \buf -> do (NullSockAddr, _, cmsgs, _) <- recvBufMsg s [(buf,dummyBufSize)] 32 mempty case (lookupCmsg CmsgIdFd cmsgs >>= decodeCmsg) :: Maybe Fd of @@ -165,19 +161,29 @@ Just (Fd fd) -> return fd where dummyBufSize = 16 -#else -recvFd _ = error "Network.Socket.recvFd" -#endif -- | Build a pair of connected socket objects. --- For portability, use this function in the case --- where 'isUnixDomainSocketAvailable' is 'True' --- and specify 'AF_UNIX' to the first argument. +-- On Windows, this function emulates socketpair() using +-- 'AF_UNIX' and a temporary file will remain. socketPair :: Family -- Family Name (usually AF_UNIX) -> SocketType -- Socket Type (usually Stream) -> ProtocolNumber -- Protocol Number -> IO (Socket, Socket) -- unnamed and connected. -#if defined(DOMAIN_SOCKET_SUPPORT) +#if defined(mingw32_HOST_OS) +socketPair _ _ _ = withSystemTempFile "temp-for-pair" $ \file hdl -> do + hClose hdl + removeFile file + listenSock <- socket AF_UNIX Stream defaultProtocol + bind listenSock $ SockAddrUnix file + listen listenSock 10 + clientSock <- socket AF_UNIX Stream defaultProtocol + connect clientSock $ SockAddrUnix file + (serverSock, _ :: SockAddr) <- accept listenSock + close listenSock + withFdSocket clientSock setNonBlockIfNeeded + withFdSocket serverSock setNonBlockIfNeeded + return (clientSock, serverSock) +#else socketPair family stype protocol = allocaBytes (2 * sizeOf (1 :: CInt)) $ \ fdArr -> do let c_stype = packSocketType stype @@ -192,6 +198,4 @@ foreign import ccall unsafe "socketpair" c_socketpair :: CInt -> CInt -> CInt -> Ptr CInt -> IO CInt -#else -socketPair _ _ _ = error "Network.Socket.socketPair" #endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/network-3.1.2.8/Network/Socket/Win32/Cmsg.hsc new/network-3.1.4.0/Network/Socket/Win32/Cmsg.hsc --- old/network-3.1.2.8/Network/Socket/Win32/Cmsg.hsc 2001-09-09 03:46:40.000000000 +0200 +++ new/network-3.1.4.0/Network/Socket/Win32/Cmsg.hsc 2001-09-09 03:46:40.000000000 +0200 @@ -12,6 +12,7 @@ #include "HsNet.h" import Data.ByteString.Internal +import System.Posix.Types (Fd(..)) import Foreign.ForeignPtr import System.IO.Unsafe (unsafeDupablePerformIO) @@ -191,6 +192,9 @@ n :: ULONG <- (#peek IN6_PKTINFO, ipi6_ifindex) p return $ IPv6PktInfo (fromIntegral n) ha6 +instance ControlMessage Fd where + controlMessageId = CmsgIdFd + cmsgIdBijection :: Bijection CmsgId String cmsgIdBijection = [ (UnsupportedCmsgId, "UnsupportedCmsgId") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/network-3.1.2.8/Network/Socket.hs new/network-3.1.4.0/Network/Socket.hs --- old/network-3.1.2.8/Network/Socket.hs 2001-09-09 03:46:40.000000000 +0200 +++ new/network-3.1.4.0/Network/Socket.hs 2001-09-09 03:46:40.000000000 +0200 @@ -143,6 +143,7 @@ ,RecvIPv4TTL,RecvIPv4TOS,RecvIPv4PktInfo ,RecvIPv6HopLimit,RecvIPv6TClass,RecvIPv6PktInfo) , StructLinger (..) + , SocketTimeout (..) , isSupportedSocketOption , whenSupported , getSocketOption diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/network-3.1.2.8/configure new/network-3.1.4.0/configure --- old/network-3.1.2.8/configure 2001-09-09 03:46:40.000000000 +0200 +++ new/network-3.1.4.0/configure 2001-09-09 03:46:40.000000000 +0200 @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for Haskell network package 3.1.2.8. +# Generated by GNU Autoconf 2.69 for Haskell network package 3.1.4.0. # # Report bugs to <[email protected]>. # @@ -580,8 +580,8 @@ # Identity of this package. PACKAGE_NAME='Haskell network package' PACKAGE_TARNAME='network' -PACKAGE_VERSION='3.1.2.8' -PACKAGE_STRING='Haskell network package 3.1.2.8' +PACKAGE_VERSION='3.1.4.0' +PACKAGE_STRING='Haskell network package 3.1.4.0' PACKAGE_BUGREPORT='[email protected]' PACKAGE_URL='' @@ -1234,7 +1234,7 @@ # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures Haskell network package 3.1.2.8 to adapt to many kinds of systems. +\`configure' configures Haskell network package 3.1.4.0 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1299,7 +1299,7 @@ if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of Haskell network package 3.1.2.8:";; + short | recursive ) echo "Configuration of Haskell network package 3.1.4.0:";; esac cat <<\_ACEOF @@ -1384,7 +1384,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -Haskell network package configure 3.1.2.8 +Haskell network package configure 3.1.4.0 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -1910,7 +1910,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by Haskell network package $as_me 3.1.2.8, which was +It was created by Haskell network package $as_me 3.1.4.0, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2259,7 +2259,9 @@ -ac_includes_default="#define _GNU_SOURCE 1 /* for struct ucred on Linux */ +ac_includes_default="#ifndef _WIN32 +# define _GNU_SOURCE 1 /* for struct ucred on Linux */ +#endif $ac_includes_default #ifdef _WIN32 @@ -4417,7 +4419,7 @@ # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by Haskell network package $as_me 3.1.2.8, which was +This file was extended by Haskell network package $as_me 3.1.4.0, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -4470,7 +4472,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -Haskell network package config.status 3.1.2.8 +Haskell network package config.status 3.1.4.0 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/network-3.1.2.8/configure.ac new/network-3.1.4.0/configure.ac --- old/network-3.1.2.8/configure.ac 2001-09-09 03:46:40.000000000 +0200 +++ new/network-3.1.4.0/configure.ac 2001-09-09 03:46:40.000000000 +0200 @@ -1,10 +1,12 @@ AC_INIT([Haskell network package], - [3.1.2.8], + [3.1.4.0], [[email protected]], [network]) dnl See also HsNet.h -ac_includes_default="#define _GNU_SOURCE 1 /* for struct ucred on Linux */ +ac_includes_default="#ifndef _WIN32 +# define _GNU_SOURCE 1 /* for struct ucred on Linux */ +#endif $ac_includes_default #ifdef _WIN32 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/network-3.1.2.8/include/HsNet.h new/network-3.1.4.0/include/HsNet.h --- old/network-3.1.2.8/include/HsNet.h 2001-09-09 03:46:40.000000000 +0200 +++ new/network-3.1.4.0/include/HsNet.h 2001-09-09 03:46:40.000000000 +0200 @@ -19,7 +19,9 @@ # endif #endif -#define _GNU_SOURCE 1 /* for struct ucred on Linux */ +#ifndef _WIN32 +# define _GNU_SOURCE 1 /* for struct ucred on Linux */ +#endif #define __APPLE_USE_RFC_3542 1 /* for IPV6_RECVPKTINFO */ #ifdef _WIN32 @@ -27,6 +29,7 @@ # include <ws2tcpip.h> # include <mswsock.h> # include "win32defs.h" +# include "afunix_compat.h" # define IPV6_V6ONLY 27 #endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/network-3.1.2.8/include/HsNetDef.h new/network-3.1.4.0/include/HsNetDef.h --- old/network-3.1.2.8/include/HsNetDef.h 2001-09-09 03:46:40.000000000 +0200 +++ new/network-3.1.4.0/include/HsNetDef.h 2001-09-09 03:46:40.000000000 +0200 @@ -10,10 +10,6 @@ #undef PACKAGE_TARNAME #undef PACKAGE_VERSION -#if !defined(mingw32_HOST_OS) && !defined(_WIN32) -# define DOMAIN_SOCKET_SUPPORT 1 -#endif - #if defined(HAVE_STRUCT_UCRED) && HAVE_DECL_SO_PEERCRED # define HAVE_STRUCT_UCRED_SO_PEERCRED 1 #else diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/network-3.1.2.8/include/afunix_compat.h new/network-3.1.4.0/include/afunix_compat.h --- old/network-3.1.2.8/include/afunix_compat.h 1970-01-01 01:00:00.000000000 +0100 +++ new/network-3.1.4.0/include/afunix_compat.h 2001-09-09 03:46:40.000000000 +0200 @@ -0,0 +1,23 @@ +/* The version of afunix.h provided by the version of MSYS2 included with x86 + * versions of GHC before GHC 9.2 excludes certain components introduced with + * Windows Vista. + */ + +#ifndef AFUNIX_COMPAT_H +#define AFUNIX_COMPAT_H + +#if defined(_AFUNIX_) || !defined(_WIN32) || __GLASGOW_HASKELL__ > 902 +# include <afunix.h> +#else + +#define UNIX_PATH_MAX 108 + +typedef struct sockaddr_un { + ADDRESS_FAMILY sun_family; + char sun_path[UNIX_PATH_MAX]; +} SOCKADDR_UN, *PSOCKADDR_UN; + +#define SIO_AF_UNIX_GETPEERPID _WSAIOR(IOC_VENDOR, 256) + +#endif /* GHC version check */ +#endif /* AFUNIX_COMPAT_H */ \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/network-3.1.2.8/network.cabal new/network-3.1.4.0/network.cabal --- old/network-3.1.2.8/network.cabal 2001-09-09 03:46:40.000000000 +0200 +++ new/network-3.1.4.0/network.cabal 2001-09-09 03:46:40.000000000 +0200 @@ -1,174 +1,202 @@ -cabal-version: 1.18 -name: network -version: 3.1.2.8 -license: BSD3 -license-file: LICENSE -maintainer: Kazu Yamamoto, Evan Borden -synopsis: Low-level networking interface +cabal-version: 1.18 +name: network +version: 3.1.4.0 +license: BSD3 +license-file: LICENSE +maintainer: Kazu Yamamoto, Evan Borden + +tested-with: + GHC == 9.6.1 + GHC == 9.4.4 + GHC == 9.2.7 + GHC == 9.0.2 + GHC == 8.10.7 + GHC == 8.8.4 + GHC == 8.6.5 + GHC == 8.4.4 + GHC == 8.2.2 + GHC == 8.0.2 + +homepage: https://github.com/haskell/network +bug-reports: https://github.com/haskell/network/issues +synopsis: Low-level networking interface description: - This package provides a low-level networking interface. - . - === High-Level Packages - Other packages provide higher level interfaces: - . - * connection - * hookup - * network-simple - . - === Extended Packages - @network@ seeks to provide a cross-platform core for networking. As such some - APIs live in extended libraries. Packages in the @network@ ecosystem are - often prefixed with @network-@. - . - ==== @network-bsd@ - In @network-3.0.0.0@ the @Network.BSD@ module was split off into its own - package, @network-bsd-3.0.0.0@. - . - ==== @network-uri@ - In @network-2.6@ the @Network.URI@ module was split off into its own package, - @network-uri-2.6@. If you're using the @Network.URI@ module you can - automatically get it from the right package by adding this to your @.cabal@ - file: - . - > library - > build-depends: network-uri-flag -category: Network -build-type: Configure -extra-tmp-files: - config.log config.status autom4te.cache network.buildinfo - include/HsNetworkConfig.h + This package provides a low-level networking interface. + . + === High-Level Packages + Other packages provide higher level interfaces: + . + * connection + * hookup + * network-simple + . + === Extended Packages + @network@ seeks to provide a cross-platform core for networking. As such some + APIs live in extended libraries. Packages in the @network@ ecosystem are + often prefixed with @network-@. + . + ==== @network-bsd@ + In @network-3.0.0.0@ the @Network.BSD@ module was split off into its own + package, @network-bsd-3.0.0.0@. + . + ==== @network-uri@ + In @network-2.6@ the @Network.URI@ module was split off into its own package, + @network-uri-2.6@. If you're using the @Network.URI@ module you can + automatically get it from the right package by adding this to your @.cabal@ + file: + . + > library + > build-depends: network-uri-flag + +category: Network +build-type: Configure + +extra-doc-files: + README.md + CHANGELOG.md + extra-source-files: - README.md CHANGELOG.md - examples/*.hs tests/*.hs config.guess config.sub install-sh - configure.ac configure - include/HsNetworkConfig.h.in include/HsNet.h include/HsNetDef.h - -- C sources only used on some systems - cbits/asyncAccept.c cbits/initWinSock.c - cbits/winSockErr.c cbits/cmsg.c -homepage: https://github.com/haskell/network -bug-reports: https://github.com/haskell/network/issues -tested-with: GHC == 8.0.2 - , GHC == 8.2.2 - , GHC == 8.4.4 - , GHC == 8.6.5 - , GHC == 8.8.3 - , GHC == 8.10.1 + examples/*.hs + tests/*.hs + config.guess + config.sub + install-sh + configure.ac + configure + include/HsNetworkConfig.h.in + include/HsNet.h + include/HsNetDef.h + include/afunix_compat.h + cbits/asyncAccept.c + cbits/initWinSock.c + cbits/winSockErr.c + cbits/cmsg.c + +extra-tmp-files: + config.log + config.status + autom4te.cache + network.buildinfo + include/HsNetworkConfig.h + +source-repository head + type: git + location: https://github.com/haskell/network.git flag devel - description: using tests for developers - default: False + description: using tests for developers + default: False library - default-language: Haskell2010 - exposed-modules: - Network.Socket - Network.Socket.Address - Network.Socket.ByteString - Network.Socket.ByteString.Lazy - Network.Socket.Internal - other-modules: - Network.Socket.Buffer - Network.Socket.ByteString.IO - Network.Socket.ByteString.Internal - Network.Socket.Cbits - Network.Socket.Fcntl - Network.Socket.Flag - Network.Socket.Handle - Network.Socket.If - Network.Socket.Imports - Network.Socket.Info - Network.Socket.Name - Network.Socket.Options - Network.Socket.ReadShow - Network.Socket.Shutdown - Network.Socket.SockAddr - Network.Socket.Syscall - Network.Socket.Types - Network.Socket.Unix - - build-depends: - base >= 4.9 && < 5, - bytestring >= 0.10 && < 0.12, - deepseq, - directory - - include-dirs: include - includes: HsNet.h HsNetDef.h alignment.h win32defs.h - install-includes: HsNet.h HsNetDef.h alignment.h win32defs.h - c-sources: cbits/HsNet.c cbits/cmsg.c - ghc-options: -Wall -fwarn-tabs - build-tools: hsc2hs + exposed-modules: + Network.Socket + Network.Socket.Address + Network.Socket.ByteString + Network.Socket.ByteString.Lazy + Network.Socket.Internal + + build-tools: hsc2hs >=0 + c-sources: + cbits/HsNet.c + cbits/cmsg.c - - -- Add some platform specific stuff - if !os(windows) other-modules: - Network.Socket.ByteString.Lazy.Posix - Network.Socket.Posix.Cmsg - Network.Socket.Posix.CmsgHdr - Network.Socket.Posix.IOVec - Network.Socket.Posix.MsgHdr - - if os(solaris) - extra-libraries: nsl, socket - cpp-options: -D__EXTENSIONS__ -D_XOPEN_SOURCE=500 - cc-options: -D__EXTENSIONS__ -D_XOPEN_SOURCE=500 + Network.Socket.Buffer + Network.Socket.ByteString.IO + Network.Socket.ByteString.Internal + Network.Socket.Cbits + Network.Socket.Fcntl + Network.Socket.Flag + Network.Socket.Handle + Network.Socket.If + Network.Socket.Imports + Network.Socket.Info + Network.Socket.Name + Network.Socket.Options + Network.Socket.ReadShow + Network.Socket.Shutdown + Network.Socket.SockAddr + Network.Socket.Syscall + Network.Socket.Types + Network.Socket.Unix + + default-language: Haskell2010 + include-dirs: include + includes: HsNet.h HsNetDef.h alignment.h win32defs.h + install-includes: HsNet.h HsNetDef.h alignment.h win32defs.h + if os(windows) + includes: afunix_compat.h + install-includes: afunix_compat.h + + ghc-options: -Wall -fwarn-tabs + build-depends: + base >=4.9 && <5, + bytestring >=0.10 && <0.12, + deepseq, + directory + + if !os(windows) + other-modules: + Network.Socket.ByteString.Lazy.Posix + Network.Socket.Posix.Cmsg + Network.Socket.Posix.CmsgHdr + Network.Socket.Posix.IOVec + Network.Socket.Posix.MsgHdr + + if os(solaris) + cpp-options: -D__EXTENSIONS__ -D_XOPEN_SOURCE=500 + cc-options: -D__EXTENSIONS__ -D_XOPEN_SOURCE=500 + extra-libraries: + nsl + socket + + if os(windows) + c-sources: + cbits/initWinSock.c + cbits/winSockErr.c + cbits/asyncAccept.c + + other-modules: + Network.Socket.ByteString.Lazy.Windows + Network.Socket.Win32.Cmsg + Network.Socket.Win32.CmsgHdr + Network.Socket.Win32.WSABuf + Network.Socket.Win32.MsgHdr + + extra-libraries: + ws2_32 + iphlpapi + mswsock + + if impl(ghc >=7.10) + cpp-options: -D_WIN32_WINNT=0x0600 + cc-options: -D_WIN32_WINNT=0x0600 - if os(windows) - other-modules: - Network.Socket.ByteString.Lazy.Windows - Network.Socket.Win32.Cmsg - Network.Socket.Win32.CmsgHdr - Network.Socket.Win32.WSABuf - Network.Socket.Win32.MsgHdr - c-sources: cbits/initWinSock.c, cbits/winSockErr.c, cbits/asyncAccept.c - extra-libraries: ws2_32, iphlpapi, mswsock - -- See https://github.com/haskell/network/pull/362 - if impl(ghc >= 7.10) - cpp-options: -D_WIN32_WINNT=0x0600 - cc-options: -D_WIN32_WINNT=0x0600 + build-depends: + temporary test-suite spec - default-language: Haskell2010 - hs-source-dirs: tests - main-is: Spec.hs - if flag(devel) - cpp-options: -DDEVELOPMENT - other-modules: - Network.Test.Common - Network.SocketSpec - Network.Socket.ByteStringSpec - Network.Socket.ByteString.LazySpec - type: exitcode-stdio-1.0 - ghc-options: -Wall -threaded - -- NB: make sure to versions of hspec and hspec-discover - -- that work together; easiest way is to constraint - -- both packages to a small enough version range. - build-tools: hspec-discover >= 2.6 - build-depends: - base >= 4.9 && < 5, - bytestring, - directory, - HUnit, - network, - temporary, - hspec >= 2.6, - QuickCheck - -test-suite doctests - buildable: False - default-language: Haskell2010 - hs-source-dirs: tests - main-is: doctests.hs - type: exitcode-stdio-1.0 - - build-depends: - base >= 4.9 && < 5, - doctest >= 0.10.1, - network - - ghc-options: -Wall + type: exitcode-stdio-1.0 + main-is: Spec.hs + build-tools: hspec-discover >=2.6 + hs-source-dirs: tests + other-modules: + Network.Test.Common + Network.SocketSpec + Network.Socket.ByteStringSpec + Network.Socket.ByteString.LazySpec + + default-language: Haskell2010 + ghc-options: -Wall -threaded + build-depends: + base >=4.9 && <5, + bytestring, + directory, + HUnit, + network, + temporary, + hspec >=2.6, + QuickCheck -source-repository head - type: git - location: git://github.com/haskell/network.git + if flag(devel) + cpp-options: -DDEVELOPMENT diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/network-3.1.2.8/tests/Network/SocketSpec.hs new/network-3.1.4.0/tests/Network/SocketSpec.hs --- old/network-3.1.2.8/tests/Network/SocketSpec.hs 2001-09-09 03:46:40.000000000 +0200 +++ new/network-3.1.4.0/tests/Network/SocketSpec.hs 2001-09-09 03:46:40.000000000 +0200 @@ -12,7 +12,7 @@ import Network.Socket.ByteString import Network.Test.Common import System.Mem (performGC) -import System.IO.Error (tryIOError, isAlreadyInUseError) +import System.IO.Error (tryIOError) import System.IO.Temp (withSystemTempDirectory) import Foreign.C.Types () @@ -70,9 +70,12 @@ bind sock (addrAddress addr) `shouldThrow` anyIOException #endif - it "successfully binds to a unix socket, twice" $ do + it "successfully binds to a unix socket" $ do withSystemTempDirectory "haskell-network" $ \path -> do let sfile = path ++ "/socket-file" + -- exist <- doesFileExist sfile + -- when exist $ removeFile sfile + -- removeFile sfile let addr = SockAddrUnix sfile when (isSupportedSockAddr addr) $ do sock0 <- socket AF_UNIX Stream defaultProtocol @@ -82,23 +85,10 @@ sock1 <- socket AF_UNIX Stream defaultProtocol tryIOError (bind sock1 addr) >>= \o -> case o of Right () -> error "bind should have failed but succeeded" - Left e | not (isAlreadyInUseError e) -> ioError e - _ -> return () + _ -> return () close sock0 - - -- Unix systems tend to leave the file existing, which is - -- why our `bind` does its workaround. however if any - -- system in the future does fix this issue, we don't want - -- this test to fail, since that would defeat the purpose - -- of our workaround. but you can uncomment the below lines - -- if you want to play with this on your own system. - --import System.Directory (doesPathExist) - --ex <- doesPathExist sfile - --unless ex $ error "socket file was deleted unexpectedly" - - sock2 <- socket AF_UNIX Stream defaultProtocol - bind sock2 addr + close sock1 describe "UserTimeout" $ do it "can be set" $ do diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/network-3.1.2.8/tests/doctests.hs new/network-3.1.4.0/tests/doctests.hs --- old/network-3.1.2.8/tests/doctests.hs 2001-09-09 03:46:40.000000000 +0200 +++ new/network-3.1.4.0/tests/doctests.hs 1970-01-01 01:00:00.000000000 +0100 @@ -1,15 +0,0 @@ -module Main where - -import Build_doctests (flags, pkgs, module_sources) -import Data.Foldable (traverse_) -import Data.List (isSuffixOf, isPrefixOf) -import Test.DocTest (doctest) - -main :: IO () -main = do - traverse_ putStrLn args - doctest args - where - builddir = filter ("build" `isSuffixOf`) $ filter ("-i" `isPrefixOf`) flags - addinc path = "-I" ++ drop 2 path ++ "/include" - args = map addinc builddir ++ flags ++ pkgs ++ module_sources
