Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

6.0.3 #4

Merged
merged 2 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
== 6.0.2 2024-06-19

Fixes:
* Fixed a possible race condition that would cause the transcoder to time out even if the transcoder was still running

== 6.0.2 2024-06-18

Fixes:
Expand Down
16 changes: 11 additions & 5 deletions lib/ffmpeg/timeout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,21 @@ def self.start(duration, message = nil)
end

def pause
@paused = true
@mutex.synchronize { @paused = true }
nil
end

def resume
@paused = false
tick
@mutex.synchronize do
@last_tick = Time.now
@paused = false
nil
end
end

def tick
@last_tick = Time.now
@mutex.synchronize { @last_tick = Time.now }
nil
end

def cancel
Expand All @@ -33,6 +38,7 @@ def cancel
private

def initialize(duration, message = nil)
@mutex = Mutex.new
@duration = duration
@message = message

Expand All @@ -43,7 +49,7 @@ def initialize(duration, message = nil)
end

def loop
sleep 0.1 while @paused || Time.now - @last_tick <= @duration
sleep 0.1 while @mutex.synchronize { @paused || Time.now - @last_tick <= @duration }

@current_thread.raise(::Timeout::Error, @message || self.class.name)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/ffmpeg/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module FFMPEG
VERSION = '6.0.2'
VERSION = '6.0.3'
end