@@ -197,7 +197,7 @@ forkProcess node proc = modifyMVar (localState node) $ \st -> do
201handleIncomingMessages :: LocalNode -> IO ()
201handleIncomingMessages :: LocalNode -> IO ()
202handleIncomingMessages node = go [] Map.empty Map.empty Set.empty
202handleIncomingMessages node = go [] Map.empty Map.empty Set.empty
@@ -210,6 +210,8 @@ handleIncomingMessages node = go [] Map.empty Map.empty Set.empty
210 event <- NT.receive endpoint
210 event <- NT.receive endpoint
211 case event of
211 case event of
212 NT.ConnectionOpened cid _rel _theirAddr ->
212 NT.ConnectionOpened cid _rel _theirAddr ->
213+ -- TODO: Check if _rel is ReliableOrdered, and if not, treat as
213 go (cid : uninitConns) procs chans ctrls
215 go (cid : uninitConns) procs chans ctrls
214 NT.Received cid payload ->
216 NT.Received cid payload ->
215 case ( Map.lookup cid procs
217 case ( Map.lookup cid procs
@@ -240,10 +242,12 @@ handleIncomingMessages node = go [] Map.empty Map.empty Set.empty
241 Nothing ->
243 Nothing ->
242 -- Request for an unknown process.
244 -- Request for an unknown process.
243− -- TODO: We should close the incoming connection here, but
245+ --
244− -- we cannot! Network.Transport does not provide this
246+ -- TODO: We should treat this as a fatal error on the
245− -- functionality. Not sure what the right approach is.
247+ -- part of the remote node. That is, we should report the
246− -- For now, we just drop the incoming messages
248+ -- remote node as having died, and we should close
249+ -- incoming connections (this requires a Transport layer
247 go (List.delete cid uninitConns) procs chans ctrls
251 go (List.delete cid uninitConns) procs chans ctrls
248 ChannelIdentifier chId -> do
252 ChannelIdentifier chId -> do
249 let lcid = channelLocalId chId
253 let lcid = channelLocalId chId
@@ -259,8 +263,12 @@ handleIncomingMessages node = go [] Map.empty Map.empty Set.empty
259 (Map.insert cid channel chans)
263 (Map.insert cid channel chans)
261 Nothing ->
265 Nothing ->
266+ -- Unknown typed channel
262 go (List.delete cid uninitConns) procs chans ctrls
268 go (List.delete cid uninitConns) procs chans ctrls
263 Nothing ->
269 Nothing ->
264 go (List.delete cid uninitConns) procs chans ctrls
272 go (List.delete cid uninitConns) procs chans ctrls
265 NodeIdentifier _ ->
273 NodeIdentifier _ ->
266 go (List.delete cid uninitConns)
274 go (List.delete cid uninitConns)
@@ -268,7 +276,8 @@ handleIncomingMessages node = go [] Map.empty Map.empty Set.empty
269 (Set.insert cid ctrls)
277 (Set.insert cid ctrls)
271− -- Unexpected message. We just drop it.
279+ -- Unexpected message
272 go uninitConns procs chans ctrls
281 go uninitConns procs chans ctrls
273 NT.ConnectionClosed cid ->
282 NT.ConnectionClosed cid ->
274 go (List.delete cid uninitConns)
283 go (List.delete cid uninitConns)
@@ -283,9 +292,9 @@ handleIncomingMessages node = go [] Map.empty Map.empty Set.empty
283 , ctrlMsgSignal = Died nid DiedDisconnect
292 , ctrlMsgSignal = Died nid DiedDisconnect
285 NT.ErrorEvent (NT.TransportError (NT.EventConnectionLost Nothing _) _) ->
294 NT.ErrorEvent (NT.TransportError (NT.EventConnectionLost Nothing _) _) ->
286− -- We cannot really deal with the case that some (but not all)
295+ -- TODO: We should treat an asymetrical connection loss (incoming
287− -- incoming connections from a remote node have failed (what if this
296+ -- connection broken, but outgoing connection still potentially ok)
288− -- incoming connection corresponds to a typed channel, for instance?)
297+ -- as a fatal error on the part of the remote node (like (**), above)
289 fail "handleIncomingMessages: TODO"
298 fail "handleIncomingMessages: TODO"
290 NT.ErrorEvent (NT.TransportError NT.EventEndPointFailed str) ->
299 NT.ErrorEvent (NT.TransportError NT.EventEndPointFailed str) ->
291 fail $ "Cloud Haskell fatal error: end point failed: " ++ str
300 fail $ "Cloud Haskell fatal error: end point failed: " ++ str