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 68baa3e340be3029f6acf47229118994cdc02e88..67254d09f83a2bf62ca2721e3cc28d8277ef2c71 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 3c4c41cf675c3c3ff3bc5ccf48b13c895c3cb34f..c469fe19be648777a82138ab2e8a78ef627b6f99 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