From: Eric Wong <email@example.com>
To: Jean Boussier <firstname.lastname@example.org>
Subject: Re: [PATCH] Get rid of Kgio
Date: Fri, 8 Jul 2022 19:20:23 +0000 [thread overview]
Message-ID: <20220708192023.M250152@dcvr> (raw)
Jean Boussier <email@example.com> wrote:
> As discussed kgio is no longer absolutely necessary.
> We can use Ruby 2+ non blocking IO capabilities instead.
I think there was a misunderstanding, here. I meant kgio wasn't
necessary for new process management code. Notes inline...
> diff --git a/lib/unicorn/http_server.rb b/lib/unicorn/http_server.rb
> index 21f2a05..98cd119 100644
> --- a/lib/unicorn/http_server.rb
> +++ b/lib/unicorn/http_server.rb
> @@ -733,9 +742,15 @@ def worker_loop(worker)
> reopen = reopen_worker_logs(worker.nr) if reopen
> worker.tick = time_now.to_i
> while sock = ready.shift
> - # Unicorn::Worker#kgio_tryaccept is not like accept(2) at all,
> + # Unicorn::Worker#accept_nonblock is not like accept(2) at all,
> # but that will return false
> - if client = sock.kgio_tryaccept
> + client = begin
> + sock.accept_nonblock
> + rescue Errno::EAGAIN
> + false
> + end
Exception garbage in hotter code paths like accept_nonblock was
the reason kgio exists, especially for trivial Rack apps I tend
to write. Ruby 2.3+ added `exception: false' to accept_nonblock.
It's less bad for Linux nowadays with EPOLLEXCLUSIVE, but that's
> diff --git a/lib/unicorn/stream_input.rb b/lib/unicorn/stream_input.rb
> index 41d28a0..3241ff4 100644
> --- a/lib/unicorn/stream_input.rb
> +++ b/lib/unicorn/stream_input.rb
> @@ -72,8 +77,7 @@ def read(length = nil, rv = '')
> # Returns nil if called at the end of file.
> # This takes zero arguments for strict Rack::Lint compatibility,
> # unlike IO#gets.
> - def gets
> - sep = $/
> + def gets(sep = $/)
> if sep.nil?
> read_all(rv = '')
> return rv.empty? ? nil : rv
This change to #gets is unrelated and should've belonged in a
separate commit. But the change itself seems wrong, too, given
what Rack::Lint enforces. Note the comment above the method.
I also just checked current Rack::Lint::InputWrapper#gets,
and it still forbids args.
next prev parent reply other threads:[~2022-07-08 19:20 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-08 13:17 [PATCH] Get rid of Kgio Jean Boussier
2022-07-08 19:20 ` Eric Wong [this message]
2022-07-08 20:13 ` Jean Boussier
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:
List information: https://yhbt.net/unicorn/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
* 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
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).