[PATCH] favor Class.new for method-less classes

2015-02-06 Thread Eric Wong
This saves over 400 bytes on x86-64. --- lib/yahns.rb | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/yahns.rb b/lib/yahns.rb index fd84223..b4a8bbe 100644 --- a/lib/yahns.rb +++ b/lib/yahns.rb @@ -50,11 +50,9 @@ module Yahns # :nodoc: # application dispatch.

[PATCH] use the monotonic clock under Ruby 2.1+

2015-02-05 Thread Eric Wong
The monotonic clock is immune to time adjustments so it is not thrown off by misconfigured clocks. Process.clock_gettime also generates less garbage on 64-bit systems due to the use of Flonum. --- lib/yahns.rb | 13 + lib/yahns/client_expire_generic.rb | 2 +-

[PATCH] avoid EPOLL_CTL_DEL calls on rack.hijack

2015-03-17 Thread Eric Wong
We will support un-hijacking, so the repeated ep_insert/ep_remove sequences in the kernel will get expensive and complicated for our user-land code, too. --- lib/yahns/http_client.rb | 10 +- lib/yahns/queue_epoll.rb | 11 --- lib/yahns/queue_kqueue.rb | 6 -- 3 files

Re: [PATCH 2/2] wbuf: avoid corrupted large responses with zero-copy sendfile

2015-03-07 Thread Eric Wong
Eric Wong e...@80x24.org wrote: This bug is noticeable on a amd64 FreeBSD 9.2 VM, and possible under Linux, too. This happens as a zero-copy sendfile implementation means pages queued for transmission by the sendfile system call should not be modified at any point after the sendfile syscall

[[RFC]] http_client: hijack after 100-continue disables HTTP response

2015-03-13 Thread Eric Wong
While rack.hijack usage during application dispatch normally prevents yahns from writing an HTTP response out of the Rack response array, this was not correctly prevented when the application emitted a 100-continue response when the client was was too slow to read the 100-continue response without

[PATCH 0/3] towards becoming a fully-buffering reverse proxy

2015-03-13 Thread Eric Wong
The goal is to allow yahns to become an alternative to nginx for users running pre-forking HTTP application servers. Some users are uncomfortable with the commercialized, open core nature of nginx nowadays and would rather use a non-commercial server. Technically all the pieces are already in

[PATCH 3/3] proxy_pass: officially become a part of yahns

2015-03-13 Thread Eric Wong
/{test_extras_proxy_pass.rb = test_proxy_pass.rb} (93%) diff --git a/extras/proxy_pass.rb b/extras/proxy_pass.rb index 00adf18..af6fb7c 100644 --- a/extras/proxy_pass.rb +++ b/extras/proxy_pass.rb @@ -1,215 +1,9 @@ -# -*- encoding: binary -*- -# Copyright (C) 2013, Eric Wong normalper...@yhbt.net and all contributors

[PATCH] avoid unnecessary calls #to_sym for __send__

2015-03-12 Thread Eric Wong
No point in bloating our bytecode for single-use variables. --- extras/proxy_pass.rb| 2 +- lib/yahns/rackup_handler.rb | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/extras/proxy_pass.rb b/extras/proxy_pass.rb index 08f9730..15cbae5 100644 --- a/extras/proxy_pass.rb

[ANN] yahns 1.6.0 -_- sleepy app server for Ruby

2015-03-09 Thread Eric Wong
A Free Software, multi-threaded, non-blocking network application server designed for low _idle_ power consumption. It is primarily optimized for applications with occasional users which see little or no traffic. yahns currently hosts Rack/HTTP applications, but may eventually support other

[PATCH] test/test_server: fix leftover process from inherit test

2015-03-09 Thread Eric Wong
Oops, this test bug was introduced in: commit e413325737f23c5ec27a02246f95077bc1fb038d (acceptor: close inherited-but-unneeded sockets) --- test/test_server.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/test_server.rb b/test/test_server.rb index b7cb3e6..0410f65

[PATCH 1/3] extras/proxy_pass: do not name unused variable

2015-03-03 Thread Eric Wong
ruby -w warns on it. --- extras/proxy_pass.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extras/proxy_pass.rb b/extras/proxy_pass.rb index b1697db..8a32cac 100644 --- a/extras/proxy_pass.rb +++ b/extras/proxy_pass.rb @@ -170,7 +170,7 @@ class ProxyPass # :nodoc:

[PATCH] http_client: preserve HTTP state after hijack

2015-04-02 Thread Eric Wong
We'll be supporting un-hijacking a client socket for proxy_pass and we must preserve state for pipelined requests. --- lib/yahns/http_client.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/yahns/http_client.rb b/lib/yahns/http_client.rb index 46ea3ec..164cac9 100644 ---

