According to POSIX, the mutex must be locked by the thread calling the signal
functions to ensure predictable scheduling behavior.
Found the issue using Helgrind which gave the warning `dubious: associated lock
is not held by any thread`.
--- /dev/null
+ o Minor bugfixes (relay):
+ - Unblock threads before releasing the mutex to ensure predictable
+ scheduling behavior. Fixes bug 16644; bugfix on 0.2.6.3-alpha.
TOR_TAILQ_INSERT_TAIL(&pool->work, ent, next_work);
- tor_mutex_release(&pool->lock);
-
tor_cond_signal_one(&pool->condition);
+ tor_mutex_release(&pool->lock);
+
return ent;
}
pool->update_fn = fn;
++pool->generation;
- tor_mutex_release(&pool->lock);
-
tor_cond_signal_all(&pool->condition);
+ tor_mutex_release(&pool->lock);
+
if (old_args) {
for (i = 0; i < n_threads; ++i) {
if (old_args[i] && old_args_free_fn)