HORIZON HASKELLDocslts/ghc-9.14.xd82dee82026-10-12Search names, modules, packages, or :: a typeCtrl K

GHC 9.14.1 · lts/ghc-9.14.x · d82dee8 · 2026-10-12

Modulekes-agent-1.3.0.0Haskell2010

Cardano.KESAgent.Protocols.BearerUtil

  • 1 type
  • 1 value
  • Packagekes-agent-1.3.0.0
  • Exports2
  • LanguageHaskell2010
  • LicenceApache-2.0
  • SourceBearerUtil.hs
valuewithDuplexBearer
  1. :: (MonadST m, MonadSTM m, MonadThrow m, MonadAsync m)
  2. => RawBearer m
  3. -> RawBearer m -> m a
  4. -> m a
#

Wrap a raw bearer connection such that client disconnects are detected in a timely fashion. We do this by moving reads to a separate thread, and buffering their results; this way, the recv call happens before the protocol expects to receive anything, which will block until the connection is closed, or until any data is sent. *Note that this violates mlocking guarantees for incoming data.* This means that this wrapper should only be used on connections where mlocking is not needed for incoming data, only outgoing. In practice, we will only use this on the agent side of the service protocol; this is fine, because the client never sends anything that needs to be mlocked, and data from the server (== agent) to the client isn't buffered. The client side of the service protocol doesn't need this, because it is already in a receiving state when the protocol is idle, so it will detect disconnects fast. The control protocol doesn't need this either, because interactions follow a typical request-response patterns, and will, in practice, establish a new connection for each request-response cycle.