lostisland/faraday — pull request #252 by leocassarani (2013-04-02 19:11:27+00:00)
Title: Make the `@@constants` Hash thread-safe by wrapping it in a Mutex

When multiple threads are creating instances of `Faraday::RackBuilder::Handler`, the `@@constants` hash may exhibit unexpected behaviour, as the `Hash` class is not thread-safe in Ruby.

On Rubinius, this often manifests itself as duplicated keys in the hash, but other interpreters may behave differently.

This commit wraps all writes to `@@constants` in a `Mutex`, thereby ensuring mutual exclusion.