rocksky 0.9.0 → 0.9.1

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: e27b27d24d5d5c59963b65031fb641ecb90cb322a9107f3a62a431e6d1973a0c
4
- data.tar.gz: 4a314bfa67627103279e453ab7f3563f3c0265c02ca0c1db1ca88259ca26cb33
3
+ metadata.gz: 84425f844d397e7187168e44115168f310f5a48269da6b1f3efc424cbf9991aa
4
+ data.tar.gz: 89e6d0d11fd1f88ec4e80498251f1d1d24cc4e77587860b7c96b0508306a3817
5
5
  SHA512:
6
- metadata.gz: 498b7790bd6961f4a5e118ab4485bf124afb9283fb838a38f6c21195fa50ba47e22bc10ae98518e6804401e3b8de63e5580cb8957a3690f0dcf39a4e72d18de9
7
- data.tar.gz: 3f1bb359b30802470a0c7d59ea921850ee43060bba3c67ba8f672eebb1d01c3d6814135462b47c029104bbfb3f5bb32de2b592ffab590c6521f703c3b37995f9
6
+ metadata.gz: b48c2675d3ecedc52f6b2c7b70a728d927dd69a2564bfe16bc8b55101dfbf866e44b67957b1ad866c57819b0b66360aa637745a73c87238b0c769aa5b5b5e49a
7
+ data.tar.gz: bbc58f41ea90eda2c8878cde5e6c182a364a5d8de5f4056ab5e6baad5178c67756cf2f02da5343a2b1a679d83839c02b0c1787de64ec6119a42c979abc9a9e2a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.9.1
4
+
5
+ - Fix a segfault when tearing down a `RemotePlayer` / `RemoteController`.
6
+ `#close` freed the native handle while the `#listen` background thread was
7
+ still blocked inside `#next_command` / `#next_event` (a use-after-free). It now
8
+ stops the background task and **joins** the listen thread — so the poll has
9
+ returned — before freeing. `#next_command` / `#next_event` also no-op once the
10
+ handle is released.
11
+
3
12
  ## 0.3.0
4
13
 
5
14
  - `feed.get_stories` now accepts optional `feed:` (at-uri) and `following:`
@@ -57,6 +57,8 @@ module Rocksky
57
57
  # Block until the next controller command, returned as a symbol-keyed Hash
58
58
  # (e.g. +{ action: "play" }+), or +nil+ once disconnected.
59
59
  def next_command
60
+ return nil if @ptr.null?
61
+
60
62
  cmd = Rocksky.unwrap(C.rocksky_remote_player_next_command(@ptr))
61
63
  cmd && Rocksky.symbolize(cmd)
62
64
  end
@@ -103,7 +105,12 @@ module Rocksky
103
105
  def close
104
106
  return if @ptr.null?
105
107
 
106
- @thread&.kill
108
+ # Stop the background task so a blocked #next_command returns nil and the
109
+ # #listen loop exits, then WAIT for that thread to leave the native call
110
+ # before freeing — freeing the handle while a poll is in flight is a
111
+ # use-after-free (segfault).
112
+ C.rocksky_remote_player_disconnect(@ptr)
113
+ @thread&.join unless @thread == Thread.current
107
114
  @thread = nil
108
115
  C.rocksky_remote_player_free(@ptr)
109
116
  @ptr = Fiddle::Pointer.new(0)
@@ -166,6 +173,8 @@ module Rocksky
166
173
  # Block until the next update, returned as a symbol-keyed Hash (each carries a
167
174
  # +:type+), or +nil+ once disconnected.
168
175
  def next_event
176
+ return nil if @ptr.null?
177
+
169
178
  ev = Rocksky.unwrap(C.rocksky_remote_controller_next_event(@ptr))
170
179
  ev && Rocksky.symbolize(ev)
171
180
  end
@@ -244,7 +253,12 @@ module Rocksky
244
253
  def close
245
254
  return if @ptr.null?
246
255
 
247
- @thread&.kill
256
+ # Stop the background task so a blocked #next_event returns nil and the
257
+ # #listen loop exits, then WAIT for that thread to leave the native call
258
+ # before freeing — freeing the handle while a poll is in flight is a
259
+ # use-after-free (segfault).
260
+ C.rocksky_remote_controller_disconnect(@ptr)
261
+ @thread&.join unless @thread == Thread.current
248
262
  @thread = nil
249
263
  C.rocksky_remote_controller_free(@ptr)
250
264
  @ptr = Fiddle::Pointer.new(0)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rocksky
4
- VERSION = "0.9.0"
4
+ VERSION = "0.9.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rocksky
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rocksky