[PATCH] allow vector args to wbuf_write

2015-04-02 Thread Eric Wong
This allows us to write chunked response bodies without extra copying to clients which support streaming. --- lib/yahns/wbuf.rb | 16 ++-- 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/yahns/wbuf.rb b/lib/yahns/wbuf.rb index ba7ea0f..fa39b9b 100644 ---

Re: [PATCH] proxy_pass: fix race condition due to flawed hijack check

2015-04-21 Thread Eric Wong
Pushed as commit 5328992829b2ff76cd7cda6d1911ecad70f0e8c2 additional burst test for pipelining and additional comment about queue_mod being a hand-off point for the object hitting another thread: +# n.b. we may not touch anything in this object once we call queue_mod, +# another thread is

[ANN] yahns 1.7.0 -_- sleepy app server for Ruby

2015-05-10 Thread Eric Wong
A Free Software, multi-threaded, non-blocking network application server designed for low _idle_ power consumption. It is primarily optimized for applications with occasional users which see little or no traffic. yahns currently hosts Rack/HTTP applications, but may eventually support other

Re: What would happen if a worker thread died?

2015-05-09 Thread Eric Wong
Lin Jen-Shin (godfat) god...@godfat.org wrote: On Sat, May 9, 2015 at 9:03 AM, Eric Wong e...@80x24.org wrote: Below, I'm choosing to both leave the socket open and keep the worker running to slow down a potentially malicious client if this happens and to hopefully prevent an evil client

[PATCH] ssl: ensure rack.hijack users get normal IO methods

2015-05-08 Thread Eric Wong
We do not want rack.hijack users relying on kgio_* methods since kgio is trying to make itself obsolete (as Ruby itself adopts kgio features). This is a bit wonky since our common case tries to minimize object allocation by only using the Kgio::Socket derived class. ---

[PATCH] proxy_pass: fix race condition due to ensure

2015-05-08 Thread Eric Wong
When calling proxy_busy_mod_blocked to re-enable a descriptor via epoll, the ensure block is dangerous because the ensure clause modifies the object after the ReqRes is injected into epoll. This is extremely dangerous as we give up exclusive access to the object once we call epoll_ctl. This

Re: What would happen if a worker thread died?

2015-05-08 Thread Eric Wong
Lin Jen-Shin (godfat) god...@godfat.org wrote: On Sat, May 9, 2015 at 1:03 AM, Eric Wong e...@80x24.org wrote: It's unfortunately difficult to detect thread death from ruby (no SIGCHLD handler unlike for processes) besides polling Thread#join We had this issue in ruby-core a few years

[RFC] proxy_pass: possibly avoid breaking some middlewares

2015-04-07 Thread Eric Wong
Running this on http://yhbt.net/yahns-public/ for now. I originally I forgot to disable one of my throwaway middlewares which was not aware of Rack hijacking. From: Eric Wong e...@80x24.org Subject: [PATCH] proxy_pass: possibly avoid breaking some middlewares hijack seems incompatible with many

[PATCH 4/4] proxy_pass: more tests for giant headers and truncations

2015-04-03 Thread Eric Wong
We need to ensure more uncommon cases such as gigantic upstream headers and truncated upstream responses are handled properly and predictably. --- lib/yahns/proxy_http_response.rb | 9 -- test/test_proxy_pass.rb | 62 ++-- 2 files changed, 66

[PATCH 0/4] proxy_pass updates

2015-04-03 Thread Eric Wong
Test coverage for common cases is pretty good by now, one major bugfix for giant uploads. We still need to handle HTTP trailers properly in both directions. lib/yahns/proxy_http_response.rb | 9 +- lib/yahns/proxy_pass.rb | 5 +- test/test_proxy_pass.rb | 190

Re: [RFC] proxy_pass: possibly avoid breaking some middlewares

2015-04-08 Thread Eric Wong
Lin Jen-Shin (godfat) god...@godfat.org wrote: On Wed, Apr 8, 2015 at 5:34 AM, Eric Wong e...@80x24.org wrote: +# this probably breaks fewer middlewares than returning whatever else... +[ 500, [], [] ] You probably meant [ 500, {}, [] ] here? No, arrays work fine, Rack headers

beware of lowering TCP buffer sizes under Linux

2015-05-20 Thread Eric Wong
On Linux, the (currently) excessively large memory buffers size defaults hide some bugs in the TCP implementation regarding edge-triggered epoll wakeups. Setting low :sndbuf values (or lowering tcp_wmem/tcp_mem) can cause problems) for servers using edge-triggered I/O. yahns uses one-shot epoll

[PATCH] test/helper: warn atomically

