Merge commit 'origin/maint-0.2.1'

Conflicts:
	src/or/test.c
This commit is contained in:
Nick Mathewson 2010-04-12 18:22:06 -04:00
commit 7221d15acc
2 changed files with 19 additions and 2 deletions

View File

@ -0,0 +1,8 @@
o Minor bugfixes:
- Testsuite: In the util/threads test no longer free the test_mutex
before all worker threads have finished.
- Testsuite: The master thread could starve the worker threads quite
badly on certain systems, causing them to run only partially in
the allowed window. This resulted in test failures. Now the master
thread sleeps occasionally for a few microseconds while the two
worker-threads compete for the mutex.

View File

@ -448,6 +448,11 @@ test_util_threads(void)
char *s1 = NULL, *s2 = NULL; char *s1 = NULL, *s2 = NULL;
int done = 0, timedout = 0; int done = 0, timedout = 0;
time_t started; time_t started;
#ifndef MS_WINDOWS
struct timeval tv;
tv.tv_sec=0;
tv.tv_usec=10;
#endif
#ifndef TOR_IS_MULTITHREADED #ifndef TOR_IS_MULTITHREADED
/* Skip this test if we aren't threading. We should be threading most /* Skip this test if we aren't threading. We should be threading most
* everywhere by now. */ * everywhere by now. */
@ -477,14 +482,18 @@ test_util_threads(void)
timedout = done = 1; timedout = done = 1;
} }
tor_mutex_release(_thread_test_mutex); 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_acquire(_thread_test_start1);
tor_mutex_release(_thread_test_start1); tor_mutex_release(_thread_test_start1);
tor_mutex_acquire(_thread_test_start2); tor_mutex_acquire(_thread_test_start2);
tor_mutex_release(_thread_test_start2); tor_mutex_release(_thread_test_start2);
tor_mutex_free(_thread_test_mutex);
if (timedout) { if (timedout) {
printf("\nTimed out: %d %d", t1_count, t2_count); printf("\nTimed out: %d %d", t1_count, t2_count);
test_assert(strmap_get(_thread_test_strmap, "thread 1")); test_assert(strmap_get(_thread_test_strmap, "thread 1"));