wip, busyloop removed? maybe leak

This commit is contained in:
voidlizard 2025-03-15 09:51:16 +03:00
parent 025b269562
commit b7e5fcdbe3
2 changed files with 14 additions and 12 deletions

View File

@ -9,6 +9,8 @@ constraints:
, suckless-conf >= 0.1.2.7 , suckless-conf >= 0.1.2.7
, http-client >=0.7.16 && <0.8 , http-client >=0.7.16 && <0.8
debug-info: True
-- executable-static: True -- executable-static: True
-- profiling: True -- profiling: True
--library-profiling: False --library-profiling: False

View File

@ -243,20 +243,20 @@ runMessagingTCP env@MessagingTCP{..} = liftIO do
S.yield =<< ( readTVarIO _tcpSent <&> ("tcpSent",) . fromIntegral . HM.size) S.yield =<< ( readTVarIO _tcpSent <&> ("tcpSent",) . fromIntegral . HM.size)
sweepCookies <- ContT $ withAsync $ forever do sweepCookies <- ContT $ withAsync $ forever do
pause @'Seconds 10 pause @'Seconds 120
atomically do -- atomically do
pips <- readTVar _tcpPeerConn -- pips <- readTVar _tcpPeerConn
modifyTVar _tcpPeerToCookie (HM.filterWithKey (\k _ -> HM.member k pips)) -- modifyTVar _tcpPeerToCookie (HM.filterWithKey (\k _ -> HM.member k pips))
alive <- readTVar _tcpPeerToCookie <&> HS.fromList . HM.elems -- alive <- readTVar _tcpPeerToCookie <&> HS.fromList . HM.elems
modifyTVar _tcpPeerCookie (HM.filterWithKey (\k _ -> HS.member k alive)) -- modifyTVar _tcpPeerCookie (HM.filterWithKey (\k _ -> HS.member k alive))
sweep <- ContT $ withAsync $ forever do sweep <- ContT $ withAsync $ forever do
pause @'Seconds 60 pause @'Seconds 120
atomically do -- atomically do
pips <- readTVar _tcpPeerConn -- pips <- readTVar _tcpPeerConn
modifyTVar _tcpSent (HM.filterWithKey (\k _ -> HM.member k pips)) -- modifyTVar _tcpSent (HM.filterWithKey (\k _ -> HM.member k pips))
modifyTVar _tcpPeerSocket (HM.filterWithKey (\k _ -> HM.member k pips)) -- modifyTVar _tcpPeerSocket (HM.filterWithKey (\k _ -> HM.member k pips))
modifyTVar _tcpPeerCookie (HM.filter (>=1)) -- modifyTVar _tcpPeerCookie (HM.filter (>=1))
waitAnyCatchCancel [p1,p2,probes,sweep,sweepCookies] waitAnyCatchCancel [p1,p2,probes,sweep,sweepCookies]