yahns Ruby server user/dev discussion
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [ANN] yahns 1.5.0 - initial OpenSSL support and bugfixes
@ 2014-12-21  2:25  5% Eric Wong
  0 siblings, 0 replies; 3+ results
From: Eric Wong @ 2014-12-21  2:25 UTC (permalink / raw)
  To: yahns-public

This release adds basic OpenSSL support for HTTPS connections.

Users must supply a OpenSSL::SSL::SSLContext object which yahns will use
as-is.  yahns will only support HTTPS on Ruby 2.1 and later, as we rely
on "exception: false" in the read_nonblock and write_nonblock methods in
OpenSSL::SSL::SSLSocket.

See the Ruby standard library documentation on how to configure
OpenSSL::SSL::SSLContext objects to pass to the yahns "listen" directive
Editing the yahns config file to use OpenSSL goes something like this:

    require 'openssl' # we will not do this for the user, even
    ctx = OpenSSL::SSL::SSLContext.new
    # user must configure ctx here...

    listen 443, ssl_ctx: ctx

Note: yahns developers are not responsible for bugs in OpenSSL itself
or misconfigured SSLContext objects created by users.  However, our
support of OpenSSL sockets is barely-tested and likely buggy, too.

Furthermore, the "sendfile" (or "kgio-sendfile") gem is no longer a
required dependency.  It is currently impossible to use zero-copy
system calls with TLS sockets.

There are also minor cleanups and a bugfix to ensure body#close is
called for folks using body#to_path where `body' is the Rack
response body.  This bug affected logging using the 'clogger' gem
when serving static files.

Shortlog of changes since 1.4.0

      save around 1500 bytes of memory on x86-64
      http_response: remove arg for Array#join
      remove unused client_max_header_size config
      config: use literal symbol array for now
      http_response: reduce constants for 100 responses
      favor Array#map! for freshly-split arrays
      sendfile_compat: remove dependency on pread
      extras/autoindex: simplify checking non-.gz
      Rakefile: kill more useless gsub use
      initial cut at OpenSSL support
      test/test_ssl: skip test if SSL on older Rubies
      wbuf_common: close body proxies on sendfile abort
      bump published Ruby version requirement to 2.0
      make sendfile an optional dependency
      openssl_client: ignore SSL_accept errors during negotiation

Disclaimer: the yahns project does not and will never endorse
any commercial entities, including certificate authorities.

Shpx Nhgubevgl.

-- 
EW

^ permalink raw reply	[relevance 5%]

* [PATCH 6/6] sendfile_compat: remove dependency on pread
  2014-11-20 20:45  7% [PATCH 0/6] misc minor updates Eric Wong
@ 2014-11-20 20:45  6% ` Eric Wong
  0 siblings, 0 replies; 3+ results
From: Eric Wong @ 2014-11-20 20:45 UTC (permalink / raw)
  To: yahns-public; +Cc: e

We only need to open files with O_APPEND to allow appending to the
temporary buffer while leaving the read offset unchanged.
---
 INSTALL                      |  4 +---
 lib/yahns/sendfile_compat.rb | 12 +++++-------
 lib/yahns/tmpio.rb           |  2 +-
 3 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/INSTALL b/INSTALL
index 87acc53..fcc92f2 100644
--- a/INSTALL
+++ b/INSTALL
@@ -10,6 +10,4 @@ more details.
 Debian GNU/kFreeBSD:
 
 For now, you will need to define SENDFILE_BROKEN=1 in the env before
-running yahns, and also install the "io-extra" RubyGem (tested on 1.2.7)
-
-	gem install -v 1.2.7 io-extra
+running yahns.
diff --git a/lib/yahns/sendfile_compat.rb b/lib/yahns/sendfile_compat.rb
index e3f53d1..f324075 100644
--- a/lib/yahns/sendfile_compat.rb
+++ b/lib/yahns/sendfile_compat.rb
@@ -1,25 +1,23 @@
 # -*- encoding: binary -*-
 # Copyright (C) 2009-2014, Eric Wong <normalperson@yhbt.net> et. al.
 # License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
-require 'io/extra' # gem install io-extra
 
 module Yahns::SendfileCompat
   def trysendfile(io, offset, count)
     return 0 if count == 0
     count = 0x4000 if count > 0x4000
-    str = IO.pread(io.fileno, count, offset)
-    if count > str.bytesize
-      raise EOFError, "end of file reached"
-    end
+    buf = Thread.current[:yahns_sfbuf] ||= ''
+    io.pos = offset
+    str = io.read(count, buf) or return # nil for EOF
     n = 0
     case rv = kgio_trywrite(str)
     when String # partial write, keep trying
-      n += (str.bytesize - rv.bytesize)
+      n += (str.size - rv.size)
       str = rv
     when :wait_writable, :wait_readable
       return n > 0 ? n : rv
     when nil
-      return n + str.bytesize # yay!
+      return n + str.size # yay!
     end while true
   end
 end
diff --git a/lib/yahns/tmpio.rb b/lib/yahns/tmpio.rb
index 19da658..f0ddd2f 100644
--- a/lib/yahns/tmpio.rb
+++ b/lib/yahns/tmpio.rb
@@ -14,7 +14,7 @@ class Yahns::TmpIO < File # :nodoc:
   def self.new(tmpdir = Dir.tmpdir)
     retried = false
     begin
-      fp = super("#{tmpdir}/#{rand}", RDWR|CREAT|EXCL, 0600)
+      fp = super("#{tmpdir}/#{rand}", RDWR|CREAT|EXCL|APPEND, 0600)
     rescue Errno::EEXIST
       retry
     rescue Errno::EMFILE, Errno::ENFILE
-- 
EW


^ permalink raw reply related	[relevance 6%]

* [PATCH 0/6] misc minor updates
@ 2014-11-20 20:45  7% Eric Wong
  2014-11-20 20:45  6% ` [PATCH 6/6] sendfile_compat: remove dependency on pread Eric Wong
  0 siblings, 1 reply; 3+ results
From: Eric Wong @ 2014-11-20 20:45 UTC (permalink / raw)
  To: yahns-public; +Cc: e

Most of this are minor cleanups to reduce code size.  I'll probably
make the sendfile dependency optional as well.  Not everybody needs
static file serving, and the pread-style offset-agnosticism is
unlikely to be useful unless we feel the need need to implement open
file caching for static files.

Eric Wong (6):
      http_response: remove arg for Array#join
      remove unused client_max_header_size config
      config: use literal symbol array for now
      http_response: reduce constants for 100 responses
      favor Array#map! for freshly-split arrays
      sendfile_compat: remove dependency on pread

 INSTALL                      |  4 +---
 lib/yahns/config.rb          |  3 +--
 lib/yahns/http_context.rb    |  1 -
 lib/yahns/http_response.rb   | 11 +++++------
 lib/yahns/sendfile_compat.rb | 12 +++++-------
 lib/yahns/server.rb          |  2 +-
 lib/yahns/tmpio.rb           |  2 +-
 7 files changed, 14 insertions(+), 21 deletions(-)

^ permalink raw reply	[relevance 7%]

Results 1-3 of 3 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2014-11-20 20:45  7% [PATCH 0/6] misc minor updates Eric Wong
2014-11-20 20:45  6% ` [PATCH 6/6] sendfile_compat: remove dependency on pread Eric Wong
2014-12-21  2:25  5% [ANN] yahns 1.5.0 - initial OpenSSL support and bugfixes Eric Wong

Code repositories for project(s) associated with this public inbox

	https://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).