fast_send 1.1.3 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ea16771c56f207d5c40555b4981d955e20724177
4
- data.tar.gz: 691ef28f1a505a95c974c5060fc66eff6147ad22
3
+ metadata.gz: 26069db40cb9f389a16d39c87a6171dd6f341256
4
+ data.tar.gz: 937f14723306d0d7dcdd58b8a1178a895bcbcbdd
5
5
  SHA512:
6
- metadata.gz: a354a9e5b09f1d598147428351f824f39b42c1b29e48633ee334791bc68d3c95edc2bc551f2eb7087c8e29f37b20c9ff33360528f7424422e0de403575cda916
7
- data.tar.gz: eae00df9f9beb28595c2de2023915245525a27892ed67e2b6ee192446e24822b9f80929051ad6f1bf1a8bb2ede2529bf3ae6364758db3166097ff8466d9ac7e3
6
+ metadata.gz: 325587ad50e76b729cc2075b31800d0da68410004bc5826fa936a86ae2fa68da66bfc44511167070bea6a201524d73bd63f7ca84f66e94781ef1a30b21a30cdb
7
+ data.tar.gz: 25d732c665b5ad6fc96b7a822cdf28225d30e55fec78b0124b61468ec59ccd8f45bef02bc3b6d9c8c7bd6b71e645193019fd98b18d8e12ab66c3f3a91db54d94
@@ -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
@@ -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 = "2016-11-15"
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
- at = Time.now
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
- _, writeables, errored = IO.select(nil, [writable_socket], [writable_socket], SELECT_TIMEOUT_ON_BLOCK)
90
- if writeables && writeables.include?(writable_socket)
91
- return # We can proceed
92
- end
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
 
@@ -1,3 +1,3 @@
1
1
  class FastSend
2
- VERSION = "1.1.3"
2
+ VERSION = "1.2.0"
3
3
  end
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.1.3
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: 2016-11-15 00:00:00.000000000 Z
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