Stratoscale / osmosis

Osmosis replaces rsync, where the backend is a git-like object store. Its used for storing build products (and rootfses)
Apache License 2.0
7 stars 16 forks source link

Fix race condition on chekcout progress thread initialization #2

Closed eliran-stratoscale closed 9 years ago

eliran-stratoscale commented 9 years ago

The current implementation of the waiting for the CheckOutProgress and CheckInProgress threads to finish, causes a race condition, which can lead to Osmosis not finishing forever); The stop method of CheckOutProgress (which is supposed to be called by someone other than the thread itself, who wants to stop the thread) calls notify_one on the 'stop' condition variable, which is used by the CheckOutProgress thread to wait for a stop command. But, In case that the checkout was really short in duration, then the CheckOutThread hasn't started waiting on the condition variable, which means that notify_on has no effect at all. notify_one only works when it is invoked -after- someone has started waiting on the condition variable, and not before (i was supprised too. here is someone with the same problem: http://stackoverflow.com/questions/18691966/are-there-alternative-ways-to-catch-potentially-missed-signals-with-condition-va). In case that the notify_on was missed, then the waiting on the condition variable will be forever (actually terminated after a timeout period and then started again, in a loop).

shlomi-stratoscale commented 9 years ago

refactored patch by eliran was pushed instead