ruby/ruby — pull request #415 by obrie (2013-10-04 15:41:38+00:00)
Title: Fix race condition causing some mutexes to remain locked after forking

This patch fixes a race condition in which a mutex gets locked by a background thread and not properly unlocked after forking. The occurs when the background thread is blocked waiting to lock the mutex and the mutex is unlocked right around the time that the process gets forked. When this happens the mutex is not part of `keeping_mutexes`. Instead, it's still tracked as `locking_mutex` even though the mutex *has* actually been locked by the background thread.

This was originally reported by https://bugs.ruby-lang.org/issues/8433. A test has been added verifying the fix.

Completely open to any / all feedback as I'm certainly not a c guru :)