Hiroyuki Komatsu
komat****@users*****
2004年 12月 17日 (金) 22:48:23 JST
Index: prime/lib/prime-japanese.rb diff -u prime/lib/prime-japanese.rb:1.8 prime/lib/prime-japanese.rb:1.9 --- prime/lib/prime-japanese.rb:1.8 Thu Dec 16 23:44:09 2004 +++ prime/lib/prime-japanese.rb Fri Dec 17 22:48:23 2004 @@ -1,5 +1,5 @@ # prime/prime-japnese.rb: Japanese module for PRIME. -# $Id: prime-japanese.rb,v 1.8 2004/12/16 14:44:09 komatsu Exp $ +# $Id: prime-japanese.rb,v 1.9 2004/12/17 13:48:23 komatsu Exp $ # # Copyright (C) 2004 Hiroyuki Komatsu <komat****@taiya*****> # All rights reserved. @@ -417,9 +417,15 @@ return @@suikyo end - ## lock "suikyo.rbo" - lock_io = File.new(PRIME_USER_DIR) - if lock_io.flock( File::LOCK_EX | File::LOCK_NB ) then + ## lock for "suikyo.rbo" + filename_lock = File::join2(PRIME_USER_DIR, ".lock") + if File::symlink?(filename_lock) == false or + ( File::symlink?(filename_lock) and + Time::now - File::lstat(filename_lock).mtime > 3600 ) then + + unless File::symlink?(filename_lock) then + File::symlink($$.to_s, filename_lock) + end if PRIME_ENV['suikyo_use_cache'] and force == false then threshold_time = [File::mtime(File::expand_path(__FILE__)), @@ -440,8 +446,8 @@ end } - ## unlock "suikyo.rbo" - lock_io.flock( File::LOCK_UN | File::LOCK_NB ) + ## unlock for "suikyo.rbo" + File::delete(filename_lock) else ## If the locking failed, the cache file is not used. suikyo = PrimeTypeConv::initialize_suikyo_internal(typing_method)