diff options
author | Joey Hess <joeyh@joeyh.name> | 2016-09-05 12:10:24 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2016-09-05 12:10:24 -0400 |
commit | 0500d982f4fdba241e085c5c601479dff813d829 (patch) | |
tree | 82b3181e6b534b91437fd8e0d43f5c25259f09aa /Assistant | |
parent | d0d0d07b9e88992f8beedce33a78918e27b41a6a (diff) |
switch away from deprecated recvFrom
Network.Socket.ByteString is in network since before 2.4, so no need to
adjust bounds.
Diffstat (limited to 'Assistant')
-rw-r--r-- | Assistant/Threads/PairListener.hs | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/Assistant/Threads/PairListener.hs b/Assistant/Threads/PairListener.hs index ba2ae955c..507575941 100644 --- a/Assistant/Threads/PairListener.hs +++ b/Assistant/Threads/PairListener.hs @@ -20,6 +20,9 @@ import Git import Network.Multicast import Network.Socket +import qualified Data.ByteString as B +import qualified Data.ByteString.UTF8 as BU8 +import qualified Network.Socket.ByteString as B import qualified Data.Text as T pairListenerThread :: UrlRenderer -> NamedThread @@ -33,7 +36,7 @@ pairListenerThread urlrenderer = namedThread "PairListener" $ do - or only one like lo that doesn't support multicast. -} getsock = multicastReceiver (multicastAddress IPv4AddrClass) pairingPort - go reqs cache sock = liftIO (getmsg sock []) >>= \msg -> case readish msg of + go reqs cache sock = liftIO (getmsg sock B.empty) >>= \msg -> case readish (BU8.toString msg) of Nothing -> go reqs cache sock Just m -> do debug ["received", show msg] @@ -94,10 +97,10 @@ pairListenerThread urlrenderer = namedThread "PairListener" $ do invalidateCache msg = filter (not . verifiedPairMsg msg) getmsg sock c = do - (msg, n, _) <- recvFrom sock chunksz - if n < chunksz - then return $ c ++ msg - else getmsg sock $ c ++ msg + (msg, _) <- B.recvFrom sock chunksz + if B.length msg < chunksz + then return $ c <> msg + else getmsg sock $ c <> msg where chunksz = 1024 |