Skip to content

Commit 5268b41

Browse files
committed
Avoid rescheduling threads.
1 parent 791e7ce commit 5268b41

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

thread.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1824,7 +1824,7 @@ rb_thread_io_blocking_region(rb_io_t *fptr, rb_blocking_function_t *func, void *
18241824
BLOCKING_REGION(blocking_node.thread, {
18251825
val = func(data1);
18261826
saved_errno = errno;
1827-
}, ubf_select, blocking_node.thread, FALSE);
1827+
}, NULL /* ubf_select */, blocking_node.thread, FALSE);
18281828
}
18291829
EC_POP_TAG();
18301830

@@ -2589,12 +2589,13 @@ rb_notify_io_close(struct rb_io_t *fptr)
25892589
int count = 0;
25902590

25912591
while (true) {
2592-
struct rb_io_blocking_node *blocking_node = list_top(&fptr->blocking_list, struct rb_io_blocking_node, list);
2592+
struct rb_io_blocking_node *blocking_node = list_pop(&fptr->blocking_list, struct rb_io_blocking_node, list);
25932593
if (blocking_node == NULL) break;
25942594

25952595
rb_threadptr_pending_interrupt_enque(blocking_node->thread, error);
2596+
2597+
// This operation is slow:
25962598
rb_threadptr_interrupt(blocking_node->thread);
2597-
rb_thread_schedule();
25982599

25992600
count += 1;
26002601
}

0 commit comments

Comments
 (0)