Skip to content

Don't unconditionally ref task when blocking on a pipe #3139

Closed
@eholk

Description

@eholk

9f287c2 added ref counting for tasks blocking on pipes to avoid a race that happens during shutdown. This should only be necessary in the select case. When receiving from one pipe, the receiver will definitely block, so we don't have to worry about it shutting down before the sender wakes it up.

I propose using the low bit of the task pointer that goes in the packet header to indicate whether it is a strong or weak reference. The sender is responsible for dropping strong references, but not weak ones, since the receiver won't increment the task ref count when it stores a weak reference.

The rule would then be to use a strong reference in select (via mark_blocked), and use a weak reference for receive.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-concurrencyArea: ConcurrencyI-slowIssue: Problems and improvements with respect to performance of generated code.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions