From: Eric Wong <e@80x24.org>
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 [thread overview]
Message-ID: <20211009022446.705-2-e@80x24.org> (raw)
In-Reply-To: <20211009022446.705-1-e@80x24.org>
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
next prev parent reply other threads:[~2021-10-09 2:24 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-09 2:24 [PATCH 0/3] various minor bugfixes Eric Wong
2021-10-09 2:24 ` Eric Wong [this message]
2021-10-09 2:24 ` [PATCH 2/3] server: workaround Linux v5.5..v5.13 epoll bug Eric Wong
2021-10-09 2:24 ` [PATCH 3/3] gemspec: allow unicorn 6.x Eric Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://yhbt.net/yahns/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211009022446.705-2-e@80x24.org \
--to=e@80x24.org \
--cc=yahns-public@yhbt.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
http://yhbt.net/yahns.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).