Verified Commit 88bba8ee authored by Camil Staps's avatar Camil Staps 🚀

Robustness: close TCP connections to avoid "too many open file descriptors" in...

Robustness: close TCP connections to avoid "too many open file descriptors" in case of many parallel connections
parent 9a6a595e
Pipeline #37829 passed with stages
in 16 minutes and 52 seconds
......@@ -23,18 +23,20 @@ where
#! (tRep,conn,li,w) = receive_MT server.connect_timeout li w
| tRep <> TR_Success
= (li,w)
#! (ip,dupChan) = fromJust conn
#! (pid,w) = fork w
#! (ip,{rChannel,sChannel}) = fromJust conn
#! (pid,w) = fork w
| pid < 0
= abort "fork failed\n"
| pid > 0 // Parent: handle new requests
# w = abortConnection sChannel (closeRChannel rChannel w)
= loop li w
| otherwise // Child: handle current request
#! (logst,w) = logger (Connected ip) Nothing w
= handle logst st dupChan w
# w = closeRChannel li w
#! (logst,w) = logger (Connected ip) Nothing w
= handle logst st rChannel sChannel w
//handle :: !(Maybe s) !TCP_DuplexChannel !*World -> *(!TCP_Listener, !*World)
handle logst st dupChannel=:{rChannel,sChannel} w
//handle :: (Maybe s) TCP_SChannel_ TCP_RChannel_ *World -> (TCP_Listener, *World)
handle logst st rChannel sChannel w
#! (tRep,msg,rChannel,w) = receive_MT server.keepalive_timeout rChannel w
| tRep <> TR_Success
#! (logst,w) = logger Disconnected logst w
......@@ -45,7 +47,7 @@ where
#! (resp, hidden, st, w) = server.handler msg st w
#! (sChannel, w) = send (toByteSeq (toString resp)) sChannel w
#! (logst, w) = logger (Sent resp hidden) logst w
= handle logst st {dupChannel & rChannel=rChannel, sChannel=sChannel} w
= handle logst st rChannel sChannel w
signal :: !Int !Int !*World -> *(!Int, !*World)
signal signum handler w = code {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment