* [PATCH 2/2] make sendfile an optional dependency
@ 2014-12-16 22:54 Eric Wong
0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2014-12-16 22:54 UTC (permalink / raw)
To: yahns-public
Not everybody needs to serve or even buffer to regular files,
so make sendfile optional to avoid the extra memory use and
relocations.
---
lib/yahns/wbuf_common.rb | 7 ++++---
yahns.gemspec | 2 +-
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/lib/yahns/wbuf_common.rb b/lib/yahns/wbuf_common.rb
index 69fd00d..0ce4526 100644
--- a/lib/yahns/wbuf_common.rb
+++ b/lib/yahns/wbuf_common.rb
@@ -1,10 +1,11 @@
# -*- encoding: binary -*-
# Copyright (C) 2009-2013, Eric Wong <normalperson@yhbt.net> et. al.
# License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
-if ENV["SENDFILE_BROKEN"]
- require_relative 'sendfile_compat'
-else
+begin
+ raise LoadError, "SENDFILE_BROKEN env set" if ENV["SENDFILE_BROKEN"]
require 'sendfile'
+rescue LoadError
+ require_relative 'sendfile_compat'
end
module Yahns::WbufCommon # :nodoc:
diff --git a/yahns.gemspec b/yahns.gemspec
index db1d50e..120dc46 100644
--- a/yahns.gemspec
+++ b/yahns.gemspec
@@ -12,8 +12,8 @@ Gem::Specification.new do |s|
s.files = manifest
s.add_dependency(%q<kgio>, '~> 2.9')
s.add_dependency(%q<sleepy_penguin>, '~> 3.2')
- s.add_dependency(%q<kgio-sendfile>, '~> 1.2')
s.add_dependency(%q<unicorn>, '~> 4.6', '>= 4.6.3')
+ # s.add_dependency(%q<kgio-sendfile>, '~> 1.2') # optional
# minitest is standard in Ruby 2.0, 4.3 is packaged with Ruby 2.0.0,
# 4.7.5 with 2.1. We work with minitest 5, too. 6.x does not exist
--
EW
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2014-12-16 22:54 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-16 22:54 [PATCH 2/2] make sendfile an optional dependency 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).