aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2010-04-12 18:22:06 -0400
committerNick Mathewson <nickm@torproject.org>2010-04-12 18:22:06 -0400
commit7221d15acc87d2438aba7e3c261c2fc460479a01 (patch)
treeb18a7d0af4d6b181d023f132e2b2167da94cadce /src
parent311aca5a3472cd318b72ca21d7a530182154e75c (diff)
parent5e679acc72a2648c38a3ee3a2b05cd5b75906568 (diff)
downloadtor-7221d15acc87d2438aba7e3c261c2fc460479a01.tar
tor-7221d15acc87d2438aba7e3c261c2fc460479a01.tar.gz
Merge commit 'origin/maint-0.2.1'
Conflicts: src/or/test.c
Diffstat (limited to 'src')
-rw-r--r--src/test/test_util.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/test/test_util.c b/src/test/test_util.c
index ad5a27e51..bba96325c 100644
--- a/src/test/test_util.c
+++ b/src/test/test_util.c
@@ -448,6 +448,11 @@ test_util_threads(void)
char *s1 = NULL, *s2 = NULL;
int done = 0, timedout = 0;
time_t started;
+#ifndef MS_WINDOWS
+ struct timeval tv;
+ tv.tv_sec=0;
+ tv.tv_usec=10;
+#endif
#ifndef TOR_IS_MULTITHREADED
/* Skip this test if we aren't threading. We should be threading most
* everywhere by now. */
@@ -477,14 +482,18 @@ test_util_threads(void)
timedout = done = 1;
}
tor_mutex_release(_thread_test_mutex);
+#ifndef MS_WINDOWS
+ /* Prevent the main thread from starving the worker threads. */
+ select(0, NULL, NULL, NULL, &tv);
+#endif
}
- tor_mutex_free(_thread_test_mutex);
-
tor_mutex_acquire(_thread_test_start1);
tor_mutex_release(_thread_test_start1);
tor_mutex_acquire(_thread_test_start2);
tor_mutex_release(_thread_test_start2);
+ tor_mutex_free(_thread_test_mutex);
+
if (timedout) {
printf("\nTimed out: %d %d", t1_count, t2_count);
test_assert(strmap_get(_thread_test_strmap, "thread 1"));