fast_send 1.1.3 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +15 -0
- data/fast_send.gemspec +1 -1
- data/lib/fast_send/socket_handler.rb +10 -9
- data/lib/fast_send/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26069db40cb9f389a16d39c87a6171dd6f341256
|
4
|
+
data.tar.gz: 937f14723306d0d7dcdd58b8a1178a895bcbcbdd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 325587ad50e76b729cc2075b31800d0da68410004bc5826fa936a86ae2fa68da66bfc44511167070bea6a201524d73bd63f7ca84f66e94781ef1a30b21a30cdb
|
7
|
+
data.tar.gz: 25d732c665b5ad6fc96b7a822cdf28225d30e55fec78b0124b61468ec59ccd8f45bef02bc3b6d9c8c7bd6b71e645193019fd98b18d8e12ab66c3f3a91db54d94
|
data/.travis.yml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
rvm:
|
2
|
+
- 2.3.3
|
3
|
+
- 2.5.0
|
4
|
+
|
5
|
+
before_install:
|
6
|
+
- gem update --system # Due to: https://github.com/travis-ci/travis-ci/issues/8978
|
7
|
+
|
8
|
+
cache: bundler
|
9
|
+
|
10
|
+
# Travis permits the following phases: before_install, install, after_install, before_script, script, after_script
|
11
|
+
# before_install:
|
12
|
+
# - gem update bundler # Travis RVM ships with an old-ish Bundler which has no install_if support
|
13
|
+
|
14
|
+
script:
|
15
|
+
- bundle exec rspec --backtrace
|
data/fast_send.gemspec
CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.require_paths = ["lib"]
|
9
9
|
s.authors = ["Julik Tarkhanov"]
|
10
|
-
s.date = "
|
10
|
+
s.date = Time.now.utc.strftime("%Y-%m-%d")
|
11
11
|
s.description = "Send bursts of large files quickly via Rack"
|
12
12
|
s.email = "me@julik.nl"
|
13
13
|
s.extra_rdoc_files = [
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'io/wait'
|
2
|
+
|
1
3
|
# Handles the TCP socket within the Rack hijack. Is used instead of a Proc object for better
|
2
4
|
# testability and better deallocation
|
3
5
|
class FastSend::SocketHandler < Struct.new(:stream, :logger, :started_proc, :aborted_proc, :error_proc,
|
@@ -84,18 +86,17 @@ class FastSend::SocketHandler < Struct.new(:stream, :logger, :started_proc, :abo
|
|
84
86
|
#
|
85
87
|
# Note that this will not work on OSX due to a sendfile() bug.
|
86
88
|
def fire_timeout_using_select(writable_socket)
|
87
|
-
|
89
|
+
started_polling_at = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
90
|
+
select_timeout_secs = 0.25
|
91
|
+
sleep_after_select_timeout_secs = 0.5
|
88
92
|
loop do
|
89
|
-
|
90
|
-
if
|
91
|
-
|
92
|
-
|
93
|
-
if errored && errored.include?(writable_socket)
|
94
|
-
raise SlowLoris, "Receiving socket had an error, connection will be dropped"
|
95
|
-
end
|
96
|
-
if (Time.now - at) > SOCKET_TIMEOUT
|
93
|
+
socket_or_nil = writable_socket.wait_writable(SELECT_TIMEOUT_ON_BLOCK)
|
94
|
+
return if socket_or_nil # socket became writable
|
95
|
+
now = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
96
|
+
if (now - started_polling_at) > SOCKET_TIMEOUT
|
97
97
|
raise SlowLoris, "Receiving socket timed out on sendfile(), probably a dead slow loris"
|
98
98
|
end
|
99
|
+
sleep(sleep_after_select_timeout_secs)
|
99
100
|
end
|
100
101
|
end
|
101
102
|
|
data/lib/fast_send/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fast_send
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julik Tarkhanov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -75,6 +75,7 @@ extra_rdoc_files:
|
|
75
75
|
- README.md
|
76
76
|
files:
|
77
77
|
- ".gitignore"
|
78
|
+
- ".travis.yml"
|
78
79
|
- Gemfile
|
79
80
|
- LICENSE.txt
|
80
81
|
- README.md
|