maybe fix TCP busyloop

This commit is contained in:
voidlizard 2025-02-17 06:01:09 +03:00
parent 9a0ab0e024
commit 6df825226d
1 changed files with 6 additions and 7 deletions

View File

@ -39,6 +39,7 @@ import Network.Socket hiding (listen,connect)
import System.Random hiding (next) import System.Random hiding (next)
import Control.Monad.Trans.Cont import Control.Monad.Trans.Cont
import Control.Exception import Control.Exception
import Control.Concurrent.STM qualified as STM
import UnliftIO (MonadUnliftIO(..)) import UnliftIO (MonadUnliftIO(..))
import UnliftIO.Async import UnliftIO.Async
@ -391,16 +392,14 @@ runMessagingTCP env@MessagingTCP{..} = liftIO do
-- client sockets -- client sockets
-- смотрим к кому надо -- смотрим к кому надо
who <- atomically $ readTQueue _tcpConnDemand who <- atomically do
whoAddr <- toPeerAddr who who <- readTQueue _tcpConnDemand
already <- readTVar _tcpPeerConn <&> HM.member who
if not already then pure who else STM.retry
debug $ "DEMAND:" <+> pretty who debug $ "DEMAND:" <+> pretty who
already <- atomically $ readTVar _tcpPeerConn <&> HM.member who whoAddr <- toPeerAddr who
when already do
debug "SHIT? BUSYLOOP?"
mzero
liftIO $ newClientThread env $ do liftIO $ newClientThread env $ do
let (L4Address _ (IPAddrPort (ip,port))) = whoAddr let (L4Address _ (IPAddrPort (ip,port))) = whoAddr