daemon: Manager::addTask() is not threadsafe and can cause race-condition
Issue generated from Tuleap's migration script. Originally submitted by: Guillaume Roguez (guillaume)
As the comment below Manager::addTask() warns:
// Not thread-safe, SHOULD be called in same thread that run poolEvents()
But Manager::runOnMainThread() call this function and developpers don't have noticed this warning by calling this later out of the main-thread (the one that call poolEvents).
This led into possible non-added task (due to a race-condition)
Solution is to make it thread-safe (like by a mutex protection)