2015-06-15 Thread Eric Wong
We want to avoid race conditions if tests become multithreaded from Kernel#warn internally issuing a second write. --- test/helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/helper.rb b/test/helper.rb index 7b8c1aa..c86f3e3 100644 --- a/test/helper.rb +++

[PATCH] gemspec fixes for various RubyGems versions

2015-10-15 Thread Eric Wong
Version may not be frozen in some RubyGems versions, so we must dup it. Use a SPDX-compatible license string for GPL-3.0+, too (RubyGems still complains, for now) --- yahns.gemspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/yahns.gemspec b/yahns.gemspec index

[PATCH] use olddoc 1.1.0 for generating NEWS + NEWS.atom.xml

2015-10-15 Thread Eric Wong
news as a text file' -task "NEWS" do - fp = Tempfile.new("NEWS", ".") - fp.sync = true - time = nil - tags.each do |tag| -time ||= tag[:time_obj] -line = tag[:subject] + " / " + tag[:time].sub(/T.*/, '') - fp.puts line -fp.puts("-" * line

[PUSHED] copyright updates

2015-10-13 Thread Eric Wong
Future updates may use the update-copyright script in gnulib: git ls-files | UPDATE_COPYRIGHT_HOLDER='all contributors' \ UPDATE_COPYRIGHT_USE_INTERVALS=2 \ xargs /path/to/gnulib/build-aux/update-copyright --- Giant patch which touches nearly every single file:

[PATCH] proxy_pass: quiet down ECONNRESET and EPIPE, too

2015-10-03 Thread Eric Wong
Clients may disconnect on us while we're writing the response here, so we should shut the backtrace up to avoid polluting logs. --- lib/yahns/proxy_pass.rb | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/yahns/proxy_pass.rb b/lib/yahns/proxy_pass.rb index

[PATCH] README: clarify and update copyright year

2015-12-04 Thread Eric Wong
This is no place to advertise weirdo projects. --- README | 8 +++- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/README b/README index e1ca3a6..1219a7e 100644 --- a/README +++ b/README @@ -55,19 +55,17 @@ Contact We are happy to see feedback of all types via plain-text

[WIP] rely on optimized case dispatch

2015-12-04 Thread Eric Wong
In the future, Ruby may optimize case dispatch for additional immediate values such as `nil', `true', and `false'. Rearrange our case statements (and take away some safety-checks :x) to take advantage of these (to-be-done) optimizations. Note: totally untested at the moment and the changes to

