* Re: [PATCH] check_client_connection: use tcp state on linux
@ 2017-03-07 22:50 9% ` Eric Wong
0 siblings, 0 replies; 1+ results
From: Eric Wong @ 2017-03-07 22:50 UTC (permalink / raw)
To: Simon Eskildsen; +Cc: unicorn-public, Aman Gupta
Simon Eskildsen <simon.eskildsen@shopify.com> wrote:
> Here's another update Eric!
Thanks, a few teeny issues fixed up locally (but commented
inline, below).
However, there's a bigger problem which I'm Cc:-ing Aman about
for tmm1/gctools changing process_client in the internal API.
I won't burden him maintaining extra versions, nor will I force
users to use a certain version of unicorn or gctools to match.
Aman: for reference, relevant messages in the archives:
https://bogomips.org/unicorn-public/?q=d:20170222-+check_client_connection&x=t
(TL;DR: I don't expect Aman will have to do anything,
just keeping him in the loop)
> +++ b/lib/unicorn/http_server.rb
> @@ -558,8 +558,8 @@ def e100_response_write(client, env)
>
> # once a client is accepted, it is processed in its entirety here
> # in 3 easy steps: read request, call app, write app response
> - def process_client(client)
> - status, headers, body = @app.call(env = @request.read(client))
> + def process_client(client, listener)
> + status, headers, body = @app.call(env = @request.read(client, listener))
I can squash this fix in, locally:
diff --git a/lib/unicorn/oob_gc.rb b/lib/unicorn/oob_gc.rb
index 5572e59..74a1d51 100644
--- a/lib/unicorn/oob_gc.rb
+++ b/lib/unicorn/oob_gc.rb
@@ -67,8 +67,8 @@ def self.new(app, interval = 5, path = %r{\A/})
#:stopdoc:
PATH_INFO = "PATH_INFO"
- def process_client(client)
- super(client) # Unicorn::HttpServer#process_client
+ def process_client(client, listener)
+ super(client, listener) # Unicorn::HttpServer#process_client
if OOBGC_PATH =~ OOBGC_ENV[PATH_INFO] && ((@@nr -= 1) <= 0)
@@nr = OOBGC_INTERVAL
OOBGC_ENV.clear
However, https://github.com/tmm1/gctools also depends on this
undocumented internal API of ours; and I will not consider
breaking it for release...
Pushed to the "ccc-tcp" branch @ git://bogomips.org/unicorn
(commit beaee769c6553bf4e0260be2507b8235f0aa764f)
> begin
> return if @request.hijacked?
> @@ -655,7 +655,7 @@ def worker_loop(worker)
> # Unicorn::Worker#kgio_tryaccept is not like accept(2) at all,
> # but that will return false
> if client = sock.kgio_tryaccept
> - process_client(client)
> + process_client(client, sock)
> nr += 1
> worker.tick = time_now.to_i
> end
> @@ -28,6 +29,7 @@ class Unicorn::HttpParser
> # Drop these frozen strings when Ruby 2.2 becomes more prevalent,
> # 2.2+ optimizes hash assignments when used with literal string keys
> HTTP_RESPONSE_START = [ 'HTTP', '/1.1 ']
> + EMPTY_ARRAY = [].freeze
(minor) this was made before commit e06b699683738f22
("http_request: freeze constant strings passed IO#write")
but I've trivially fixed it up, locally.
> + def check_client_connection(socket, listener) # :nodoc:
> + if Kgio::TCPServer === listener
> + @@tcp_info ||= Raindrops::TCP_Info.new(socket)
> + @@tcp_info.get!(socket)
> + raise Errno::EPIPE, "client closed connection".freeze,
> EMPTY_ARRAY if closed_state?(@@tcp_info.state)
(minor) I needed to wrap that line since I use gigantic fonts
(fixed up locally)
^ permalink raw reply related [relevance 9%]
Results 1-1 of 1 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2017-02-25 14:03 [PATCH] check_client_connection: use tcp state on linux Simon Eskildsen
2017-02-25 16:19 ` Simon Eskildsen
2017-02-25 23:12 ` Eric Wong
2017-02-27 11:44 ` Simon Eskildsen
2017-02-28 21:12 ` Eric Wong
2017-03-01 3:18 ` Eric Wong
2017-03-06 21:32 ` Simon Eskildsen
2017-03-07 22:50 9% ` Eric Wong
Code repositories for project(s) associated with this public inbox
https://yhbt.net/unicorn.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).