Skip to content

Commit a9f0108

Browse files
committed
Refactor IOOperations.poll and restore thread status in ensure clause
1 parent a4c93d0 commit a9f0108

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/main/ruby/truffleruby/core/truffle/io_operations.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,12 @@ def self.poll(io, event_mask, timeout)
263263
# Don't mark Truffle::POSIX.truffleposix_poll_single_fd as blocking because
264264
# then it would automatically retry on EINTR without considering/adjusting the timeout.
265265
status = Primitive.thread_set_status(Thread.current, :sleep)
266-
returned_events = Truffle::POSIX.truffleposix_poll_single_fd(Primitive.io_fd(io), event_mask, remaining_timeout)
267-
Primitive.thread_set_status(Thread.current, status)
266+
267+
begin
268+
returned_events = Truffle::POSIX.truffleposix_poll_single_fd(Primitive.io_fd(io), event_mask, remaining_timeout)
269+
ensure
270+
Primitive.thread_set_status(Thread.current, status)
271+
end
268272

269273
result =
270274
if returned_events < 0

0 commit comments

Comments
 (0)