cable_room 0.6.2.beta7 → 0.6.2.beta8

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
  SHA256:
3
- metadata.gz: 7309c58f5b1c28f703935326e40e13194a1e57c57ddd184cfa100ee7c23351d1
4
- data.tar.gz: d666029a14ac41eb3b422edc7de2eaf1ce2cef8c95854f4116052c5bff8b447f
3
+ metadata.gz: cf9bc187f61f47429b4f6d19591ae11f9ce5adc4f3e631a386543c5a4be3d31f
4
+ data.tar.gz: 7ea623c7bce5023f7eef8e9f70c7fd723dd6d4c83ffdff6e0e636bcf4a0c2085
5
5
  SHA512:
6
- metadata.gz: d252055f0b2e4062f01865a6f1ba482e555e3c8325eac88d29b0e0d34673aafccdab72fea916fda0fb6b36dbab4f8e7340ad120d90b463752d79d5c071dc9468
7
- data.tar.gz: 2352b8d4315b7d3fff5389e6c6c9783b3314329cef0233500fd6a26fb91c8343f2244094ce0faa4a1b28f5e0868cef2932a27364ecfe2c9d7cfb66bb5377a2f4
6
+ metadata.gz: 3ea7801344b227a3db243d32aa569427a2e721adb2c4e8894ff803834a6e60392a064cac0b9f2bf21257936109b472d99f994bb82eec3387aa490d1cf7260c1b
7
+ data.tar.gz: b0d7b8b7b054d5a45290df64691e919a9ac8d951beb06df38edf799e3c81bb955ca5444b490293fb4d20d0a09759dc4b8122334d2d041ebf52e6bbd23486d8cf
@@ -118,10 +118,7 @@ module CableRoom
118
118
  def handle_received_message(message)
119
119
  case message['type']
120
120
  when 'port_connected'
121
- mo = @_port_clients[@current_message_origin]
122
- return if mo
123
-
124
- mo = @_port_clients[@current_message_origin] = PortClient.new(self, @current_message_origin)
121
+ mo = @_port_clients[@current_message_origin] ||= PortClient.new(self, @current_message_origin)
125
122
 
126
123
  mo.touch_activity!
127
124
  mo.tag!(message['tags'])
@@ -51,7 +51,13 @@ module CableRoom
51
51
 
52
52
  def transmit_subscription_confirmation(...)
53
53
  super
54
- _room_memberships.each(&:transmit_port_connected)
54
+ # Rails invokes this from the pubsub adapter's subscribe success callback, which runs while
55
+ # SubscriberMap holds its (non-reentrant) @sync mutex. Broadcasting from that stack raises
56
+ # ThreadError: deadlock; recursive locking, and the adapter swallows it. Defer onto the event
57
+ # loop so the announce still happens after every stream is confirmed live, but off the lock.
58
+ memberships = _room_memberships.to_a
59
+ memberships.each(&:streams_live!)
60
+ connection.server.event_loop.post { memberships.each(&:transmit_port_connected) }
55
61
  end
56
62
  end
57
63
 
@@ -78,6 +84,7 @@ module CableRoom
78
84
 
79
85
  @has_left = false
80
86
  @has_established = false
87
+ @streams_live = false
81
88
 
82
89
  @cable_channel = cable_channel
83
90
  @room_class = room_class
@@ -146,6 +153,11 @@ module CableRoom
146
153
 
147
154
  def key; @room_key; end
148
155
 
156
+ # @internal
157
+ def streams_live!
158
+ @streams_live = true
159
+ end
160
+
149
161
  # @internal
150
162
  def transmit_port_connected
151
163
  msg = {
@@ -196,7 +208,10 @@ module CableRoom
196
208
  @has_established = true
197
209
  @on_joined&.call(self) if first_acknowledgement
198
210
  when 'room_opened'
199
- transmit_port_connected
211
+ # Only safe once our own streams are confirmed; otherwise the room may acknowledge on the
212
+ # private port before anyone is listening. If we are not live yet, the subscription
213
+ # confirmation hook will announce for us.
214
+ transmit_port_connected if @streams_live
200
215
  @on_room_opened&.call(self)
201
216
  when 'room_closed'
202
217
  leave!
@@ -243,7 +258,9 @@ module CableRoom
243
258
 
244
259
  @preconfigure&.call(self)
245
260
 
246
- # transmit_port_connected
261
+ # Announcing here races the async stream subscriptions: the room can acknowledge on the
262
+ # private port before it is live and the ack is lost. transmit_subscription_confirmation
263
+ # announces instead, once every stream is confirmed.
247
264
 
248
265
  maybe_provision_room
249
266
  end
@@ -1,3 +1,3 @@
1
1
  module CableRoom
2
- VERSION = "0.6.2.beta7".freeze
2
+ VERSION = "0.6.2.beta8".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cable_room
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2.beta7
4
+ version: 0.6.2.beta8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ethan Knapp