faye-websocket 0.10.0 → 0.10.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of faye-websocket might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: be0df4257b3a1f898577eb787b6f1fc8f5c0fae4
4
- data.tar.gz: 75def6662b64d516ee753ccd78003a445c9dca11
3
+ metadata.gz: 85557a18bc39ccf7f19ea25d9bb97778e4976a3c
4
+ data.tar.gz: ac8c769136548e7c8355fb01f7c79e6928fb0c32
5
5
  SHA512:
6
- metadata.gz: 9054661c65b66682fea05e779d785b142f7005f323228ffdbd3429570ba4df9055b2c7b6516a6c7f046c929387133574ffa39a142121b1871bdcfe99e52ff828
7
- data.tar.gz: 7eb1cb4a544824ffa191270c665ed70c87d5a131e54f597f090d71a23802691bdce18e9cc46f62c39d3283e031af42c27bec6bae552519c2c7e4a4630fde64cf
6
+ metadata.gz: 6e259cae366b3bc1995380905504677be7ec4ba2cc498c6ad01e0c9fc53157e910161635199d3fda017d1fb82263514a4c39ccc224fce920ac65b312a9664385
7
+ data.tar.gz: e922b280a0dd8ef81a0c5f0664af26459f921ace8dab435afbe1650505dac2c6c04b08605436b8ffd9ddb1351554ccd23fc5612e11f2999bd7b332c773993f73
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ### 0.10.1 / 2015-11-06
2
+
3
+ * Make sure errors can be safely emitted if creating the driver fails
4
+ * Prevent a race condition when binding `EM.attach` to the socket
5
+
1
6
  ### 0.10.0 / 2015-07-08
2
7
 
3
8
  * Add the standard `code` and `reason` parameters to the `close` method
data/README.md CHANGED
@@ -372,7 +372,7 @@ WebSocket performance in Passenger. This is
372
372
  [documented in the Passenger manual](https://www.phusionpassenger.com/documentation/Users%20guide%20Nginx.html#tuning_sse_websockets).
373
373
 
374
374
  ```ruby
375
- if defined?(PhusionPasseneger)
375
+ if defined?(PhusionPassenger)
376
376
  PhusionPassenger.advertised_concurrency_level = 0
377
377
  end
378
378
  ```
@@ -15,21 +15,39 @@ module Faye
15
15
  end
16
16
  end
17
17
 
18
- def initialize(socket_object)
19
- @socket_object = socket_object
20
- @connection = socket_object.env['em.connection']
21
- @stream_send = socket_object.env['stream.send']
22
-
23
- if socket_object.env['rack.hijack']
24
- socket_object.env['rack.hijack'].call
25
- @rack_hijack_io = socket_object.env['rack.hijack_io']
26
- EventMachine.attach(@rack_hijack_io, Reader) do |reader|
27
- @rack_hijack_io_reader = reader
28
- reader.stream = self
18
+ def initialize(socket)
19
+ @socket_object = socket
20
+ @connection = socket.env['em.connection']
21
+ @stream_send = socket.env['stream.send']
22
+
23
+ hijack_rack_socket
24
+
25
+ @connection.socket_stream = self if @connection.respond_to?(:socket_stream)
26
+ end
27
+
28
+ def hijack_rack_socket
29
+ return unless @socket_object.env['rack.hijack']
30
+
31
+ @socket_object.env['rack.hijack'].call
32
+ @rack_hijack_io = @socket_object.env['rack.hijack_io']
33
+ queue = Queue.new
34
+
35
+ EventMachine.schedule do
36
+ begin
37
+ EventMachine.attach(@rack_hijack_io, Reader) do |reader|
38
+ reader.stream = self
39
+ if @rack_hijack_io
40
+ @rack_hijack_io_reader = reader
41
+ else
42
+ reader.close_connection_after_writing
43
+ end
44
+ end
45
+ ensure
46
+ queue.push(nil)
29
47
  end
30
48
  end
31
49
 
32
- @connection.socket_stream = self if @connection.respond_to?(:socket_stream)
50
+ queue.pop if EventMachine.reactor_running?
33
51
  end
34
52
 
35
53
  def clean_rack_hijack
@@ -18,9 +18,12 @@ module Faye
18
18
  attr_reader :url, :ready_state, :buffered_amount
19
19
 
20
20
  def initialize(options = {})
21
+ @ready_state = CONNECTING
21
22
  super()
22
23
  ::WebSocket::Driver.validate_options(options, [:headers, :extensions, :max_length, :ping, :proxy, :tls])
23
24
 
25
+ @driver = yield
26
+
24
27
  if headers = options[:headers]
25
28
  headers.each { |name, value| @driver.set_header(name, value) }
26
29
  end
@@ -31,7 +34,6 @@ module Faye
31
34
 
32
35
  @ping = options[:ping]
33
36
  @ping_id = 0
34
- @ready_state = CONNECTING
35
37
  @buffered_amount = 0
36
38
 
37
39
  @driver.on(:open) { |e| open }
@@ -10,8 +10,8 @@ module Faye
10
10
  attr_reader :headers, :status
11
11
 
12
12
  def initialize(url, protocols = nil, options = {})
13
- @url = url
14
- @driver = ::WebSocket::Driver.client(self, :max_length => options[:max_length], :protocols => protocols)
13
+ @url = url
14
+ super(options) { ::WebSocket::Driver.client(self, :max_length => options[:max_length], :protocols => protocols) }
15
15
 
16
16
  [:open, :error].each do |event|
17
17
  @driver.on(event) do
@@ -20,8 +20,6 @@ module Faye
20
20
  end
21
21
  end
22
22
 
23
- super(options)
24
-
25
23
  proxy = options.fetch(:proxy, {})
26
24
  endpoint = URI.parse(proxy[:origin] || @url)
27
25
  port = endpoint.port || DEFAULT_PORTS[endpoint.scheme]
@@ -64,20 +64,26 @@ module Faye
64
64
  def initialize(env, protocols = nil, options = {})
65
65
  WebSocket.ensure_reactor_running
66
66
 
67
- @env = env
68
- @url = WebSocket.determine_url(@env)
69
- @driver = ::WebSocket::Driver.rack(self, :max_length => options[:max_length], :protocols => protocols)
67
+ @env = env
68
+ @url = WebSocket.determine_url(@env)
69
+
70
+ super(options) { ::WebSocket::Driver.rack(self, :max_length => options[:max_length], :protocols => protocols) }
71
+
70
72
  @stream = Stream.new(self)
71
73
 
72
74
  if callback = @env['async.callback']
73
75
  callback.call([101, {}, @stream])
74
76
  end
77
+ end
75
78
 
76
- super(options)
77
- @driver.start
79
+ def start_driver
80
+ return if @driver.nil? || @driver_started
81
+ @driver_started = true
82
+ EventMachine.schedule { @driver.start }
78
83
  end
79
84
 
80
85
  def rack_response
86
+ start_driver
81
87
  [ -1, {}, [] ]
82
88
  end
83
89
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: faye-websocket
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Coglan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-08 00:00:00.000000000 Z
11
+ date: 2015-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eventmachine
@@ -233,7 +233,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
233
233
  version: '0'
234
234
  requirements: []
235
235
  rubyforge_project:
236
- rubygems_version: 2.4.5
236
+ rubygems_version: 2.4.5.1
237
237
  signing_key:
238
238
  specification_version: 4
239
239
  summary: Standards-compliant WebSocket server and client