puppetlabs/facter — pull request #688 by adrienthebo (2014-06-02 22:16:40+00:00)
Title: Issue/facter 2/fact 482 remove thread locking

(FACT-482) Remove thread locking

Facter has sporadic instances where facts implement their own locking
when resolving facts. Facter itself has never made any guarantees about
thread safety so the existing locking is useless at best and broken at
worst.

When Mcollective resolves facts it acquires a threadlock before running
to ensure that facts are generated in an atomic fashion. However the
lock used is not scoped to the given critical region; it is global so
`Thread.exclusive` cannot be reentered in a single thread:

[3] pry(main)> Thread.exclusive do
[3] pry(main)* Thread.exclusive do
[3] pry(main)* puts "hi"
[3] pry(main)* end
[3] pry(main)* end
ThreadError: deadlock; recursive locking
from :8:in `lock'

Because of this the facter facts source could not be used on Windows
because Mcollective and Facter would deadlock. This commit removes the
locking from Facter and places the responsibility for thread safety on
the code invoking Facter.