Skip to content

Conversation

@Freax13
Copy link
Owner

@Freax13 Freax13 commented Aug 30, 2025

Opening a read-only or write-only pipe blocks until a pipe with opposite access or a read-write pipe is opened.

The old implementation had the following race-condition:

  1. Open a read-only pipe.
  2. Check if there's a write-only or read-write pipe. a) No, there isn't, so this blocks.
  3. Open a write-only or read-write pipe. a) This doesn't block because there's already a read-only pipe waiting.
  4. Notify the read-only pipe so that it can redo the check from step 2.
  5. Close the pipe from step 3.
  6. The read-only pipe receives the notification and checks again. a) There aren't any write-only/read-write pipes alive right now, so open continues to block.

Opening a read-only pipe should succeed when a write-only/read-write pipe is opened even when that pipe is already closed by the time opening the read-only pipe finishes.

This didn't apply just to read-only pipes, but also write-only pipes.

Opening a read-only or write-only pipe blocks until a pipe with
opposite access or a read-write pipe is opened.

The old implementation had the following race-condition:
1. Open a read-only pipe.
2. Check if there's a write-only or read-write pipe.
  a) No, there isn't, so this blocks.
3. Open a write-only or read-write pipe.
  a) This doesn't block because there's already a read-only pipe
     waiting.
4. Notify the read-only pipe so that it can redo the check from step 2.
5. Close the pipe from step 3.
6. The read-only pipe receives the notification and checks again.
  a) There aren't any write-only/read-write pipes alive right now, so
     open continues to block.

Opening a read-only pipe should succeed when a write-only/read-write
pipe is opened even when that pipe is already closed by the time
opening the read-only pipe finishes.

This didn't apply just to read-only pipes, but also write-only pipes.
@Freax13 Freax13 enabled auto-merge August 30, 2025 11:10
@Freax13 Freax13 merged commit 1f02680 into main Aug 30, 2025
82 checks passed
@Freax13 Freax13 deleted the fix/named-pipe-open-race-condition branch August 30, 2025 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants