cvmfs/cvmfs — pull request #340 by reneme (2014-01-10 16:31:31+00:00)
Title: FIX: Race Condition in Asynchronous Reader Class

This applies the same thread start/stop pattern to the `Reader` template, that I already used recently for the `AbstractUploader` base class. The situation here is a bit different, but I suspect it to potentially cause problems (*data race*, *premature memory releasing*). I am not a 100% sure, that this fixes the seen deadlock/crash behaviour, but it is a potential bug.

Additionally this contains a new unit test for the `SynchronizingCounter` template that was the suspect before, but turned out to work fine for now.

**TODO:** Since the concept of spawning/destroying a worker thread inside a specific class using `Initialize()` / `TearDown()` and connecting it using a `tbb::concurrent_bounded_queue` is now duplicated for `AbstractUploader` and `Reader<>`, it might be time to factor it out in a generic extra template. I didn't do it for now, since I first want to see, if it actually fixes these suspicious deadlocks.