[PATCH] openssl_client: use `exception: false' for accept_nonblock

2015-12-12 Thread Eric Wong
Ruby 2.3 will support this feature to reduce allocations for common errors. --- lib/yahns/openssl_client.rb | 27 +++ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/lib/yahns/openssl_client.rb b/lib/yahns/openssl_client.rb index ffa4b3e..246b407 100644 ---

[PATCH] use String#clear for short-lived buffers we create

2016-01-04 Thread Eric Wong
This should reduce memory pressure slightly as we can have finer-grained control of memory usage for buffers which can be several kilobytes large. It is not safe to do this for output buffers we get from the application, as they may reuse that memory themselves. --- lib/yahns/http_response.rb

[PATCH 2/2] proxy_pass: support "proxy_buffering: false"

2016-06-02 Thread Eric Wong
This may be useful to avoid wasting resources when proxying for an upstream which can already handle slow clients itself. It is impossible to completely disable buffering, this merely prevents gigantic amounts of buffering. This may be useful when an upstream can generate a gigantic response

[PATCH 3/5] cleanup graceful shutdown handling

2016-06-07 Thread Eric Wong
Using a 10ms tick was too little, use 100ms instead to avoid burning CPU. Ideally, we would not tick at all during shutdown (we're normally tickless); but the common case could be slightly more expensive; and shutdowns are rare (I hope). Then, change our process title to indicate we're shutting

[PATCH 4/5] proxy_pass: more descriptive error messages

2016-06-07 Thread Eric Wong
This should make it easier to figure out where certain errors are coming from and perhaps fix problems with upstreams, too. This helped me track down the problem causing public-inbox WWW component running under Perl v5.20.2 on my Debian jessie system to break and drop connections going through

[PATCH 2/5] queue_*: check for closed IO objects

2016-06-07 Thread Eric Wong
Using a high max_events may mean some IO objects are closed after they're retrieved from the kernel but before our Ruby process has had a chance to get to them. --- lib/yahns/queue_epoll.rb | 1 + lib/yahns/queue_kqueue.rb | 1 + 2 files changed, 2 insertions(+) diff --git

[PATCH 1/5] test_proxy_pass_no_buffering: fix racy test

2016-06-07 Thread Eric Wong
We can force output buffer files to a directory of our choosing to avoid being confused by temporary files from other tests polluting the process we care about. --- test/test_proxy_pass_no_buffering.rb | 13 ++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git

[PATCH \0/5] another round of proxy-related bugfixes!

2016-06-07 Thread Eric Wong
currently running code as is for a day or so, first. Anyways, yahns should be able to handle HTTPS termination for arbitrarily large responses without touching the FS. But generating the arbitrarily large responses efficiently (outside of yahns/Ruby) is still tricky :x Er

[PATCH 2/3] proxy_pass: redo "proxy_buffering: false"

2016-06-05 Thread Eric Wong
Relying on @body.close in Yahns::WbufCommon#wbuf_close_common to resume reading the upstream response was too subtle and potentially racy. Instead use a new Yahns::WbufLite class which does exactly what we want for implementing this feature, and nothing more. --- lib/yahns/proxy_http_response.rb

[ANN] yahns 1.12.5 -_- sleepy app server for Ruby

2016-06-05 Thread Eric Wong
A Free Software, multi-threaded, non-blocking network application server designed for low _idle_ power consumption. It is primarily optimized for applications with occasional users which see little or no traffic. yahns currently hosts Rack/HTTP applications, but may eventually support other

[PATCH] extras/try_gzip_static: do not show backtrace on syscall errors

2016-06-05 Thread Eric Wong
On ENAMETOOLONG and perhaps other system errors which we can do nothing about, we should not spew a giant backtrace which could be used as an easy DoS vector. --- extras/try_gzip_static.rb | 2 +- test/test_extras_try_gzip_static.rb | 12 2 files changed, 13 insertions(+),

[YUCK 0/2] wbuf_lite: fix write retries for OpenSSL

2016-06-05 Thread Eric Wong
ers; but it's still useful on private LANs and within VPNs (or hosting Tor hidden services). Eric Wong (2): wbuf: remove tmpdir parameter wbuf_lite: fix write retries for OpenSSL sockets lib/yahns/http_response.rb | 4 ++-- lib/yahns/proxy_http_response.rb | 2 +-

[PATCH 2/2] wbuf_lite: fix write retries for OpenSSL sockets

2016-06-05 Thread Eric Wong
OpenSSL can't handle write retries if we append to an existing string. Thus we must preserve the same string object upon retrying. Do that by utilizing the underlying Wbuf class which could already handles it transparently using trysendfile. However, we still avoiding the subtlety of

[PATCH] proxy_pass: X-Forwarded-For appends to existing list

2016-05-30 Thread Eric Wong
Ugh, this is a little slower, but some people will want to forward through multiple proxies. --- lib/yahns/proxy_pass.rb | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/yahns/proxy_pass.rb b/lib/yahns/proxy_pass.rb index 8e0b742..a30089d 100644 ---

[PATCH] gemspec: make rack a development dependency

2016-01-27 Thread Eric Wong
We don't depend on rack directly, and unicorn 5.1 will make rack optional. This seems reasonable for testing, but one day I could imagine this being more than an HTTP or Rack server... --- yahns.gemspec | 3 +++ 1 file changed, 3 insertions(+) diff --git a/yahns.gemspec b/yahns.gemspec index

[ANN] yahns 1.12.0 -_- sleepy app server for Ruby

2016-02-14 Thread Eric Wong
A Free Software, multi-threaded, non-blocking network application server designed for low _idle_ power consumption. It is primarily optimized for applications with occasional users which see little or no traffic. yahns currently hosts Rack/HTTP applications, but may eventually support other

yahns vs unicorn, part 2: accepting connections

2016-04-12 Thread Eric Wong
Both servers have the ability to bind and listen on multiple Unix or TCP sockets and share them across multiple worker processes, but that's where the similarities end. While yahns is marketed as a "non-blocking application server", yahns actually uses the blocking accept(2) syscall (or

[ANN] yahns 1.12.3 -_- sleepy app server for Ruby

2016-04-08 Thread Eric Wong
A Free Software, multi-threaded, non-blocking network application server designed for low _idle_ power consumption. It is primarily optimized for applications with occasional users which see little or no traffic. yahns currently hosts Rack/HTTP applications, but may eventually support other

[PATCH] extras/exec_cgi: document cgit example

2016-04-25 Thread Eric Wong
Apparently this can be useful to some people. --- extras/exec_cgi.rb | 8 1 file changed, 8 insertions(+) diff --git a/extras/exec_cgi.rb b/extras/exec_cgi.rb index 3091cfb..2183d23 100644 --- a/extras/exec_cgi.rb +++ b/extras/exec_cgi.rb @@ -12,6 +12,14 @@ # (delfater: ensure that

[PATCH] document Rack::Chunked/ContentLength semi-requirements

2016-04-29 Thread Eric Wong
Ugh, it sucks that other servers are so tolerant of violations of the Rack spec. Rainbows! had the same problem: https://bogomips.org/rainbows-public/20140704195032.ga13...@dcvr.yhbt.net/ --- Comments on wording clarity? Asynchronous spaghetti messed me brain up :X

[PATCH 2/5] wbuf: drop persistence if writing to client fails

2016-04-26 Thread Eric Wong
We cannot maintain a persistent connection to a client if writing to the client fails; so we can't proceed to let the app hijack the response. This may happen in the unlikely case where a response header needs to be buffered with a Wbuf (and the app uses response hijacking). ---

[PATCH 0/5] proxy_pass resource cleanup fixes

2016-04-26 Thread Eric Wong
Lightly-tested, I'm going to let these run on YHBT.net for a bit before cutting a new release. And all this proxy_pass stuff could still use some cleanup and refactoring, it's hairy! Eric Wong (5): test_proxy_pass: test for auto chunking on 1.0 backends wbuf: drop persistence

[PATCH 4/5] proxy_http_response: do not persist upstream on slow clients

2016-04-26 Thread Eric Wong
For slow clients, we want to be able to drop the connection to the upstream as soon as we are done buffering and not waste resources by leaving it in an :ignore state. We also need to remember the client for the fdmap to prevent shutdowns. Ugh, this is really hard to test locally. ---

[PATCH 3/5] proxy_http_response: cleanup: avoid redundant setting of "alive"

2016-04-26 Thread Eric Wong
We already check for the truthiness of "alive" in the "if" statement, so re-setting is pointless. --- lib/yahns/proxy_http_response.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/yahns/proxy_http_response.rb b/lib/yahns/proxy_http_response.rb index c8a2a42..e551323 100644 ---

[PATCH 5/5] proxy_pass: drop resources immediately on errors

2016-04-26 Thread Eric Wong
We don't want to wait on GC to reap sockets on errors, generational GC in Ruby is less aggressive about reaping long-lived objects such as long-lived HTTP connections. --- lib/yahns/proxy_http_response.rb | 7 ++- lib/yahns/proxy_pass.rb | 5 +++-- 2 files changed, 9 insertions(+), 3

[PATCH 1/5] test_proxy_pass: test for auto chunking on 1.0 backends

2016-04-26 Thread Eric Wong
These are followups to the following two commits: * commit d16326723d ("proxy_http_response: fix non-terminated fast responses, too") * commit 8c9f33a539 ("proxy_http_response: workaround non-terminated backends") --- test/test_proxy_pass.rb | 15 +++ 1 file changed, 15

[PATCH] proxy_http_response: fix non-terminated fast responses, too

2016-04-21 Thread Eric Wong
Without this, non-terminated backends were not properly supported if they gave tiny responses or responded faster than we could stream the response to the client. This is necessary to support fast responses from some non-Rack HTTP/1.0-only backend servers which rely on connection termination to

[PATCH] proxy_pass: honor wbuf_persist when ending response

2016-04-21 Thread Eric Wong
If a static file response gets truncated while writing, we set wbuf_persist to false in wbuf_flush of lib/yahns/wbuf_common.rb Thus, we must check wbuf_persist attribute as late as possible before yielding control back to the caller in proxy_response_finish --- A hopefully better version of what

[PATCH 1/7] proxy_pass: simplify writing request bodies upstream

2016-05-15 Thread Eric Wong
The cost of extra branches inside a loop is negligible compared to the cost of all the other method calls we make. Favor smaller code instead and inline some (now) single-use methods. Furthermore, this allows us to reuse the request header buffer instead of relying on thread-local storage and

[ANN] yahns 1.12.4 -_- sleepy app server for Ruby

2016-05-02 Thread Eric Wong
A Free Software, multi-threaded, non-blocking network application server designed for low _idle_ power consumption. It is primarily optimized for applications with occasional users which see little or no traffic. yahns currently hosts Rack/HTTP applications, but may eventually support other

[PATCH] http_client: set state to :ignore before hijack callback

2016-05-09 Thread Eric Wong
We need to set state as early as possible as any modification of our HttpClient object is unsafe after it is handed over to the underlying application. Otherwise, we could be clobbering a state set inside the hijack but before we hit the case statement in HttpClient#step_write. This bug should

Re: [PATCH] proxy_http_response: workaround non-terminated backends

2016-04-16 Thread Eric Wong
Eric Wong <e...@80x24.org> wrote: > @@ -232,7 +247,7 @@ def proxy_response_finish(kcar, wbuf, req_res) > end > > busy = wbuf.busy and return proxy_busy_mod_blocked(wbuf, busy) > -proxy_busy_mod_done(wbuf.wbuf_persist) # returns nil > +proxy_busy_mod_d

[PATCH 2/3] wbuf_lite: use StringIO instead of TmpIO

2016-07-12 Thread Eric Wong
This allows us to work transparently with our OpenSSL workaround[*] while allowing us to reuse our non-sendfile compatibility code. Unfortunately, this means we duplicate a lot of code from the normal wbuf code for now; but that should be fairly stable at this point. [*]

[PATCH 1/3] test_proxy_pass_no_buffering: exclude rb/ru files, too

2016-07-12 Thread Eric Wong
We may have temporary files lingering from concurrent multi-threaded tests in our forked child since FD_CLOFORK does not exist :P --- test/test_proxy_pass_no_buffering.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_proxy_pass_no_buffering.rb

[PATCH] test: skip some buffering tests on non-default values

2016-08-02 Thread Eric Wong
It's too hard to reliably test output buffering behavior with non-default values users sometimes set; so just skip and warn about it for now. ref: commit dad99b5ecd93cdf0a514ff9fb51d198f8aebb188 ("test/test_proxy_pass: remove buffer size tuning") --- test/helper.rb| 12

[PATCH 1/4] response: drop clients after HTTP responses of unknown length

2016-08-02 Thread Eric Wong
Clients are not able to handle persistent connections unless the client knows the length of the response. --- lib/yahns/http_response.rb | 6 ++ test/test_extras_exec_cgi.rb | 4 +--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/yahns/http_response.rb

[PATCH] ANOTHER round of proxy_pass fixes

2016-07-19 Thread Eric Wong
no alternative to nginx for preforking servers... Eric Wong (2): wbuf_lite: prevent clobbering responses wbuf_lite: unify EOF error handling lib/yahns/wbuf.rb | 1 + lib/yahns/wbuf_lite.rb | 18 ++ 2 files changed, 7 insertions(+), 12 deletions(-) -- unsubscribe: yahns

[PATCH 1/2] wbuf_lite: prevent clobbering responses

2016-07-19 Thread Eric Wong
All of our wbuf code assumes we append to existing buffers (files) since sendfile cannot deal otherwise. We also follow this pattern for StringIO to avoid extra data copies. --- lib/yahns/wbuf.rb | 1 + lib/yahns/wbuf_lite.rb | 7 --- 2 files changed, 5 insertions(+), 3 deletions(-)

[PATCH 0/3] another round of proxy_pass fixes

2016-07-05 Thread Eric Wong
varnish 4.0.2 (random chunks results, even given Content-Length :p) | v static file server (with some dynamic parts) Eric Wong (3): proxy_pass: avoid TOCTTOU race when unbuffering, too proxy_pass: avoid accessing logger in env

[PATCH 3/3] proxy_pass: avoid stuck responses in "proxy_buffering: false"

2016-07-05 Thread Eric Wong
Another critical bugfix for this yet-to-be-released feature. By the time we call proxy_unbuffer in proxy_read_body, the req_res socket may be completely drained of readable data and a persistent-connection-capable backend will be waiting for the next request (not knowing we do not yet support

[PATCH] update init and add systemd examples

2016-07-06 Thread Eric Wong
..6fe1ae6 100644 --- a/examples/init.sh +++ b/examples/init.sh @@ -2,8 +2,14 @@ # To the extent possible under law, Eric Wong has waived all copyright and # related or neighboring rights to this examples set -e -# Example init script, this can be used with nginx, too, -# since nginx and yahns accept

[ANN] yahns 1.13.0 -_- sleepy app server for Ruby

2016-08-05 Thread Eric Wong
A Free Software, multi-threaded, non-blocking network application server designed for low _idle_ power consumption. It is primarily optimized for applications with occasional users which see little or no traffic. yahns currently hosts Rack/HTTP applications, but may eventually support other

Re: [PATCH] doc: add session cache usage to OpenSSL example

2016-08-02 Thread Eric Wong
Eric Wong <e...@80x24.org> wrote: > +++ b/Documentation/yahns_config.pod > @@ -451,6 +451,9 @@ An example which seems to work is: ># but disable client certificate verification as it is rare: >ssl_ctx.set_params(verify_mode: OpenSSL::SSL::VERIFY_NONE) > > +

[PATCH] test_ssl: remove unnecessary priv_key DH parameter

2016-07-03 Thread Eric Wong
It seems unnecessary to set it at all and it's deprecated in current Ruby trunk. --- test/test_ssl.rb | 6 -- 1 file changed, 6 deletions(-) diff --git a/test/test_ssl.rb b/test/test_ssl.rb index e89a89d..92be542 100644 --- a/test/test_ssl.rb +++ b/test/test_ssl.rb @@ -26,12 +26,6 @@ class

[PATCH] move website to https://yhbt.net/yahns/

2016-09-26 Thread Eric Wong
HTTPS adds some level of privacy protection and helps marketing (because we care s much about good marketing! :P). Performance-wise, this reduces subjectAltName bloat when negotiating connections and will also speed up occasional certificate renewals when/if we drop the old name. Also, not

[PATCH] stream_file: remove #to_io support from responses

2016-11-08 Thread Eric Wong
This is not a part of any Rack specification, and can lead to interesting bugs with wrapped classes for gzip and TLS. AFAIK, .to_io was meant to support IO#wait_*able and IO.select methods, not to actually perform read/writes on the return value. --- lib/yahns/stream_file.rb | 30

[PATCH] response: only stream "file" responses on known length

2016-11-08 Thread Eric Wong
This means we need to check Content-Length and use it properly (unless Content-Range is set). --- lib/yahns/http_response.rb | 9 ++--- lib/yahns/stream_file.rb | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/yahns/http_response.rb b/lib/yahns/http_response.rb

Re: [PATCH] response: only stream "file" responses on known length

2016-11-08 Thread Eric Wong
Eric Wong <e...@80x24.org> wrote: > diff --git a/lib/yahns/http_response.rb b/lib/yahns/http_response.rb Oops, missed this :x --- a/lib/yahns/http_response.rb +++ b/lib/yahns/http_response.rb @@ -125,7 +125,7 @@ def kv_str(buf, key, value) def http_response_write(res, opt)

[PATCH] queue_*: fix outdated comments

2016-11-28 Thread Eric Wong
These comments have been outdated since 2013 with commit cd84e2ccbdf2 ("ensure we stop all threads at exit") --- lib/yahns/queue_epoll.rb | 2 +- lib/yahns/queue_kqueue.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/yahns/queue_epoll.rb b/lib/yahns/queue_epoll.rb

[PATCH] req_res: do not send 502 on catchall error if response buffered

2016-11-11 Thread Eric Wong
If we already started writing a response, we cannot be sending a 502 to inform a user a connection has failed. This should prevent errors from the OpenSSL layer about mismatched buffers due to the combination of slow clients and upstreams prematurely aborting. --- lib/yahns/req_res.rb | 2 +- 1

[ANN] yahns 1.14.0 -_- sleepy app server for Ruby

2016-11-14 Thread Eric Wong
A Free Software, multi-threaded, non-blocking network application server designed for low _idle_ power consumption. It is primarily optimized for applications with occasional users which see little or no traffic. yahns currently hosts Rack/HTTP applications, but may eventually support other

[PUSHED] http_response: support rack.hijack on HTTP/0.9 responses

2016-11-29 Thread Eric Wong
We still need to iterate through all response headers to support response-only Rack hijacking. Previously, we only supported full hijacking on so-called "HTTP/0.9" clients. n.b. This diff will be easier to read with the -b/--ignore-space-change option of git-diff(1) or GNU diff(1) ---

[PATCH 2/2] proxy_pass: do not chunk on bodyless upstream responses

2016-12-13 Thread Eric Wong
As with the previous commit ("response: do not set chunked header on bodyless responses"), blindly setting "Transfer-Encoding: chunked" is wrong and confuses "curl -T" on 204 responses, at least. --- lib/yahns/proxy_http_response.rb | 2 +- test/test_proxy_pass.rb | 33

[PATCH 1/2] response: do not set chunked header on bodyless responses

2016-12-13 Thread Eric Wong
Setting "Transfer-Encoding: chunked" on responses will confuse clients which see a 204 response and do not expect a body. This follows Rack::Chunked behavior, as yahns should function without Rack::Chunked middleware. This regression appeared in yahns v1.13.0 (2016-08-05) ---

[PATCH] stream_input: avoid allocation for common #read case

2016-12-28 Thread Eric Wong
When entering StreamInput#read, it is common for @rbuf to be drained and empty, meaning a simple String#clear can be used in place of a more complex String#slice! String#replace combo on an empty @rbuf. While we're at it, we'll avoid an extra instructions for calling `@rbuf.size` by storing the

[PATCH] avoid Thread#[] and Thread#[]= across threads

2017-03-24 Thread Eric Wong
Support for it may be removed in future versions of Ruby(*), and we actually do not need to waste time looping when a instance variable will do. (*) https://bugs.ruby-lang.org/issues/13245 --- lib/yahns/acceptor.rb | 6 +++--- lib/yahns/server.rb | 2 +- 2 files changed, 4 insertions(+), 4

[PATCH 3/4] Revert "use olddoc 1.1.0 for generating NEWS + NEWS.atom.xml"

2017-03-21 Thread Eric Wong
This reverts commit bcf0f0efb3173b18957ddba2af6592219a2d72a3. The dependency on olddoc makes it slightly more difficult for users to package their own and distribute RubyGems. We will also not host HTML RDoc files since we have no internal API to support. --- .gitignore | 1 - .olddoc.yml |

[PATCH 1/2] remove kgio read and wait dependencies

2017-03-21 Thread Eric Wong
Ruby 2.4+ should contain everything we need to replace kgio; and we can provide reasonable (if not slower) facsimiles for older Rubies. The reading and wait_*able APIs of kgio are similar to APIs in the IO core class, so lets deal with that, first. Removing dependencies on writing will be

[PATCH] doc: design_notes: we do not use EPOLLEXCLUSIVE

2017-03-21 Thread Eric Wong
And clarify that we only have one thread by default. Since EPOLLEXCLUSIVE seems to have gotten some more press, I guess we should emphasize our design does not rely on it. --- Documentation/design_notes.txt | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git

[PATCH 2/4] chunk_body: nodoc this internal class

2017-03-21 Thread Eric Wong
Although we do not publish RDoc-generated documentation on our website, other places may, an people use ri(1) locally. --- lib/yahns/chunk_body.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/yahns/chunk_body.rb b/lib/yahns/chunk_body.rb index 6e56a18..aab803b 100644

[PATCH] README: update with disclaimer about subscription

2017-03-21 Thread Eric Wong
Also, give the Atom feed a little more visibility. --- README | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README b/README index 349b028..8c80561 100644 --- a/README +++ b/README @@ -66,8 +66,12 @@ You may optionally subscribe by sending an email to:

[PATCH] rackup_handler: remove unnecessary branch

2017-04-04 Thread Eric Wong
No point in optimizing for the single listener case in setup code. --- lib/yahns/rackup_handler.rb | 6 +- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/yahns/rackup_handler.rb b/lib/yahns/rackup_handler.rb index 538e00d..63ab373 100644 --- a/lib/yahns/rackup_handler.rb +++

[PATCH] allow omitting specifying socket name when inheriting listen socket

2017-04-05 Thread Eric Wong
Since the common case is still to run a single app inside yahns, we can simplify setup a bit for systemd (and like) users by allowing them to omit the "listen" directive when they are running a single app in yahns. --- Documentation/yahns-rackup.pod | 4 lib/yahns/config.rb| 5

[PATCH] test_bin: use RbConfig.ruby for non-standard names

2017-04-05 Thread Eric Wong
It's possible to have "ruby" executables by other names (e.g. "ruby24"), so use a supported API for finding our executable. This feature was added in Ruby 1.9.2, so it's safe to use as we've always been 1.9.3+ (and nowadays 2.0+) --- test/test_bin.rb | 7 +++ 1 file changed, 3 insertions(+),

[PATCH] test_bin: SO_KEEPALIVE value only needs to be true

2017-04-03 Thread Eric Wong
From: Eric Wong <e...@80x24.org> On FreeBSD 10.3 (and presumably other *BSD TCP stacks, the value of SO_KEEPALIVE returned by getsockopt is 8, even when set to '1' via setsockopt. Relax the test to only ensure the boolean value is interpreted as "true". Verified independent

[PATCH] rack_proxy: initial implementation

2017-04-06 Thread Eric Wong
From: Eric Wong <e...@80x24.org> Needs more tests, docs, and such... --- lib/yahns.rb | 3 + lib/yahns/config.rb | 16 - lib/yahns/http_context.rb | 6 ++ lib/yahns/rack_proxy.rb | 156 ++ lib/yahns/server.rb

Re: [PATCH] rack_proxy: initial implementation

2017-04-07 Thread Eric Wong
Eric Wong <yahns-public@yhbt.net> wrote: > Needs more tests, docs, and such... Erm, a little too excited and also in a rush, so not a proper commit message :> Anyways, submasters seems like a useful concept for small sites where everything runs on a single host; or a containerized

[PATCH] fix some unused variables

2017-11-14 Thread Eric Wong
Current (tested r60757) ruby trunk warns in a few more places than 2.4.x did, so clean them up. --- extras/autoindex.rb| 4 ++-- test/test_mt_accept.rb | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/extras/autoindex.rb b/extras/autoindex.rb index 238edd9..45b80cf

[PATCH 2/2] test/test_ssl: set SSLContext#security_level=0

2018-07-03 Thread Eric Wong
This is apparently needed to pass tests with a newer version of OpenSSL found in Debian 9 --- test/test_ssl.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/test_ssl.rb b/test/test_ssl.rb index 92be542..7909094 100644 --- a/test/test_ssl.rb +++ b/test/test_ssl.rb @@ -41,6 +41,7 @@

  1   2   >