diff options
author | Eric Wong <e@80x24.org> | 2014-12-16 22:54:55 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2014-12-20 04:10:22 +0000 |
commit | f8a260976417f14bb0de59ca3f6645813edb37b7 (patch) | |
tree | fc93f837dc5356e6cbbc32c13a84536659a4c72c /lib | |
parent | 0270501f70ed74552a13f85ea0b85ce3389f84e8 (diff) | |
download | yahns-f8a260976417f14bb0de59ca3f6645813edb37b7.tar.gz |
Not everybody needs to serve or even buffer to regular files, so make sendfile optional to avoid the extra memory use and relocations.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/yahns/wbuf_common.rb | 7 |
1 files changed, 4 insertions, 3 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: |