packages feed

network 2.7.0.0 → 2.7.0.1

raw patch · 14 files changed

+130/−69 lines, 14 filesdep ~bytestringPVP: minor bump suggested

API additions: PVP suggests at least a minor version bump

Dependency ranges changed: bytestring

API changes (from Hackage documentation)

+ Network.Socket: socketPortSafe :: Socket -> IO (Maybe PortNumber)

Files

CHANGELOG.md view
@@ -1,4 +1,16 @@+## Version 2.7.0.1++ * A new API: socketPortSafe.+   [#319](https://github.com/haskell/network/pull/319)+ * Fixing a drain bug of sendAll.+   [#320](https://github.com/haskell/network/pull/320)+ * Porting the new CALLCONV convention from master.+   [#313](https://github.com/haskell/network/pull/313)+ * Withdrawing the deprecations of packFamily and unpackFamily.+   [#324](https://github.com/haskell/network/pull/324)+ ## Version 2.7.0.0+  * Obsoleting the Network module.  * Obsoleting the Network.BSD module.  * Obsoleting APIs: MkSocket, htonl, ntohl,@@ -7,9 +19,9 @@               inet_addr, inet_ntoa,               isConnected, isBound, isListening, isReadable, isWritable,               aNY_PORT, iNADDR_ANY, iN6ADDR_ANY, sOMAXCONN,-	      sOL_SOCKET, sCM_RIGHTS,+              sOL_SOCKET, sCM_RIGHTS,               packFamily, unpackFamily, packSocketType- * Do not closeFd within sendFd+ * Do not closeFd within sendFd.    [#271](https://github.com/haskell/network/pull/271)  * Exporting ifNameToIndex and ifIndexToName from Network.Socket.  * New APIs: setCloseOnExecIfNeeded, getCloseOnExec and getNonBlock@@ -17,6 +29,7 @@  * socketPair, sendFd and recvFd are exported even on Windows.  ## Version 2.6.3.5+  * Reverting "Do not closeFd within sendFd"    [#271](https://github.com/haskell/network/pull/271) 
Network/BSD.hsc view
@@ -17,6 +17,7 @@ -----------------------------------------------------------------------------  #include "HsNet.h"+##include "HsNetDef.h"  module Network.BSD  {-# DEPRECATED "This platform dependent module is no longer supported." #-}     (
Network/Socket.hsc view
@@ -91,8 +91,7 @@ -----------------------------------------------------------------------------  #include "HsNet.h"---- In order to process this file, you need to have CALLCONV defined.+##include "HsNetDef.h"  module Network.Socket     (@@ -163,6 +162,7 @@     -- ** Port number     , PortNumber(..)     , defaultPort+    , socketPortSafe     , socketPort     -- * UNIX-domain socket     , isUnixDomainSocketAvailable@@ -338,10 +338,6 @@    withSocketsDo $ return ()    return $ MkSocket fd fam sType pNum mStat --- | Obtaining the file descriptor from a socket.-fdSocket :: Socket -> CInt-fdSocket (MkSocket fd _ _ _ _) = fd- -- | This is the default protocol for a given service. defaultProtocol :: ProtocolNumber defaultProtocol = 0@@ -881,6 +877,8 @@ -- determined by calling $port$, is generally only useful when bind -- was given $aNY\_PORT$. +-- | Getting the port of socket.+--   `IOError` is thrown if a port is not available. socketPort :: Socket            -- Connected & Bound Socket            -> IO PortNumber     -- Port Number of Socket socketPort sock@(MkSocket _ AF_INET _ _ _) = do@@ -898,6 +896,20 @@   -- ---------------------------------------------------------------------------+-- socketPortSafe+-- | Getting the port of socket.+socketPortSafe :: Socket                -- Connected & Bound Socket+               -> IO (Maybe PortNumber) -- Port Number of Socket+socketPortSafe s = do+    sa <- getSocketName s+    return $ case sa of+      SockAddrInet port _      -> Just port+#if defined(IPV6_SOCKET_SUPPORT)+      SockAddrInet6 port _ _ _ -> Just port+#endif+      _                        -> Nothing++-- --------------------------------------------------------------------------- -- getPeerName  -- Calling $getPeerName$ returns the address details of the machine,@@ -1345,7 +1357,7 @@ -- ----------------------------------------------------------------------------- -- Internet address manipulation routines: -{-# DEPRECATED inet_addr "Use \"getNameInfo\" instead" #-}+{-# DEPRECATED inet_addr "Use \"getAddrInfo\" instead" #-} inet_addr :: String -> IO HostAddress inet_addr ipstr = withSocketsDo $ do    withCString ipstr $ \str -> do
Network/Socket/ByteString.hsc view
@@ -1,5 +1,6 @@ {-# OPTIONS_GHC -fno-warn-warnings-deprecations #-} {-# LANGUAGE CPP, ForeignFunctionInterface #-}+{-# LANGUAGE OverloadedStrings #-}  #include "HsNet.h" @@ -92,9 +93,11 @@ sendAll :: Socket      -- ^ Connected socket         -> ByteString  -- ^ Data to send         -> IO ()+sendAll _    "" = return () sendAll sock bs = do     sent <- send sock bs-    when (sent < B.length bs) $ sendAll sock (B.drop sent bs)+    waitWhen0 sent sock+    when (sent >= 0) $ sendAll sock $ B.drop sent bs  -- | Send data to the socket.  The recipient can be specified -- explicitly, so the socket need not be in a connected state.@@ -121,9 +124,11 @@           -> ByteString  -- ^ Data to send           -> SockAddr    -- ^ Recipient address           -> IO ()+sendAllTo _    "" _    = return () sendAllTo sock xs addr = do     sent <- sendTo sock xs addr-    when (sent < B.length xs) $ sendAllTo sock (B.drop sent xs) addr+    waitWhen0 sent sock+    when (sent >= 0) $ sendAllTo sock (B.drop sent xs) addr  -- ---------------------------------------------------------------------------- -- ** Vectored I/O@@ -159,9 +164,11 @@          -> [ByteString]  -- ^ Data to send          -> IO () #if !defined(mingw32_HOST_OS)+sendMany _                          [] = return () sendMany sock@(MkSocket fd _ _ _ _) cs = do     sent <- sendManyInner-    when (sent < totalLength cs) $ sendMany sock (remainingChunks sent cs)+    waitWhen0 sent sock+    when (sent >= 0) $ sendMany sock (remainingChunks sent cs)   where     sendManyInner =       liftM fromIntegral . withIOVec cs $ \(iovsPtr, iovsLen) ->@@ -185,9 +192,11 @@            -> SockAddr      -- ^ Recipient address            -> IO () #if !defined(mingw32_HOST_OS)+sendManyTo _                          [] _    = return () sendManyTo sock@(MkSocket fd _ _ _ _) cs addr = do     sent <- liftM fromIntegral sendManyToInner-    when (sent < totalLength cs) $ sendManyTo sock (remainingChunks sent cs) addr+    waitWhen0 sent sock+    when (sent >= 0) $ sendManyTo sock (remainingChunks sent cs) addr   where     sendManyToInner =       withSockAddr addr $ \addrPtr addrSize ->@@ -257,10 +266,6 @@     | otherwise      = let i' = i - len in i' `seq` remainingChunks i' xs   where     len = B.length x---- | @totalLength cs@ is the sum of the lengths of the chunks in the list @cs@.-totalLength :: [ByteString] -> Int-totalLength = sum . map B.length  -- | @withIOVec cs f@ executes the computation @f@, passing as argument a pair -- consisting of a pointer to a temporarily allocated array of pointers to
Network/Socket/ByteString/Internal.hs view
@@ -16,6 +16,7 @@     , c_writev     , c_sendmsg #endif+    , waitWhen0     ) where  import System.IO.Error (ioeSetErrorString, mkIOError)@@ -29,7 +30,10 @@ import Network.Socket.ByteString.MsgHdr (MsgHdr) #endif +import Control.Concurrent (threadWaitWrite, rtsSupportsBoundThreads)+import Control.Monad (when) import GHC.IO.Exception (IOErrorType(..))+import Network.Socket.Types  mkInvalidRecvArgError :: String -> IOError mkInvalidRecvArgError loc = ioeSetErrorString (mkIOError@@ -43,3 +47,9 @@ foreign import ccall unsafe "sendmsg"   c_sendmsg :: CInt -> Ptr MsgHdr -> CInt -> IO CSsize #endif++waitWhen0 :: Int -> Socket -> IO ()+waitWhen0 0 s = when rtsSupportsBoundThreads $ do+  let fd = fromIntegral $ fdSocket s+  threadWaitWrite fd+waitWhen0 _ _ = return ()
Network/Socket/ByteString/Lazy/Posix.hs view
@@ -7,8 +7,7 @@     , sendAll     ) where -import Control.Monad (liftM)-import Control.Monad (unless)+import Control.Monad (liftM, when) import qualified Data.ByteString.Lazy as L import Data.ByteString.Lazy.Internal (ByteString(..)) import Data.ByteString.Unsafe (unsafeUseAsCStringLen)@@ -19,7 +18,7 @@  import Network.Socket (Socket(..)) import Network.Socket.ByteString.IOVec (IOVec(IOVec))-import Network.Socket.ByteString.Internal (c_writev)+import Network.Socket.ByteString.Internal (c_writev, waitWhen0) import Network.Socket.Internal  -- -----------------------------------------------------------------------------@@ -53,5 +52,5 @@         -> IO () sendAll sock bs = do   sent <- send sock bs-  let bs' = L.drop sent bs-  unless (L.null bs') $ sendAll sock bs'+  waitWhen0 (fromIntegral sent) sock+  when (sent >= 0) $ sendAll sock $ L.drop sent bs
Network/Socket/ByteString/Lazy/Windows.hs view
@@ -7,13 +7,14 @@     ) where  import Control.Applicative ((<$>))-import Control.Monad (unless)+import Control.Monad (when) import qualified Data.ByteString as S import qualified Data.ByteString.Lazy as L import Data.Int (Int64)  import Network.Socket (Socket(..)) import qualified Network.Socket.ByteString as Socket+import Network.Socket.ByteString.Internal (waitWhen0)  -- ----------------------------------------------------------------------------- -- Sending@@ -32,5 +33,5 @@         -> IO () sendAll sock bs = do   sent <- send sock bs-  let bs' = L.drop sent bs-  unless (L.null bs') $ sendAll sock bs'+  waitWhen0 (fromIntegral sent) sock+  when (sent >= 0) $ sendAll sock $ L.drop sent bs
Network/Socket/Internal.hsc view
@@ -19,6 +19,7 @@ -----------------------------------------------------------------------------  #include "HsNet.h"+##include "HsNetDef.h"  module Network.Socket.Internal     (@@ -224,7 +225,7 @@ throwSocketErrorWaitRead :: (Eq a, Num a) => Socket -> String -> IO a -> IO a throwSocketErrorWaitRead sock name io =     throwSocketErrorIfMinus1RetryMayBlock name-        (threadWaitRead $ fromIntegral $ sockFd sock)+        (threadWaitRead $ fromIntegral $ fdSocket sock)         io  -- | Like 'throwSocketErrorIfMinus1Retry', but if the action fails with@@ -233,7 +234,7 @@ throwSocketErrorWaitWrite :: (Eq a, Num a) => Socket -> String -> IO a -> IO a throwSocketErrorWaitWrite sock name io =     throwSocketErrorIfMinus1RetryMayBlock name-        (threadWaitWrite $ fromIntegral $ sockFd sock)+        (threadWaitWrite $ fromIntegral $ fdSocket sock)         io  -- ---------------------------------------------------------------------------
Network/Socket/Types.hsc view
@@ -3,12 +3,13 @@ {-# LANGUAGE ForeignFunctionInterface #-}  #include "HsNet.h"+##include "HsNetDef.h"  module Network.Socket.Types     (     -- * Socket       Socket(..)-    , sockFd+    , fdSocket     , sockFamily     , sockType     , sockProtocol@@ -85,8 +86,9 @@  {-# DEPRECATED MkSocket "'MkSocket' will not be available in version 3.0.0.0 or later. Use fdSocket instead" #-} -sockFd :: Socket -> CInt-sockFd       (MkSocket n _ _ _ _) = n+-- | Obtaining the file descriptor from a socket.+fdSocket :: Socket -> CInt+fdSocket (MkSocket fd _ _ _ _) = fd  sockFamily :: Socket -> Family sockFamily   (MkSocket _ f _ _ _) = f@@ -305,8 +307,6 @@     | AF_CAN              -- Controller Area Network       deriving (Eq, Ord, Read, Show) -{-# DEPRECATED packFamily "packFamily will not be available in version 3.0.0.0 or later." #-}- packFamily :: Family -> CInt packFamily f = case packFamily' f of     Just fam -> fam@@ -522,8 +522,6 @@     _ -> Nothing  --------- ------------{-# DEPRECATED unpackFamily "unpackFamily will not be available in version 3.0.0.0 or later." #-}  unpackFamily :: CInt -> Family unpackFamily f = case f of
configure.ac view
@@ -1,4 +1,4 @@-AC_INIT([Haskell network package], [2.7.0.0], [libraries@haskell.org], [network])+AC_INIT([Haskell network package], [2.7.0.1], [libraries@haskell.org], [network])  ac_includes_default="$ac_includes_default #ifdef HAVE_SYS_SOCKET_H@@ -101,7 +101,7 @@ fi  dnl ---------------------------------------------------dnl * test for GETPEEREID(3) +dnl * test for GETPEEREID(3) dnl -------------------------------------------------- AC_MSG_CHECKING(for getpeereid in unistd.h) AC_CHECK_FUNC( getpeereid, AC_DEFINE([HAVE_GETPEEREID], [1], [Define to 1 if you have getpeereid.] ))@@ -173,17 +173,16 @@ *-mingw* | *-msys*) 	EXTRA_SRCS="cbits/initWinSock.c, cbits/winSockErr.c, cbits/asyncAccept.c" 	EXTRA_LIBS=ws2_32-	CALLCONV=stdcall ;;+	;; *-solaris2*) 	EXTRA_SRCS="cbits/ancilData.c" 	EXTRA_LIBS="nsl, socket"-	CALLCONV=ccall ;;+	;; *) 	EXTRA_SRCS="cbits/ancilData.c" 	EXTRA_LIBS=-	CALLCONV=ccall ;;+	;; esac-AC_SUBST([CALLCONV]) AC_SUBST([EXTRA_CPPFLAGS]) AC_SUBST([EXTRA_LIBS]) AC_SUBST([EXTRA_SRCS])
include/HsNet.h view
@@ -7,19 +7,12 @@ #ifndef HSNET_H #define HSNET_H -#include "HsNetworkConfig.h"+#include "HsNetDef.h"  #ifdef NEED_WINVER # define WINVER 0x0501 #endif -/* ultra-evil... */-#undef PACKAGE_BUGREPORT-#undef PACKAGE_NAME-#undef PACKAGE_STRING-#undef PACKAGE_TARNAME-#undef PACKAGE_VERSION- #ifndef INLINE # if defined(_MSC_VER) #  define INLINE extern __inline@@ -159,22 +152,6 @@ {     freeaddrinfo(ai); }-#endif--#if defined(HAVE_WINSOCK2_H)-# define WITH_WINSOCK  1-#endif--#if !defined(mingw32_HOST_OS) && !defined(_WIN32)-# define DOMAIN_SOCKET_SUPPORT 1-#endif--#if !defined(CALLCONV)-# if defined(WITH_WINSOCK)-#  define CALLCONV stdcall-# else-#  define CALLCONV ccall-# endif #endif  #if !defined(IOV_MAX)
+ include/HsNetDef.h view
@@ -0,0 +1,45 @@+#ifndef HSNETDEF_H+#define HSNETDEF_H++#include "HsNetworkConfig.h"++/* ultra-evil... */+#undef PACKAGE_BUGREPORT+#undef PACKAGE_NAME+#undef PACKAGE_STRING+#undef PACKAGE_TARNAME+#undef PACKAGE_VERSION++#if defined(HAVE_WINSOCK2_H)+# define WITH_WINSOCK  1+#endif++#if !defined(mingw32_HOST_OS) && !defined(_WIN32)+# define DOMAIN_SOCKET_SUPPORT 1+#endif++/* stdcall is for Windows 32.+   Haskell FFI does not have a keyword for Windows 64.+   If ccall/stdcall is specified on Windows 64,+   GHC ignores it and use a proper ABI for Windows 64.+   But if stdcall is specified, GHC displays a warning.+   So, let's use ccall for Windows 64.+ */+#if defined(mingw32_HOST_OS)+# if defined(i386_HOST_ARCH)+#  define CALLCONV stdcall+# elif defined(x86_64_HOST_ARCH)+#  define CALLCONV ccall+# else+#  error Unknown mingw32 arch+# endif+#else+# define CALLCONV ccall+#endif+#if defined(mingw32_HOST_OS)+# define SAFE_ON_WIN safe+#else+# define SAFE_ON_WIN unsafe+#endif++#endif /* HSNETDEF_H */
network.buildinfo.in view
@@ -1,7 +1,7 @@-ghc-options: -DCALLCONV=@CALLCONV@ @EXTRA_CPPFLAGS@-ghc-prof-options: -DCALLCONV=@CALLCONV@ @EXTRA_CPPFLAGS@+ghc-options: @EXTRA_CPPFLAGS@+ghc-prof-options: @EXTRA_CPPFLAGS@ ld-options: @LDFLAGS@-cc-options: -DCALLCONV=@CALLCONV@ @EXTRA_CPPFLAGS@+cc-options: @EXTRA_CPPFLAGS@ c-sources: @EXTRA_SRCS@ extra-libraries: @EXTRA_LIBS@ install-includes: HsNetworkConfig.h
network.cabal view
@@ -1,5 +1,5 @@ name:           network-version:        2.7.0.0+version:        2.7.0.1 license:        BSD3 license-file:   LICENSE maintainer:     Kazu Yamamoto, Evan Borden@@ -24,7 +24,7 @@   README.md CHANGELOG.md   examples/*.hs tests/*.hs config.guess config.sub install-sh   configure.ac configure network.buildinfo.in-  include/HsNetworkConfig.h.in include/HsNet.h+  include/HsNetworkConfig.h.in include/HsNet.h include/HsNetDef.h   -- C sources only used on some systems   cbits/ancilData.c cbits/asyncAccept.c cbits/initWinSock.c   cbits/winSockErr.c