Skip to content

spawnChannel might wait indefinitely #271

Open
@edsko

Description

@edsko

If the remote process (or node, or the connection, ..) dies before it manages to send a SendPort back to us, we will wait forever. Instead, spawnChannel should monitor the remote process and if dies, construct a "null port", just like spawn does:

nullSendPort :: ProcessId -> SendPort a
nullSendPort nullPid = SendPort (SendPortId nullPid 0)

fromMaybeSendPort :: ProcessId -> Maybe (SendPort a) -> SendPort a
fromMaybeSendPort _   (Just sendPort) = sendPort
fromMaybeSendPort pid Nothing         = nullSendPort pid

Monitoring such a null port has the intended effect (the monitor will fire immediately).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions