git.iko.soy/distributed-process
on master help sign in
Update documentation
a2d5758Edsko de Vries
network-transport/src/Network/Transport/TCP.hs+16−12
@@ -251,21 +251,22 @@ data ValidLocalEndPointState = ValidLocalEndPointState
251--
251--
252-- Remote endpoints (basically, TCP connections) have the following lifecycle:
252-- Remote endpoints (basically, TCP connections) have the following lifecycle:
253--
253--
254−-- Init ----+---> Invalid
254+-- Init ---+---> Invalid
255-- |
255-- |
256−-- | /----------------\
256+-- | /--------------\
257−-- | | |
257+-- | | |
258−-- | v |
258+-- | v |
259−-- +---> Valid ----+---> Closing
259+-- +---> Valid ---+---> Closing ---+---> Closed
260−-- | | |
260+-- | | | |
261−-- | | v
261+-- | | | v
262−-- \---------------+---> Closed
262+-- \-------+--------------+------------> Failed
263--
263--
264-- Init: There are two places where we create new remote endpoints: in
264-- Init: There are two places where we create new remote endpoints: in
265-- requestConnectionTo (in response to an API 'connect' call) and in
265-- requestConnectionTo (in response to an API 'connect' call) and in
266-- handleConnectionRequest (when a remote node tries to connect to us).
266-- handleConnectionRequest (when a remote node tries to connect to us).
267-- 'Init' carries an MVar () 'resolved' which concurrent threads can use to
267-- 'Init' carries an MVar () 'resolved' which concurrent threads can use to
268−-- wait for the remote endpoint to finish initialization.
268+-- wait for the remote endpoint to finish initialization. We record who
269+-- requested the connection (the local endpoint or the remote endpoint).
269--
270--
270-- Invalid: We put the remote endpoint in invalid state only during
271-- Invalid: We put the remote endpoint in invalid state only during
271-- requestConnectionTo when we fail to connect.
272-- requestConnectionTo when we fail to connect.
@@ -281,8 +282,11 @@ data ValidLocalEndPointState = ValidLocalEndPointState
281-- the request.
282-- the request.
282--
283--
283-- Closed: The endpoint is put in Closed state after a successful garbage
284-- Closed: The endpoint is put in Closed state after a successful garbage
285+-- collection.
286+--
287+-- Failed: If the connection to the remote endpoint is lost, or the local
284−-- collection, when the endpoint (or the whole transport) is closed manually,
288+-- endpoint (or the whole transport) is closed manually, the remote endpoint is
285−-- or when an IO exception occurs during communication.
289+-- put in Failed state, and we record the reason.
286--
290--
287-- Invariants for dealing with remote endpoints:
291-- Invariants for dealing with remote endpoints:
288--
292--
@@ -290,7 +294,7 @@ data ValidLocalEndPointState = ValidLocalEndPointState
290-- interleaving bits of payload).
294-- interleaving bits of payload).
291--
295--
292-- INV-CLOSE: Local endpoints should never point to remote endpoint in closed
296-- INV-CLOSE: Local endpoints should never point to remote endpoint in closed
293−-- state. Whenever we put an endpoint in closed state we remove that
297+-- state. Whenever we put an endpoint in Closed state we remove that
294-- endpoint from localConnections first, so that if a concurrent thread reads
298-- endpoint from localConnections first, so that if a concurrent thread reads
295-- the MVar, finds RemoteEndPointClosed, and then looks up the endpoint in
299-- the MVar, finds RemoteEndPointClosed, and then looks up the endpoint in
296-- localConnections it is guaranteed to either find a different remote
300-- localConnections it is guaranteed to either find a different remote