We are using FSDB with Puppet under Ruby 1.8.7. There are two issues that we needed to patch to get this to work:
diff -Nur repo/lib/fsdb/database.rb patch/lib/fsdb/database.rb
--- repo/lib/fsdb/database.rb 2012-05-16 14:14:51.132284339 -0700
+++ patch/lib/fsdb/database.rb 2012-05-16 14:14:51.160284499 -0700
@@ -385,7 +385,7 @@
rescue Errno::EINTR
retry
else
- f.lock_shared(@lock_type)
+ f.lock_shared_fsdb(@lock_type)
identify_file_type(f, path, abs_path)
yield f
ensure
@@ -407,7 +407,7 @@
rescue Errno::EINTR
retry
else
- f.lock_exclusive(@lock_type)
+ f.lock_exclusive_fsdb(@lock_type)
identify_file_type(f, path, abs_path)
yield f
ensure
@@ -502,7 +502,7 @@
end
cache_entry.file_handle = f
- f.lock_shared(@lock_type)
+ f.lock_shared_fsdb(@lock_type)
identify_file_type(f, path, abs_path)
## could avoid if cache_object says so
object = cache_object(f, cache_entry)
diff -Nur repo/lib/fsdb/file-lock.rb patch/lib/fsdb/file-lock.rb
--- repo/lib/fsdb/file-lock.rb 2012-05-16 14:14:51.132284339 -0700
+++ patch/lib/fsdb/file-lock.rb 2012-05-16 14:14:51.155284264 -0700
@@ -10,17 +10,17 @@
if FSDB::PLATFORM_IS_WINDOWS_ME
# no flock() on WinME
- def lock_exclusive lock_type # :nodoc
+ def lock_exclusive_fsdb lock_type # :nodoc
end
- def lock_shared lock_type # :nodoc
+ def lock_shared_fsdb lock_type # :nodoc
end
else
# Get an exclusive (i.e., write) lock on the file.
# If the lock is not available, wait for it without blocking other ruby
# threads.
- def lock_exclusive lock_type
+ def lock_exclusive_fsdb lock_type
send(lock_type, LOCK_EX)
rescue Errno::EINTR
retry
@@ -29,7 +29,7 @@
# Get a shared (i.e., read) lock on the file.
# If the lock is not available, wait for it without blocking other ruby
# threads.
- def lock_shared lock_type
+ def lock_shared_fsdb lock_type
send(lock_type, LOCK_SH)
rescue Errno::EINTR
retry
diff -Nur repo/lib/fsdb/modex.rb patch/lib/fsdb/modex.rb
--- repo/lib/fsdb/modex.rb 2012-05-16 14:14:51.132284339 -0700
+++ patch/lib/fsdb/modex.rb 2012-05-16 14:14:51.170284771 -0700
@@ -1,4 +1,5 @@
module FSDB
+require 'thread'
# Modex is a modal exclusion semaphore.
# The two modes are shared (SH) and exclusive (EX).
diff -Nur repo/lib/fsdb/persistent.rb patch/lib/fsdb/persistent.rb
--- repo/lib/fsdb/persistent.rb 2012-05-16 14:14:51.132284339 -0700
+++ patch/lib/fsdb/persistent.rb 2012-05-16 14:14:51.163286375 -0700
@@ -27,7 +27,7 @@
persistent_mutex.synchronize do
File.makedirs(File.dirname(persistent_file))
File.open(persistent_file, "wb") do |f|
- f.lock_exclusive do
+ f.lock_exclusive_fsdb do
dump(f)
yield self if block_given?
end
@@ -50,7 +50,7 @@
# a particular object, or there will be multiple copies.
def restore file
object = File.open(file, "rb") do |f|
- f.lock_shared do
+ f.lock_shared_fsdb do
load(f)
end
end