From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 4222F1F934 for ; Sat, 9 Oct 2021 02:24:47 +0000 (UTC) From: Eric Wong To: yahns-public@yhbt.net Subject: [PATCH 1/3] do not sleep if signals are pending Date: Sat, 9 Oct 2021 02:24:44 +0000 Message-Id: <20211009022446.705-2-e@80x24.org> In-Reply-To: <20211009022446.705-1-e@80x24.org> References: <20211009022446.705-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: This should prevent missed/delayed wakeups if repeatedly kill(2)-ed. --- lib/yahns/server.rb | 3 ++- lib/yahns/server_mp.rb | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/yahns/server.rb b/lib/yahns/server.rb index d13c57e..208b5ee 100644 --- a/lib/yahns/server.rb +++ b/lib/yahns/server.rb @@ -476,7 +476,8 @@ def reap_reexec end def sp_sig_handle(alive) - @sev.wait_readable(alive ? nil : 0.01) + tout = alive ? (@sig_queue.empty? ? nil : 0) : 0.01 + @sev.wait_readable(tout) @sev.yahns_step case sig = @sig_queue.shift when :QUIT, :TERM, :INT diff --git a/lib/yahns/server_mp.rb b/lib/yahns/server_mp.rb index 5467674..d56d1ed 100644 --- a/lib/yahns/server_mp.rb +++ b/lib/yahns/server_mp.rb @@ -157,7 +157,8 @@ def run_mp_worker(worker) def mp_sig_handle(watch, alive) # not performance critical watch.delete_if { |io| io.to_io.closed? } - if r = select(watch, nil, nil, alive ? nil : 0.1) + tout = alive ? (@sig_queue.empty? ? nil : 0) : 0.01 + if r = select(watch, nil, nil, tout) r[0].each(&:yahns_step) end case @sig_queue.shift