Skip to content

Commit

Permalink
connection-manager: server
Browse files Browse the repository at this point in the history
  • Loading branch information
coot authored and karknu committed Jan 26, 2021
1 parent 01ae633 commit 6593432
Show file tree
Hide file tree
Showing 5 changed files with 2,076 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ouroboros-network-framework/ouroboros-network-framework.cabal
Expand Up @@ -50,6 +50,8 @@ library
Ouroboros.Network.Server.ConnectionTable
Ouroboros.Network.Server.Socket
Ouroboros.Network.Server.RateLimiting
Ouroboros.Network.Server2
Ouroboros.Network.Server2.ControlChannel
Ouroboros.Network.Snocket
Ouroboros.Network.Socket

Expand All @@ -73,6 +75,7 @@ library
, hashable
, mtl
, nothunks
, random
, stm
, text
, time
Expand Down
Expand Up @@ -43,8 +43,10 @@ import Network.Mux.Trace (MuxTrace, WithMuxBearer (..))

import Ouroboros.Network.ConnectionId
import Ouroboros.Network.ConnectionManager.Types
import Ouroboros.Network.MuxMode
import Ouroboros.Network.Snocket
import Ouroboros.Network.Server.RateLimiting (AcceptedConnectionsLimit (..))
import Ouroboros.Network.Server2.ControlChannel


-- | Arguments for a 'ConnectionManager' whch are independent of 'MuxMode'.
Expand Down Expand Up @@ -311,6 +313,9 @@ withConnectionManager
-- ^ Callback which runs in a thread dedicated for a given connection.
-> (handleError -> HandleErrorType)
-- ^ classify 'handleError's
-> InResponderMode muxMode (ControlChannel m (NewConnection peerAddr handle))
-- ^ On outbound duplex connections we need to notify the server about
-- a new connection.
-> (ConnectionManager muxMode socket peerAddr handle handleError m -> m a)
-- ^ Continuation which receives the 'ConnectionManager'. It must not leak
-- outside of scope of this callback. Once it returns all resources
Expand All @@ -334,6 +339,7 @@ withConnectionManager ConnectionManagerArguments {
connectionIdle
}
classifyHandleError
inboundGovernorControlChannel
k = do
(stateVar :: StrictTMVar m (ConnectionManagerState peerAddr handle handleError version m))
<- atomically $ do
Expand Down Expand Up @@ -903,6 +909,14 @@ withConnectionManager ConnectionManagerArguments {
(writeTVar
connVar
(OutboundState connId connThread handle dataFlow))
case dataFlow of
Duplex ->
case inboundGovernorControlChannel of
InResponderMode controlChannel ->
newOutboundConnection
controlChannel connId dataFlow handle
NotInResponderMode -> return ()
_ -> return ()
traceWith
tracer
(TrNegotiatedConnection provenance connId dataFlow)
Expand Down

0 comments on commit 6593432

Please sign in to comment.