summaryrefslogtreecommitdiff
path: root/internal/thread.h
diff options
context:
space:
mode:
authorKJ Tsanaktsidis <[email protected]>2024-09-13 17:40:30 +1000
committerKJ Tsanaktsidis <[email protected]>2024-09-17 10:11:44 +1000
commite08d5239b68ad61a731f4938cf963e37a5e88c25 (patch)
tree85960f18ac3f470a73cd2641ef1636ef00f7eda7 /internal/thread.h
parent50d4840bd975a5e187c56dc4a56795cb6d02d658 (diff)
Ensure fiber scheduler is woken up when close interrupts read
If one thread is reading and another closes that socket, the close blocks waiting for the read to abort cleanly. This ensures that Ruby is totally done with the file descriptor _BEFORE_ we tell the OS to close and potentially re-use it. When the read is correctly terminated, the close should be unblocked. That currently works if closing is happening on a thread, but if it's happening on a fiber with a fiber scheduler, it does NOT work. This patch ensures that if the close happened in a fiber scheduled thread, that the scheduler is notified that the fiber is unblocked. [Bug #20723]
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/11614
Diffstat (limited to 'internal/thread.h')
-rw-r--r--internal/thread.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/internal/thread.h b/internal/thread.h
index a2926febc3..e079ebb22b 100644
--- a/internal/thread.h
+++ b/internal/thread.h
@@ -60,6 +60,7 @@ int rb_thread_wait_for_single_fd(int fd, int events, struct timeval * timeout);
struct rb_io_close_wait_list {
struct ccan_list_head pending_fd_users;
VALUE closing_thread;
+ VALUE closing_fiber;
VALUE wakeup_mutex;
};
int rb_notify_fd_close(int fd, struct rb_io_close_wait_list *busy);