lib/puppet/external/lock.rb
# Get a shared (i.e., read) lock on the file, and yield to the block.
# If the lock is not available, wait for it without blocking other ruby
# threads.
Get a shared  lock on the file, and yield to the block.
If the lock is not available, wait for it without blocking other ruby
threads.
Get a shared lock on the file and yield to the block . If the lock is not available wait for it without blocking other ruby threads .
def lock_shared
    if Thread.list.size == 1
      flock(LOCK_SH)
    else
      period = 0.001
      until flock(LOCK_SH|LOCK_NB)
        sleep period
        period *= 2 if period < 1
      end
    end
    yield self
  ensure
    Thread.exclusive {flock(LOCK_UN) if $reader_count[self.stat.ino] == 1}
  end
def lock_shared if Thread . list . size == 1 flock ( LOCK_SH ) else period = 0.001 until flock ( LOCK_SH | LOCK_NB ) sleep period period *= 2 if period < 1 end end yield self ensure Thread . exclusive { flock ( LOCK_UN ) if $reader_count [ self . stat . ino ] == 1 } end
Get a shared (i.e., read) lock on the file, and yield to the block.
Get a shared ( i . e . read ) lock on the file and yield to the block .
# ugly hack because waiting for a lock in a Ruby thread blocks the # process ## for solaris, no need to unlock here--closing does it ## but this has no effect on the bug