git.iko.soy/distributed-process
on master help sign in
Enhance error messages for incoming connections.
12cdcfcFacundo Domínguez
src/Control/Distributed/Process/Node.hs+23−9
@@ -516,7 +516,8 @@ handleIncomingMessages node = go initConnectionState
516 . (incomingFrom theirAddr ^: Set.insert cid)
516 . (incomingFrom theirAddr ^: Set.insert cid)
517 $ st
517 $ st
518 )
518 )
519− else invalidRequest cid st ("unsupported reliability: "++show rel)
519+ else invalidRequest cid st $
520+ "attempt to connect with unsupported reliability " ++ show rel
520 NT.Received cid payload ->
521 NT.Received cid payload ->
521 case st ^. incomingAt cid of
522 case st ^. incomingAt cid of
522 Just (_, ToProc pid weakQueue) -> do
523 Just (_, ToProc pid weakQueue) -> do
@@ -549,7 +550,9 @@ handleIncomingMessages node = go initConnectionState
549 Just proc ->
550 Just proc ->
550 go (incomingAt cid ^= Just (src, ToProc pid (processWeakQ proc)) $ st)
551 go (incomingAt cid ^= Just (src, ToProc pid (processWeakQ proc)) $ st)
551 Nothing ->
552 Nothing ->
552− invalidRequest cid st "unknown local process id"
553+ invalidRequest cid st $
554+ "incoming attempt to connect to unknown process "
555+ ++ show pid
553 SendPortIdentifier chId -> do
556 SendPortIdentifier chId -> do
554 let lcid = sendPortLocalId chId
557 let lcid = sendPortLocalId chId
555 lpid = processLocalId (sendPortProcessId chId)
558 lpid = processLocalId (sendPortProcessId chId)
@@ -561,19 +564,28 @@ handleIncomingMessages node = go initConnectionState
561 Just channel ->
564 Just channel ->
562 go (incomingAt cid ^= Just (src, ToChan channel) $ st)
565 go (incomingAt cid ^= Just (src, ToChan channel) $ st)
563 Nothing ->
566 Nothing ->
564− invalidRequest cid st "unknown channel"
567+ invalidRequest cid st $
568+ "incoming attempt to connect to unknown channel of"
569+ ++ " process " ++ show (sendPortProcessId chId)
565 Nothing ->
570 Nothing ->
566− invalidRequest cid st "unknown process id"
571+ invalidRequest cid st $
572+ "incoming attempt to connect to channel of unknown"
573+ ++ " process " ++ show (sendPortProcessId chId)
567 NodeIdentifier nid ->
574 NodeIdentifier nid ->
568 if nid == localNodeId node
575 if nid == localNodeId node
569 then go (incomingAt cid ^= Just (src, ToNode) $ st)
576 then go (incomingAt cid ^= Just (src, ToNode) $ st)
570− else invalidRequest cid st "invalid node id"
577+ else invalidRequest cid st $
578+ "incoming attempt to connect to a different node -"
579+ ++ " I'm " ++ show (localNodeId node)
580+ ++ " but the remote peer wants to connect to "
581+ ++ show nid
571 Nothing ->
582 Nothing ->
572− invalidRequest cid st "invalid request target"
583+ invalidRequest cid st
584+ "message received from an unknown connection"
573 NT.ConnectionClosed cid ->
585 NT.ConnectionClosed cid ->
574 case st ^. incomingAt cid of
586 case st ^. incomingAt cid of
575 Nothing ->
587 Nothing ->
576− invalidRequest cid st "closed unknown connection id"
588+ invalidRequest cid st "closed unknown connection"
577 Just (src, _) -> do
589 Just (src, _) -> do
578 trace node (MxDisconnected cid src)
590 trace node (MxDisconnected cid src)
579 go ( (incomingAt cid ^= Nothing)
591 go ( (incomingAt cid ^= Nothing)
@@ -610,8 +622,10 @@ handleIncomingMessages node = go initConnectionState
610 -- node. That is, we should report the remote node as having died, and we
622 -- node. That is, we should report the remote node as having died, and we
611 -- should close incoming connections (this requires a Transport layer
623 -- should close incoming connections (this requires a Transport layer
612 -- extension).
624 -- extension).
613− traceEventFmtIO node "" [(TraceStr $ " [network] invalid request ("++msg++"): "),
625+ traceEventFmtIO node "" [ TraceStr $ " [network] invalid request"
626+ ++ " (" ++ msg ++ "): "
614− (Trace cid)]
627+ , (Trace cid)
628+ ]
615 go ( incomingAt cid ^= Nothing
629 go ( incomingAt cid ^= Nothing
616 $ st
630 $ st
617 )
631 )