From 3937b252145b584be6bbb0a4b753a2fdf86f8a44 Mon Sep 17 00:00:00 2001 From: Samuel Williams <samuel.williams@oriontransfer.co.nz> Date: Wed, 24 Apr 2024 15:14:55 +1200 Subject: [PATCH] Missed `async-io` in a few places... --- examples/fan-out/pipe.rb | 3 +-- examples/grace/server.rb | 2 +- examples/http/server.rb | 1 - examples/queue/server.rb | 2 +- lib/async/container/notify/server.rb | 14 +++----------- lib/async/container/notify/socket.rb | 9 ++++----- test.rb | 19 ------------------- 7 files changed, 10 insertions(+), 40 deletions(-) delete mode 100644 test.rb diff --git a/examples/fan-out/pipe.rb b/examples/fan-out/pipe.rb index e68876b..97c84fe 100755 --- a/examples/fan-out/pipe.rb +++ b/examples/fan-out/pipe.rb @@ -2,8 +2,7 @@ # frozen_string_literal: true # Released under the MIT License. -# Copyright, 2020-2022, by Samuel Williams. -# Copyright, 2020, by Olle Jonsson. +# Copyright, 2020-2024, by Samuel Williams. require 'async/container' diff --git a/examples/grace/server.rb b/examples/grace/server.rb index 0d26003..5a6b236 100755 --- a/examples/grace/server.rb +++ b/examples/grace/server.rb @@ -5,7 +5,7 @@ # Copyright, 2024, by Samuel Williams. require '../../lib/async/container' -require 'async/io/host_endpoint' +require 'io/endpoint/host_endpoint' Console.logger.debug! diff --git a/examples/http/server.rb b/examples/http/server.rb index 2298577..611fd29 100755 --- a/examples/http/server.rb +++ b/examples/http/server.rb @@ -8,7 +8,6 @@ require 'async/http/endpoint' require 'async/http/server' -require 'async/io/shared_endpoint' container = Async::Container::Forked.new diff --git a/examples/queue/server.rb b/examples/queue/server.rb index e63e7b0..159b205 100755 --- a/examples/queue/server.rb +++ b/examples/queue/server.rb @@ -2,7 +2,7 @@ # frozen_string_literal: true # Released under the MIT License. -# Copyright, 2020-2022, by Samuel Williams. +# Copyright, 2020-2024, by Samuel Williams. require 'async' require 'async/container' diff --git a/lib/async/container/notify/server.rb b/lib/async/container/notify/server.rb index 17aaa1a..5ab2c6d 100644 --- a/lib/async/container/notify/server.rb +++ b/lib/async/container/notify/server.rb @@ -1,11 +1,9 @@ # frozen_string_literal: true # Released under the MIT License. -# Copyright, 2020-2022, by Samuel Williams. +# Copyright, 2020-2024, by Samuel Williams. # Copyright, 2020, by Olle Jonsson. -require 'async/io' -require 'async/io/unix_endpoint' require 'kernel/sync' require 'tmpdir' @@ -62,19 +60,13 @@ def bind class Context def initialize(path) @path = path - @endpoint = IO::Endpoint.unix(@path, ::Socket::SOCK_DGRAM) - - Sync do - @bound = @endpoint.bind - end + @bound = Addrinfo.unix(@path, ::Socket::SOCK_DGRAM).bind @state = {} end def close - Sync do - @bound.close - end + @bound.close File.unlink(@path) end diff --git a/lib/async/container/notify/socket.rb b/lib/async/container/notify/socket.rb index 6b01c39..f1bfdd1 100644 --- a/lib/async/container/notify/socket.rb +++ b/lib/async/container/notify/socket.rb @@ -1,12 +1,11 @@ # frozen_string_literal: true # Released under the MIT License. -# Copyright, 2020-2022, by Samuel Williams. +# Copyright, 2020-2024, by Samuel Williams. require_relative 'client' -require 'async/io' -require 'async/io/unix_endpoint' +require 'io/endpoint/unix_endpoint' require 'kernel/sync' module Async @@ -32,7 +31,7 @@ def self.open!(environment = ENV) # @parameter path [String] The path to the UNIX socket used for sending messages to the process manager. def initialize(path) @path = path - @endpoint = IO::Endpoint.unix(path, ::Socket::SOCK_DGRAM) + @endpoint = ::IO::Endpoint.unix(path, ::Socket::SOCK_DGRAM) end # Dump a message in the format requied by `sd_notify`. @@ -65,7 +64,7 @@ def send(**message) Sync do @endpoint.connect do |peer| - peer.send(data) + peer.sendmsg(data) end end end diff --git a/test.rb b/test.rb deleted file mode 100644 index dfb6076..0000000 --- a/test.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -Thread.handle_interrupt(RuntimeError => :never) do - Thread.current.raise(RuntimeError, "Queued error") - - puts "Pending interrupt: #{Thread.pending_interrupt?}" # true - - pid = Process.fork do - puts "Pending interrupt (child process): #{Thread.pending_interrupt?}" - Thread.handle_interrupt(RuntimeError => :immediate){} - end - - _, status = Process.waitpid2(pid) - puts "Child process status: #{status.inspect}" - - puts "Pending interrupt: #{Thread.pending_interrupt?}" # false -end - -puts "Exiting..."