Skip to content

Muted connections can't detect peer close #243

@SeanTAllen

Description

@SeanTAllen

When a connection is muted, _read() returns immediately at the mute check (line 1184 in tcp_connection.pony) without reading from the socket. On POSIX with edge-triggered oneshot events, no further readable events arrive until PonyAsio.resubscribe_read() is called. This means a muted connection can never detect that the peer has closed or gone away.

For the normal mute use case (backpressure), the application will eventually unmute and the close will be detected then. But if the application mutes and never unmutes, or the peer dies while muted, the connection leaks forever — the actor stays alive with a subscribed ASIO event, preventing the Pony runtime from exiting.

The idle timeout feature partially mitigates this (it fires even while muted), but without an idle timeout configured, a muted connection with a dead peer is permanently leaked.

Closing out a muted connection shouldn't leave junk around. The complexity of detecting peer close during mute should be handled by lori, not pushed to the user.

Discovered while debugging a test hang in #241.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationhelp wantedExtra attention is needed

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions