From ad2e4571acf395e98d479ce3d5d8dea1b754601f Mon Sep 17 00:00:00 2001 From: Kazu Yamamoto Date: Tue, 27 Aug 2024 18:06:20 +0900 Subject: [PATCH] removing unliftio --- Network/QUIC/Client/Reader.hs | 6 +++--- Network/QUIC/Client/Run.hs | 8 ++++---- Network/QUIC/Closer.hs | 4 ++-- Network/QUIC/Connection/Crypto.hs | 4 ++-- Network/QUIC/Connection/Migration.hs | 6 +++--- Network/QUIC/Connection/Misc.hs | 4 ++-- Network/QUIC/Connection/Queue.hs | 2 +- Network/QUIC/Connection/Role.hs | 2 +- Network/QUIC/Connection/State.hs | 10 +++++----- Network/QUIC/Connection/Stream.hs | 14 +++++++------- Network/QUIC/Connection/Timeout.hs | 8 ++++---- Network/QUIC/Connection/Types.hs | 4 ++-- Network/QUIC/Connector.hs | 2 +- Network/QUIC/Crypto/Keys.hs | 4 ++-- Network/QUIC/Exception.hs | 6 +++--- Network/QUIC/Handshake.hs | 2 +- Network/QUIC/IO.hs | 6 +++--- Network/QUIC/Packet/Decode.hs | 2 +- Network/QUIC/Receiver.hs | 2 +- Network/QUIC/Recovery/Interface.hs | 8 ++++---- Network/QUIC/Recovery/LossRecovery.hs | 2 +- Network/QUIC/Recovery/Metrics.hs | 2 +- Network/QUIC/Recovery/Release.hs | 2 +- Network/QUIC/Recovery/Timer.hs | 4 ++-- Network/QUIC/Recovery/Types.hs | 2 +- Network/QUIC/Recovery/Utils.hs | 4 ++-- Network/QUIC/Sender.hs | 6 +++--- Network/QUIC/Server/Reader.hs | 8 ++++---- Network/QUIC/Server/Run.hs | 8 ++++---- Network/QUIC/Socket.hs | 2 +- Network/QUIC/Stream/Misc.hs | 2 +- Network/QUIC/Stream/Queue.hs | 2 +- Network/QUIC/Stream/Types.hs | 4 ++-- Network/QUIC/Types/Exception.hs | 2 +- Network/QUIC/Types/Queue.hs | 2 +- Network/QUIC/Utils.hs | 2 +- quic.cabal | 14 +++++--------- test/Config.hs | 4 ++-- test/ErrorSpec.hs | 2 +- test/FrameSpec.hs | 2 +- test/HandshakeSpec.hs | 4 ++-- test/IOSpec.hs | 6 +++--- test/TransportError.hs | 4 ++-- util/ServerX.hs | 2 +- util/quic-client.hs | 2 +- 45 files changed, 97 insertions(+), 101 deletions(-) diff --git a/Network/QUIC/Client/Reader.hs b/Network/QUIC/Client/Reader.hs index e401cf92..b17635f3 100644 --- a/Network/QUIC/Client/Reader.hs +++ b/Network/QUIC/Client/Reader.hs @@ -9,11 +9,11 @@ module Network.QUIC.Client.Reader ( clientSocket, ) where +import Control.Concurrent +import qualified Control.Exception as E import Data.List (intersect) import Network.Socket (Socket, close, getSocketName) import qualified Network.Socket.ByteString as NSB -import UnliftIO.Concurrent -import qualified UnliftIO.Exception as E import Network.QUIC.Connection import Network.QUIC.Connector @@ -34,7 +34,7 @@ readerClient s0 conn = handleLogUnit logAction $ do loop where wait = do - bound <- E.handleAny (\_ -> return False) $ do + bound <- E.handle (\(E.SomeException _) -> return False) $ do _ <- getSocketName s0 return True unless bound $ do diff --git a/Network/QUIC/Client/Run.hs b/Network/QUIC/Client/Run.hs index cea7a663..8727fb88 100644 --- a/Network/QUIC/Client/Run.hs +++ b/Network/QUIC/Client/Run.hs @@ -7,10 +7,10 @@ module Network.QUIC.Client.Run ( migrate, ) where +import Control.Concurrent +import Control.Concurrent.Async +import qualified Control.Exception as E import qualified Network.Socket as NS -import UnliftIO.Async -import UnliftIO.Concurrent -import qualified UnliftIO.Exception as E import Network.QUIC.Client.Reader import Network.QUIC.Closer @@ -92,7 +92,7 @@ runClient conf client0 isICVN verInfo = do case er of Left () -> E.throwIO MustNotReached Right r -> return r - ex <- E.trySyncOrAsync runThreads + ex <- E.try runThreads sendFinal conn closure conn ldcc ex where diff --git a/Network/QUIC/Closer.hs b/Network/QUIC/Closer.hs index df1c536c..230e5c92 100644 --- a/Network/QUIC/Closer.hs +++ b/Network/QUIC/Closer.hs @@ -2,11 +2,11 @@ module Network.QUIC.Closer (closure) where +import Control.Concurrent +import qualified Control.Exception as E import Foreign.Marshal.Alloc import Foreign.Ptr import qualified Network.Socket as NS -import UnliftIO.Concurrent -import qualified UnliftIO.Exception as E import Network.QUIC.Config import Network.QUIC.Connection diff --git a/Network/QUIC/Connection/Crypto.hs b/Network/QUIC/Connection/Crypto.hs index ec87de25..31113a3c 100644 --- a/Network/QUIC/Connection/Crypto.hs +++ b/Network/QUIC/Connection/Crypto.hs @@ -24,8 +24,8 @@ module Network.QUIC.Connection.Crypto ( setCurrentKeyPhase, ) where +import Control.Concurrent.STM import Network.TLS.QUIC -import UnliftIO.STM import Network.QUIC.Connection.Misc import Network.QUIC.Connection.Types @@ -63,7 +63,7 @@ putOffCrypto Connection{..} lvl rpkt = waitEncryptionLevel :: Connection -> EncryptionLevel -> IO () waitEncryptionLevel Connection{..} lvl = atomically $ do l <- readTVar $ encryptionLevel connState - checkSTM (l >= lvl) + check (l >= lvl) ---------------------------------------------------------------- diff --git a/Network/QUIC/Connection/Migration.hs b/Network/QUIC/Connection/Migration.hs index 683ed233..f00e117f 100644 --- a/Network/QUIC/Connection/Migration.hs +++ b/Network/QUIC/Connection/Migration.hs @@ -26,9 +26,9 @@ module Network.QUIC.Connection.Migration ( validatePath, ) where +import Control.Concurrent.STM import qualified Data.IntMap.Strict as IntMap import qualified Data.Map.Strict as Map -import UnliftIO.STM import Network.QUIC.Connection.Misc import Network.QUIC.Connection.Queue @@ -123,7 +123,7 @@ waitPeerCID conn@Connection{..} = do let ref = peerCIDDB db <- readTVar ref mncid <- pickPeerCID conn - checkSTM $ isJust mncid + check $ isJust mncid let u = usedCIDInfo db setPeerCID conn (fromJust mncid) True return u @@ -313,7 +313,7 @@ isPathValidating Connection{..} = do waitResponse :: Connection -> IO () waitResponse Connection{..} = atomically $ do state <- readTVar migrationState - checkSTM (state == RecvResponse) + check (state == RecvResponse) writeTVar migrationState NonMigration checkResponse :: Connection -> PathData -> IO () diff --git a/Network/QUIC/Connection/Misc.hs b/Network/QUIC/Connection/Misc.hs index dc18175c..ccfa5574 100644 --- a/Network/QUIC/Connection/Misc.hs +++ b/Network/QUIC/Connection/Misc.hs @@ -33,10 +33,10 @@ module Network.QUIC.Connection.Misc ( abortConnection, ) where +import Control.Concurrent +import qualified Control.Exception as E import Network.Socket (Socket) import System.Mem.Weak -import UnliftIO.Concurrent -import qualified UnliftIO.Exception as E import Network.QUIC.Connection.Queue import Network.QUIC.Connection.Timeout diff --git a/Network/QUIC/Connection/Queue.hs b/Network/QUIC/Connection/Queue.hs index 161b0c81..a0c3051f 100644 --- a/Network/QUIC/Connection/Queue.hs +++ b/Network/QUIC/Connection/Queue.hs @@ -1,6 +1,6 @@ module Network.QUIC.Connection.Queue where -import UnliftIO.STM +import Control.Concurrent.STM import Network.QUIC.Connection.Types import Network.QUIC.Imports diff --git a/Network/QUIC/Connection/Role.hs b/Network/QUIC/Connection/Role.hs index 8d640cc9..f087969d 100644 --- a/Network/QUIC/Connection/Role.hs +++ b/Network/QUIC/Connection/Role.hs @@ -22,9 +22,9 @@ module Network.QUIC.Connection.Role ( getCertificateChain, ) where +import Control.Concurrent import qualified Crypto.Token as CT import Data.X509 (CertificateChain) -import UnliftIO.Concurrent import Network.QUIC.Connection.Misc import Network.QUIC.Connection.Types diff --git a/Network/QUIC/Connection/State.hs b/Network/QUIC/Connection/State.hs index 8486ae15..1573b871 100644 --- a/Network/QUIC/Connection/State.hs +++ b/Network/QUIC/Connection/State.hs @@ -24,8 +24,8 @@ module Network.QUIC.Connection.State ( checkAntiAmplificationFree, ) where +import Control.Concurrent.STM import Network.Control -import UnliftIO.STM import Network.QUIC.Connection.Types import Network.QUIC.Connector @@ -62,20 +62,20 @@ isConnection1RTTReady Connection{..} = atomically $ do wait0RTTReady :: Connection -> IO () wait0RTTReady Connection{..} = atomically $ do cs <- readTVar $ connectionState connState - checkSTM (cs >= ReadyFor0RTT) + check (cs >= ReadyFor0RTT) -- | Waiting until 1-RTT data can be sent. wait1RTTReady :: Connection -> IO () wait1RTTReady Connection{..} = atomically $ do cs <- readTVar $ connectionState connState - checkSTM (cs >= ReadyFor1RTT) + check (cs >= ReadyFor1RTT) -- | For clients, waiting until HANDSHAKE_DONE is received. -- For servers, waiting until a TLS stack reports that the handshake is complete. waitEstablished :: Connection -> IO () waitEstablished Connection{..} = atomically $ do cs <- readTVar $ connectionState connState - checkSTM (cs >= Established) + check (cs >= Established) ---------------------------------------------------------------- @@ -134,7 +134,7 @@ waitAntiAmplificationFree conn@Connection{..} siz = do ok <- checkAntiAmplificationFree conn siz unless ok $ do beforeAntiAmp connLDCC - atomically (checkAntiAmplificationFreeSTM conn siz >>= checkSTM) + atomically (checkAntiAmplificationFreeSTM conn siz >>= check) -- setLossDetectionTimer is called eventually. diff --git a/Network/QUIC/Connection/Stream.hs b/Network/QUIC/Connection/Stream.hs index 18414757..fc817d45 100644 --- a/Network/QUIC/Connection/Stream.hs +++ b/Network/QUIC/Connection/Stream.hs @@ -14,7 +14,7 @@ module Network.QUIC.Connection.Stream ( checkStreamIdRoom, ) where -import UnliftIO.STM +import Control.Concurrent.STM import Network.QUIC.Connection.Misc import Network.QUIC.Connection.Types @@ -45,7 +45,7 @@ get tvar = atomically $ do conc@Concurrency{..} <- readTVar tvar let streamType = currentStream .&. 0b11 StreamIdBase base = maxStreams - checkSTM (currentStream < base * 4 + streamType) + check (currentStream < base * 4 + streamType) let currentStream' = currentStream + 4 writeTVar tvar conc{currentStream = currentStream'} return currentStream @@ -68,15 +68,15 @@ updatePeerStreamId conn sid = do || (isServer conn && isClientInitiatedBidirectional sid) ) $ do - atomicModifyIORef'' (peerStreamId conn) check + atomicModifyIORef'' (peerStreamId conn) checkConc when ( (isClient conn && isServerInitiatedUnidirectional sid) || (isServer conn && isClientInitiatedUnidirectional sid) ) $ do - atomicModifyIORef'' (peerUniStreamId conn) check + atomicModifyIORef'' (peerUniStreamId conn) checkConc where - check conc@Concurrency{..} + checkConc conc@Concurrency{..} | currentStream < sid = conc{currentStream = sid} | otherwise = conc @@ -106,9 +106,9 @@ checkStreamIdRoom conn dir = do let ref | dir == Bidirectional = peerStreamId conn | otherwise = peerUniStreamId conn - atomicModifyIORef' ref check + atomicModifyIORef' ref checkConc where - check conc@Concurrency{..} = + checkConc conc@Concurrency{..} = let StreamIdBase base = maxStreams initialStreams = initialMaxStreamsBidi $ getMyParameters conn cbase = currentStream !>>. 2 diff --git a/Network/QUIC/Connection/Timeout.hs b/Network/QUIC/Connection/Timeout.hs index 63b2e524..bf269cf8 100644 --- a/Network/QUIC/Connection/Timeout.hs +++ b/Network/QUIC/Connection/Timeout.hs @@ -5,10 +5,10 @@ module Network.QUIC.Connection.Timeout ( delay, ) where +import Control.Concurrent +import qualified Control.Exception as E import Network.QUIC.Event import qualified System.Timeout as ST -import UnliftIO.Concurrent -import qualified UnliftIO.Exception as E import Network.QUIC.Connection.Types import Network.QUIC.Connector @@ -25,7 +25,7 @@ fire conn (Microseconds microseconds) action = do where action' = do alive <- getAlive conn - when alive action `E.catchSyncOrAsync` ignore + when alive action `E.catch` ignore cfire :: Connection -> Microseconds -> TimeoutCallback -> IO (IO ()) cfire conn (Microseconds microseconds) action = do @@ -36,7 +36,7 @@ cfire conn (Microseconds microseconds) action = do where action' = do alive <- getAlive conn - when alive action `E.catchSyncOrAsync` ignore + when alive action `E.catch` ignore delay :: Microseconds -> IO () delay (Microseconds microseconds) = threadDelay microseconds diff --git a/Network/QUIC/Connection/Types.hs b/Network/QUIC/Connection/Types.hs index d02beaf6..4195cbc3 100644 --- a/Network/QUIC/Connection/Types.hs +++ b/Network/QUIC/Connection/Types.hs @@ -5,6 +5,8 @@ module Network.QUIC.Connection.Types where +import Control.Concurrent +import Control.Concurrent.STM import qualified Crypto.Token as CT import Data.Array.IO import Data.ByteString.Internal @@ -18,8 +20,6 @@ import Foreign.Ptr (nullPtr) import Network.Control (Rate, RxFlow, TxFlow, newRate, newRxFlow, newTxFlow) import Network.Socket (Cmsg, SockAddr, Socket) import Network.TLS.QUIC -import UnliftIO.Concurrent -import UnliftIO.STM import Network.QUIC.Config import Network.QUIC.Connector diff --git a/Network/QUIC/Connector.hs b/Network/QUIC/Connector.hs index 981b1501..b3d8c1bd 100644 --- a/Network/QUIC/Connector.hs +++ b/Network/QUIC/Connector.hs @@ -1,8 +1,8 @@ module Network.QUIC.Connector where +import Control.Concurrent.STM import Data.IORef import Network.QUIC.Types -import UnliftIO.STM class Connector a where getRole :: a -> Role diff --git a/Network/QUIC/Crypto/Keys.hs b/Network/QUIC/Crypto/Keys.hs index fbb11437..fe93c376 100644 --- a/Network/QUIC/Crypto/Keys.hs +++ b/Network/QUIC/Crypto/Keys.hs @@ -12,10 +12,10 @@ module Network.QUIC.Crypto.Keys ( headerProtectionKey, ) where +import qualified Control.Exception as E import Network.TLS hiding (Version) import Network.TLS.Extra.Cipher import Network.TLS.QUIC -import qualified UnliftIO.Exception as E import Network.QUIC.Crypto.Types import Network.QUIC.Imports @@ -35,7 +35,7 @@ initialSalt Version1 = "\x38\x76\x2c\xf7\xf5\x59\x34\xb3\x4d\x17\x9a\xe6\xa4\xc8\x0c\xad\xcc\xbb\x7f\x0a" initialSalt Version2 = "\x0d\xed\xe3\xde\xf7\x00\xa6\xdb\x81\x93\x81\xbe\x6e\x26\x9d\xcb\xf9\xbd\x2e\xd9" -initialSalt (Version v) = E.impureThrow $ VersionIsUnknown v +initialSalt (Version v) = E.throw $ VersionIsUnknown v initialSecrets :: Version -> CID -> TrafficSecrets InitialSecret initialSecrets v c = (clientInitialSecret v c, serverInitialSecret v c) diff --git a/Network/QUIC/Exception.hs b/Network/QUIC/Exception.hs index 81a0cfec..c5bc1971 100644 --- a/Network/QUIC/Exception.hs +++ b/Network/QUIC/Exception.hs @@ -5,15 +5,15 @@ module Network.QUIC.Exception ( handleLogUnit, ) where +import qualified Control.Exception as E import qualified GHC.IO.Exception as E import qualified System.IO.Error as E -import qualified UnliftIO.Exception as E import Network.QUIC.Logger -- Catch all exceptions including asynchronous ones. handleLogUnit :: DebugLogger -> IO () -> IO () -handleLogUnit logAction action = action `E.catchSyncOrAsync` handler +handleLogUnit logAction action = action `E.catch` handler where handler :: E.SomeException -> IO () handler se = case E.fromException se of @@ -25,7 +25,7 @@ handleLogUnit logAction action = action `E.catchSyncOrAsync` handler -- Log and throw an exception handleLogT :: DebugLogger -> IO a -> IO a -handleLogT logAction action = action `E.catchAny` handler +handleLogT logAction action = action `E.catch` handler where handler (E.SomeException e) = do logAction $ bhow e diff --git a/Network/QUIC/Handshake.hs b/Network/QUIC/Handshake.hs index e4b5d075..17ca1fa1 100644 --- a/Network/QUIC/Handshake.hs +++ b/Network/QUIC/Handshake.hs @@ -3,10 +3,10 @@ module Network.QUIC.Handshake where +import qualified Control.Exception as E import Data.List (intersect) import qualified Network.TLS as TLS import Network.TLS.QUIC -import qualified UnliftIO.Exception as E import Network.QUIC.Config import Network.QUIC.Connection diff --git a/Network/QUIC/IO.hs b/Network/QUIC/IO.hs index f0a00cbf..ea720cbe 100644 --- a/Network/QUIC/IO.hs +++ b/Network/QUIC/IO.hs @@ -1,9 +1,9 @@ module Network.QUIC.IO where +import Control.Concurrent.STM +import qualified Control.Exception as E import qualified Data.ByteString as BS import Network.Control -import qualified UnliftIO.Exception as E -import UnliftIO.STM import Network.QUIC.Connection import Network.QUIC.Connector @@ -110,7 +110,7 @@ checkBlocked s len wait = atomically $ do connWindow = txWindowSize connFlow minFlow = min strmWindow connWindow n = min len minFlow - when wait $ checkSTM (n > 0) + when wait $ check (n > 0) if n > 0 then return $ Right n else do diff --git a/Network/QUIC/Packet/Decode.hs b/Network/QUIC/Packet/Decode.hs index a31ec589..6b4dda98 100644 --- a/Network/QUIC/Packet/Decode.hs +++ b/Network/QUIC/Packet/Decode.hs @@ -7,9 +7,9 @@ module Network.QUIC.Packet.Decode ( decodeStatelessResetToken, ) where +import qualified Control.Exception as E import qualified Data.ByteString as BS import qualified Data.ByteString.Short as Short -import qualified UnliftIO.Exception as E import Network.QUIC.Imports import Network.QUIC.Packet.Header diff --git a/Network/QUIC/Receiver.hs b/Network/QUIC/Receiver.hs index 69aa6813..cf1f9d71 100644 --- a/Network/QUIC/Receiver.hs +++ b/Network/QUIC/Receiver.hs @@ -5,10 +5,10 @@ module Network.QUIC.Receiver ( receiver, ) where +import qualified Control.Exception as E import qualified Data.ByteString as BS import Network.Control import Network.TLS (AlertDescription (..)) -import qualified UnliftIO.Exception as E import Network.QUIC.Config import Network.QUIC.Connection diff --git a/Network/QUIC/Recovery/Interface.hs b/Network/QUIC/Recovery/Interface.hs index 0a197384..f25a3f5c 100644 --- a/Network/QUIC/Recovery/Interface.hs +++ b/Network/QUIC/Recovery/Interface.hs @@ -7,9 +7,9 @@ module Network.QUIC.Recovery.Interface ( resender, ) where +import Control.Concurrent.STM import qualified Data.Sequence as Seq import System.Log.FastLogger (LogStr) -import UnliftIO.STM import Network.QUIC.Imports import Network.QUIC.Qlog @@ -23,12 +23,12 @@ import Network.QUIC.Types checkWindowOpenSTM :: LDCC -> Int -> STM () checkWindowOpenSTM LDCC{..} siz = do CC{..} <- readTVar recoveryCC - checkSTM (siz <= congestionWindow - bytesInFlight) + check (siz <= congestionWindow - bytesInFlight) takePingSTM :: LDCC -> STM EncryptionLevel takePingSTM LDCC{..} = do mx <- readTVar ptoPing - checkSTM $ isJust mx + check $ isJust mx writeTVar ptoPing Nothing return $ fromJust mx @@ -48,7 +48,7 @@ resender :: LDCC -> IO () resender ldcc@LDCC{..} = forever $ do atomically $ do lostPackets <- readTVar lostCandidates - checkSTM (lostPackets /= emptySentPackets) + check (lostPackets /= emptySentPackets) delay $ Microseconds 10000 -- fixme packets <- atomically $ do SentPackets pkts <- readTVar lostCandidates diff --git a/Network/QUIC/Recovery/LossRecovery.hs b/Network/QUIC/Recovery/LossRecovery.hs index 3a242728..e3ab8dbb 100644 --- a/Network/QUIC/Recovery/LossRecovery.hs +++ b/Network/QUIC/Recovery/LossRecovery.hs @@ -8,9 +8,9 @@ module Network.QUIC.Recovery.LossRecovery ( onPacketNumberSpaceDiscarded, ) where +import Control.Concurrent.STM import Data.Sequence (Seq, ViewR (..), (|>)) import qualified Data.Sequence as Seq -import UnliftIO.STM import Network.QUIC.Connector import Network.QUIC.Imports diff --git a/Network/QUIC/Recovery/Metrics.hs b/Network/QUIC/Recovery/Metrics.hs index fed4cd57..2161ac1e 100644 --- a/Network/QUIC/Recovery/Metrics.hs +++ b/Network/QUIC/Recovery/Metrics.hs @@ -9,8 +9,8 @@ module Network.QUIC.Recovery.Metrics ( setInitialCongestionWindow, ) where +import Control.Concurrent.STM import Data.Sequence (Seq) -import UnliftIO.STM import Network.QUIC.Imports import Network.QUIC.Qlog diff --git a/Network/QUIC/Recovery/Release.hs b/Network/QUIC/Recovery/Release.hs index bf778fd9..f237f436 100644 --- a/Network/QUIC/Recovery/Release.hs +++ b/Network/QUIC/Recovery/Release.hs @@ -7,9 +7,9 @@ module Network.QUIC.Recovery.Release ( onPacketsLost, ) where +import Control.Concurrent.STM import Data.Sequence (Seq, ViewL (..), ViewR (..), (><)) import qualified Data.Sequence as Seq -import UnliftIO.STM import Network.QUIC.Imports import Network.QUIC.Recovery.Metrics diff --git a/Network/QUIC/Recovery/Timer.hs b/Network/QUIC/Recovery/Timer.hs index 6f434e8e..69525b37 100644 --- a/Network/QUIC/Recovery/Timer.hs +++ b/Network/QUIC/Recovery/Timer.hs @@ -10,9 +10,9 @@ module Network.QUIC.Recovery.Timer ( ldccTimer, ) where +import Control.Concurrent.STM import qualified Data.Sequence as Seq import Network.QUIC.Event -import UnliftIO.STM import Network.QUIC.Connector import Network.QUIC.Imports @@ -116,7 +116,7 @@ ldccTimer :: LDCC -> IO () ldccTimer ldcc@LDCC{..} = forever $ do atomically $ do x <- readTVar timerInfoQ - checkSTM (x /= Empty) + check (x /= Empty) delay timerGranularity updateWithNext ldcc diff --git a/Network/QUIC/Recovery/Types.hs b/Network/QUIC/Recovery/Types.hs index 4fd03f81..9c8de884 100644 --- a/Network/QUIC/Recovery/Types.hs +++ b/Network/QUIC/Recovery/Types.hs @@ -35,13 +35,13 @@ module Network.QUIC.Recovery.Types ( qlogLossTimerExpired, ) where +import Control.Concurrent.STM import Data.IORef import Data.List (intersperse) import Data.Sequence (Seq) import qualified Data.Sequence as Seq import Network.QUIC.Event import System.Log.FastLogger -import UnliftIO.STM import Network.QUIC.Connector import Network.QUIC.Imports diff --git a/Network/QUIC/Recovery/Utils.hs b/Network/QUIC/Recovery/Utils.hs index 86480a10..9ff73cef 100644 --- a/Network/QUIC/Recovery/Utils.hs +++ b/Network/QUIC/Recovery/Utils.hs @@ -11,10 +11,10 @@ module Network.QUIC.Recovery.Utils ( delay, ) where +import Control.Concurrent +import Control.Concurrent.STM import Data.Sequence (Seq, ViewL (..), (<|)) import qualified Data.Sequence as Seq -import UnliftIO.Concurrent -import UnliftIO.STM import Network.QUIC.Connector import Network.QUIC.Imports diff --git a/Network/QUIC/Sender.hs b/Network/QUIC/Sender.hs index 0225ed15..27cffb0f 100644 --- a/Network/QUIC/Sender.hs +++ b/Network/QUIC/Sender.hs @@ -6,11 +6,11 @@ module Network.QUIC.Sender ( sendFinal, ) where +import Control.Concurrent +import Control.Concurrent.STM +import qualified Control.Exception as E import qualified Data.ByteString as BS import Foreign.Ptr (plusPtr) -import UnliftIO.Concurrent -import qualified UnliftIO.Exception as E -import UnliftIO.STM import Network.QUIC.Config import Network.QUIC.Connection diff --git a/Network/QUIC/Server/Reader.hs b/Network/QUIC/Server/Reader.hs index 696b56cc..18a70bd6 100644 --- a/Network/QUIC/Server/Reader.hs +++ b/Network/QUIC/Server/Reader.hs @@ -17,6 +17,9 @@ module Network.QUIC.Server.Reader ( recvServer, ) where +import Control.Concurrent +import Control.Concurrent.STM +import qualified Control.Exception as E import qualified Crypto.Token as CT import qualified Data.ByteString as BS import Data.Map.Strict (Map) @@ -28,9 +31,6 @@ import qualified Network.Control as LRUCache import Network.Socket (Socket) import qualified Network.Socket.ByteString as NSB import qualified System.IO.Error as E -import UnliftIO.Concurrent -import qualified UnliftIO.Exception as E -import UnliftIO.STM import Network.QUIC.Config import Network.QUIC.Connection @@ -162,7 +162,7 @@ dispatcher d conf mysock = handleLogUnit logAction $ do | otherwise = return () safeRecv rcv = do - ex <- E.tryAny $ windowsThreadBlockHack rcv + ex <- E.try $ windowsThreadBlockHack rcv case ex of Right x -> return x Left se -> case E.fromException se of diff --git a/Network/QUIC/Server/Run.hs b/Network/QUIC/Server/Run.hs index be8c7f31..501920e0 100644 --- a/Network/QUIC/Server/Run.hs +++ b/Network/QUIC/Server/Run.hs @@ -8,11 +8,11 @@ module Network.QUIC.Server.Run ( stop, ) where +import Control.Concurrent +import Control.Concurrent.Async +import qualified Control.Exception as E import qualified Network.Socket as NS import System.Log.FastLogger -import UnliftIO.Async -import UnliftIO.Concurrent -import qualified UnliftIO.Exception as E import Network.QUIC.Closer import Network.QUIC.Common @@ -122,7 +122,7 @@ runServer conf server0 dispatch baseThreadId acc = case er of Left () -> E.throwIO MustNotReached Right r -> return r - ex <- E.trySyncOrAsync runThreads + ex <- E.try runThreads sendFinal conn closure conn ldcc ex where diff --git a/Network/QUIC/Socket.hs b/Network/QUIC/Socket.hs index 817021ff..948a7c71 100644 --- a/Network/QUIC/Socket.hs +++ b/Network/QUIC/Socket.hs @@ -4,9 +4,9 @@ module Network.QUIC.Socket ( natRebinding, ) where +import qualified Control.Exception as E import Data.IP (IP, toSockAddr) import Network.Socket -import qualified UnliftIO.Exception as E natRebinding :: SockAddr -> IO Socket natRebinding sa = E.bracketOnError open close return diff --git a/Network/QUIC/Stream/Misc.hs b/Network/QUIC/Stream/Misc.hs index 234cbc5f..522e9c47 100644 --- a/Network/QUIC/Stream/Misc.hs +++ b/Network/QUIC/Stream/Misc.hs @@ -18,8 +18,8 @@ module Network.QUIC.Stream.Misc ( updateStreamFlowRx, ) where +import Control.Concurrent.STM import Network.Control -import UnliftIO.STM import Network.QUIC.Imports import Network.QUIC.Stream.Queue diff --git a/Network/QUIC/Stream/Queue.hs b/Network/QUIC/Stream/Queue.hs index d18adeb3..f4c205ba 100644 --- a/Network/QUIC/Stream/Queue.hs +++ b/Network/QUIC/Stream/Queue.hs @@ -2,8 +2,8 @@ module Network.QUIC.Stream.Queue where +import Control.Concurrent.STM import Data.ByteString (ByteString) -import UnliftIO.STM import Network.QUIC.Stream.Types diff --git a/Network/QUIC/Stream/Types.hs b/Network/QUIC/Stream/Types.hs index 2b068c4a..23611b19 100644 --- a/Network/QUIC/Stream/Types.hs +++ b/Network/QUIC/Stream/Types.hs @@ -12,10 +12,10 @@ module Network.QUIC.Stream.Types ( waitFinTx, ) where +import Control.Concurrent +import Control.Concurrent.STM import qualified Data.ByteString as BS import Network.Control -import UnliftIO.Concurrent -import UnliftIO.STM import {-# SOURCE #-} Network.QUIC.Connection.Types import Network.QUIC.Imports diff --git a/Network/QUIC/Types/Exception.hs b/Network/QUIC/Types/Exception.hs index 291569cd..16634084 100644 --- a/Network/QUIC/Types/Exception.hs +++ b/Network/QUIC/Types/Exception.hs @@ -1,7 +1,7 @@ module Network.QUIC.Types.Exception where +import qualified Control.Exception as E import qualified Network.TLS as TLS -import qualified UnliftIO.Exception as E import Network.QUIC.Imports import Network.QUIC.Types.Error diff --git a/Network/QUIC/Types/Queue.hs b/Network/QUIC/Types/Queue.hs index 3801e77c..a3818bdf 100644 --- a/Network/QUIC/Types/Queue.hs +++ b/Network/QUIC/Types/Queue.hs @@ -1,6 +1,6 @@ module Network.QUIC.Types.Queue where -import UnliftIO.STM +import Control.Concurrent.STM import Network.QUIC.Types.Packet diff --git a/Network/QUIC/Utils.hs b/Network/QUIC/Utils.hs index c955f861..42dd703c 100644 --- a/Network/QUIC/Utils.hs +++ b/Network/QUIC/Utils.hs @@ -2,6 +2,7 @@ module Network.QUIC.Utils where +import Control.Exception import Control.Monad (replicateM) import qualified Data.ByteString as BS import Data.ByteString.Base16 @@ -15,7 +16,6 @@ import Data.Word import Foreign.ForeignPtr (withForeignPtr) import Foreign.Ptr (Ptr, plusPtr) import System.Random (randomIO) -import UnliftIO.Exception -- GHC 8.0 does not provide fromRight. fromRight :: b -> Either a b -> b diff --git a/quic.cabal b/quic.cabal index 089193bd..40e4d3a9 100644 --- a/quic.cabal +++ b/quic.cabal @@ -128,6 +128,7 @@ library ghc-options: -Wall -Wcompat build-depends: base >=4.9 && <5, + async, array >= 0.5 && < 0.6, base16-bytestring >= 1.0 && < 1.1, bytestring >= 0.10, @@ -148,9 +149,7 @@ library network-control >= 0.1 && < 0.2, random >= 1.2.1 && < 1.3, serialise, - tls >= 2.0 && < 2.2, - unliftio >= 0.2 && < 0.3, - unliftio-core >= 0.2 && < 0.3 + tls >= 2.0 && < 2.2 if os(windows) cc-options: -D_WINDOWS @@ -182,8 +181,7 @@ executable quic-server network-byte-order, quic, tls, - tls-session-manager >= 0.0.5, - unliftio + tls-session-manager >= 0.0.5 if flag(devel) @@ -214,8 +212,7 @@ executable quic-client network-byte-order, quic, tls, - unix-time, - unliftio + unix-time if flag(devel) @@ -257,8 +254,7 @@ test-suite spec network >=3.1.2, quic, tls, - unix-time, - unliftio + unix-time if os(windows) ghc-options: -with-rtsopts=--io-manager=native diff --git a/test/Config.hs b/test/Config.hs index 2994cd8c..522087c4 100644 --- a/test/Config.hs +++ b/test/Config.hs @@ -12,6 +12,8 @@ module Config ( newSessionManager, ) where +import Control.Concurrent +import qualified Control.Exception as E import Control.Monad import Data.ByteString (ByteString) import Data.IORef @@ -19,8 +21,6 @@ import qualified Data.List as L import Network.Socket import Network.Socket.ByteString import Network.TLS hiding (Version) -import UnliftIO.Concurrent -import qualified UnliftIO.Exception as E import Network.QUIC.Client import Network.QUIC.Internal diff --git a/test/ErrorSpec.hs b/test/ErrorSpec.hs index 69cf78d1..88eea416 100644 --- a/test/ErrorSpec.hs +++ b/test/ErrorSpec.hs @@ -1,11 +1,11 @@ module ErrorSpec where +import Control.Concurrent import Control.Monad (forever, void) import Data.ByteString () import Network.QUIC import Network.QUIC.Server import Test.Hspec -import UnliftIO.Concurrent import Config import TransportError diff --git a/test/FrameSpec.hs b/test/FrameSpec.hs index cf85b70e..74a262c6 100644 --- a/test/FrameSpec.hs +++ b/test/FrameSpec.hs @@ -1,12 +1,12 @@ module FrameSpec where +import qualified Control.Exception as E import Data.Word import Foreign.Marshal.Alloc import Foreign.Marshal.Utils (fillBytes) import Foreign.Ptr import Foreign.Storable import Test.Hspec -import qualified UnliftIO.Exception as E import Network.QUIC.Internal diff --git a/test/HandshakeSpec.hs b/test/HandshakeSpec.hs index 389f8210..53de4d9a 100644 --- a/test/HandshakeSpec.hs +++ b/test/HandshakeSpec.hs @@ -2,13 +2,13 @@ module HandshakeSpec where +import Control.Concurrent +import qualified Control.Exception as E import Control.Monad import qualified Data.ByteString as BS import Network.TLS (Group (..), HandshakeMode13 (..)) import qualified Network.TLS as TLS import Test.Hspec -import UnliftIO.Concurrent -import qualified UnliftIO.Exception as E import Network.QUIC import Network.QUIC.Client as C diff --git a/test/IOSpec.hs b/test/IOSpec.hs index d7c0f2b0..a0c5e81d 100644 --- a/test/IOSpec.hs +++ b/test/IOSpec.hs @@ -2,12 +2,12 @@ module IOSpec where +import Control.Concurrent +import Control.Concurrent.Async +import qualified Control.Exception as E import Control.Monad import qualified Data.ByteString as BS import Test.Hspec -import UnliftIO.Async -import UnliftIO.Concurrent -import qualified UnliftIO.Exception as E import Network.QUIC import qualified Network.QUIC.Client as C diff --git a/test/TransportError.hs b/test/TransportError.hs index 1f44de0a..9abe49a9 100644 --- a/test/TransportError.hs +++ b/test/TransportError.hs @@ -4,14 +4,14 @@ module TransportError ( transportErrorSpec, ) where +import Control.Concurrent import Control.Monad import Data.ByteString () import qualified Data.ByteString as BS import qualified Network.TLS as TLS import Network.TLS.QUIC (ExtensionID (..), ExtensionRaw (..)) +import System.Timeout import Test.Hspec -import UnliftIO.Concurrent -import UnliftIO.Timeout import Network.QUIC.Client import Network.QUIC.Internal hiding (timeout) diff --git a/util/ServerX.hs b/util/ServerX.hs index ebbf8e91..e1f08b2e 100644 --- a/util/ServerX.hs +++ b/util/ServerX.hs @@ -3,11 +3,11 @@ module ServerX where import Control.Concurrent +import qualified Control.Exception as E import Control.Monad import qualified Data.ByteString as BS import Data.ByteString.Builder import Network.ByteOrder -import qualified UnliftIO.Exception as E import H3 import Network.QUIC diff --git a/util/quic-client.hs b/util/quic-client.hs index 8a4c214f..f6c0883f 100644 --- a/util/quic-client.hs +++ b/util/quic-client.hs @@ -17,8 +17,8 @@ import System.Console.GetOpt import System.Environment import System.Exit import System.IO +import qualified System.Timeout as T import Text.Printf -import qualified UnliftIO.Timeout as T import ClientX import Common