Skip to content

Commit

Permalink
Minor clarifications.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Jan 15, 2025
1 parent 6dcaba7 commit b0947e6
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions ext/io/event/interrupt.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,11 @@ void IO_Event_Interrupt_signal(struct IO_Event_Interrupt *interrupt)
ssize_t result = write(interrupt->descriptor[1], ".", 1);

if (result == -1) {
if (errno == EAGAIN || errno == EWOULDBLOCK) return;

rb_sys_fail("IO_Event_Interrupt_signal:write");
if (errno == EAGAIN || errno == EWOULDBLOCK) {
// If we can't write to the pipe, it means the other end is full. In that case, we can be sure that the other end has already been woken up or is about to be woken up.
} else {
rb_sys_fail("IO_Event_Interrupt_signal:write");
}
}
}

Expand All @@ -107,9 +109,11 @@ void IO_Event_Interrupt_clear(struct IO_Event_Interrupt *interrupt)
ssize_t result = read(interrupt->descriptor[0], buffer, sizeof(buffer));

if (result == -1) {
if (errno == EAGAIN || errno == EWOULDBLOCK) return;

rb_sys_fail("IO_Event_Interrupt_clear:read");
if (errno == EAGAIN || errno == EWOULDBLOCK) {
// If we can't read from the pipe, it means the other end is empty. In that case, we can be sure that the other end is already clear.
} else {
rb_sys_fail("IO_Event_Interrupt_clear:read");
}
}
}
#endif

0 comments on commit b0947e6

Please sign in to comment.