avoid race conditions 0.9.0
authorgc <gc>
Sun, 25 May 2008 21:42:29 +0000 (21:42 +0000)
committergc <gc>
Sun, 25 May 2008 21:42:29 +0000 (21:42 +0000)
bin/booh
lib/booh/booh-lib.rb

index 68baa3e..67254d0 100755 (executable)
--- a/bin/booh
+++ b/bin/booh
@@ -2076,8 +2076,10 @@ end
 
 def call_backend(cmd, waitmsg, mode, params)
     pipe = Tempfile.new("boohpipe")
+    Thread.critical = true
     pipe.close!
     system("mkfifo #{pipe.path}")
+    Thread.critical = false
     cmd += " --info-pipe #{pipe.path}"
     button, w8 = backend_wait_message($main_window, waitmsg, pipe.path, mode)
     pid = nil
@@ -2903,9 +2905,11 @@ def open_file_user(filename)
         $orig_filename = $filename
         $main_window.title = 'booh - ' + File.basename($orig_filename)
         tmp = Tempfile.new("boohtemp")
+        Thread.critical = true
         tmp.close!
         #- for security
         ios = File.open($filename = tmp.path, File::RDWR|File::CREAT|File::EXCL)
+        Thread.critical = false
         ios.close
         $tempfiles << $filename << "#{$filename}.backup"
     else
index 3c4c41c..c469fe1 100644 (file)
@@ -329,11 +329,14 @@ module Booh
         #- it's not possible to specify a basename for the output jpeg file with mplayer (file will be named 00000001.jpg); as this can
         #- be called from multiple threads, we must come up with a unique directory where to put the file
         tmpfile = Tempfile.new("boohvideotmp")
+        Thread.critical = true
         tmpfile.close!
         begin
             Dir.mkdir(tmpdirname = tmpfile.path)
         rescue Errno::EEXIST
             raise "Tmp directory #{tmpfile.path} already exists"
+        ensure
+            Thread.critical = false
         end
         cmd = "mplayer '#{orig}' -nosound -vo jpeg:outdir='#{tmpdirname}' -frames 1 -ss #{seektime} >/dev/null 2>/dev/null"
         msg 2, cmd