Changeset 221 for trunk/RebuildQueue
- Timestamp:
- 04/05/07 20:12:37 (3 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/RebuildQueue/plugins/RebuildQueue/lib/RebuildQueue/Daemon.pm
r164 r221 309 309 my $cfg = MT::ConfigMgr->instance; 310 310 311 # It's unwise to ignore locking for task manager; NoLocking should be312 # limited to the DBM driver.313 #if ($cfg->NoLocking) {314 # ## If the user doesn't want locking, don't try to lock anything.315 # ## Safe for tasks??316 # return sub { };317 #}318 319 311 my $temp_dir = $cfg->TempDir; 320 312 my $mt_dir = MT->instance->{mt_dir}; … … 328 320 my $hostname = Sys::Hostname::hostname(); 329 321 my $lock_tmp = $lock_name . '.' . $hostname; 330 my $max_lock_age = 60; ## no. of seconds til we break the lock331 322 my $tries = 10; ## no. of seconds to keep trying 332 323 my $lock_fh = gensym(); … … 341 332 ## link() failed, but the file exists--we got the lock. 342 333 $got_lock++; last; 343 } else {344 ## Couldn't get a lock; if the lock is too old, break it.345 my $lock_age = (stat $lock_name)[10];346 unlink $lock_name if time - $lock_age > $max_lock_age;347 334 } 348 335 sleep 1; … … 358 345 my $lock_flags = LOCK_EX | LOCK_NB; 359 346 unless (flock $lock_fh, $lock_flags) { 347 # Advisory lock is still active 360 348 close $lock_fh; 361 unlink $lock_name;362 349 return; 363 350 }
