"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "test/testlock.c" between
apr-1.6.5.tar.bz2 and apr-1.7.0.tar.bz2

About: APR (Apache Portable Runtime) project offers software libraries that provide a predictable and consistent interface to underlying platform-specific implementations (APR core library).

testlock.c  (apr-1.6.5.tar.bz2):testlock.c  (apr-1.7.0.tar.bz2)
skipping to change at line 93 skipping to change at line 93
static void *APR_THREAD_FUNC thread_mutex_function(apr_thread_t *thd, void *data ) static void *APR_THREAD_FUNC thread_mutex_function(apr_thread_t *thd, void *data )
{ {
int exitLoop = 1; int exitLoop = 1;
/* slight delay to allow things to settle */ /* slight delay to allow things to settle */
apr_sleep (1); apr_sleep (1);
while (1) while (1)
{ {
apr_thread_mutex_lock(thread_mutex); if (data) {
apr_thread_mutex_timedlock(thread_mutex, *(apr_interval_time_t *)dat
a);
}
else {
apr_thread_mutex_lock(thread_mutex);
}
if (i == MAX_ITER) if (i == MAX_ITER)
exitLoop = 0; exitLoop = 0;
else else
{ {
i++; i++;
x++; x++;
} }
apr_thread_mutex_unlock(thread_mutex); apr_thread_mutex_unlock(thread_mutex);
if (!exitLoop) if (!exitLoop)
skipping to change at line 181 skipping to change at line 186
ABTS_INT_EQUAL(tc, APR_SUCCESS, s4); ABTS_INT_EQUAL(tc, APR_SUCCESS, s4);
apr_thread_join(&s1, t1); apr_thread_join(&s1, t1);
apr_thread_join(&s2, t2); apr_thread_join(&s2, t2);
apr_thread_join(&s3, t3); apr_thread_join(&s3, t3);
apr_thread_join(&s4, t4); apr_thread_join(&s4, t4);
ABTS_INT_EQUAL(tc, MAX_ITER, x); ABTS_INT_EQUAL(tc, MAX_ITER, x);
} }
#if APR_HAS_TIMEDLOCKS
static void test_thread_timedmutex(abts_case *tc, void *data)
{
apr_thread_t *t1, *t2, *t3, *t4;
apr_status_t s1, s2, s3, s4;
apr_interval_time_t timeout;
s1 = apr_thread_mutex_create(&thread_mutex, APR_THREAD_MUTEX_TIMED, p);
ABTS_INT_EQUAL(tc, APR_SUCCESS, s1);
ABTS_PTR_NOTNULL(tc, thread_mutex);
i = 0;
x = 0;
timeout = apr_time_from_sec(5);
s1 = apr_thread_create(&t1, NULL, thread_mutex_function, &timeout, p);
ABTS_INT_EQUAL(tc, APR_SUCCESS, s1);
s2 = apr_thread_create(&t2, NULL, thread_mutex_function, &timeout, p);
ABTS_INT_EQUAL(tc, APR_SUCCESS, s2);
s3 = apr_thread_create(&t3, NULL, thread_mutex_function, &timeout, p);
ABTS_INT_EQUAL(tc, APR_SUCCESS, s3);
s4 = apr_thread_create(&t4, NULL, thread_mutex_function, &timeout, p);
ABTS_INT_EQUAL(tc, APR_SUCCESS, s4);
apr_thread_join(&s1, t1);
apr_thread_join(&s2, t2);
apr_thread_join(&s3, t3);
apr_thread_join(&s4, t4);
ABTS_INT_EQUAL(tc, MAX_ITER, x);
}
#endif
static void test_thread_rwlock(abts_case *tc, void *data) static void test_thread_rwlock(abts_case *tc, void *data)
{ {
apr_thread_t *t1, *t2, *t3, *t4; apr_thread_t *t1, *t2, *t3, *t4;
apr_status_t s1, s2, s3, s4; apr_status_t s1, s2, s3, s4;
s1 = apr_thread_rwlock_create(&rwlock, p); s1 = apr_thread_rwlock_create(&rwlock, p);
if (s1 == APR_ENOTIMPL) { if (s1 == APR_ENOTIMPL) {
ABTS_NOT_IMPL(tc, "rwlocks not implemented"); ABTS_NOT_IMPL(tc, "rwlocks not implemented");
return; return;
} }
skipping to change at line 300 skipping to change at line 339
begin = apr_time_now(); begin = apr_time_now();
s = apr_thread_cond_timedwait(timeout_cond, timeout_mutex, timeout); s = apr_thread_cond_timedwait(timeout_cond, timeout_mutex, timeout);
end = apr_time_now(); end = apr_time_now();
apr_thread_mutex_unlock(timeout_mutex); apr_thread_mutex_unlock(timeout_mutex);
if (s != APR_SUCCESS && !APR_STATUS_IS_TIMEUP(s)) { if (s != APR_SUCCESS && !APR_STATUS_IS_TIMEUP(s)) {
continue; continue;
} }
ABTS_INT_EQUAL(tc, 1, APR_STATUS_IS_TIMEUP(s)); ABTS_INT_EQUAL(tc, 1, APR_STATUS_IS_TIMEUP(s));
ABTS_ASSERT(tc, "Timer returned too late", end - begin - timeout < 10000 0); ABTS_ASSERT(tc, "Timer returned too late", end - begin - timeout < 50000 0);
break; break;
} }
ABTS_ASSERT(tc, "Too many retries", i < MAX_RETRY); ABTS_ASSERT(tc, "Too many retries", i < MAX_RETRY);
APR_ASSERT_SUCCESS(tc, "Unable to destroy the conditional", APR_ASSERT_SUCCESS(tc, "Unable to destroy the conditional",
apr_thread_cond_destroy(timeout_cond)); apr_thread_cond_destroy(timeout_cond));
} }
#if APR_HAS_TIMEDLOCKS
static void test_timeoutmutex(abts_case *tc, void *data)
{
apr_status_t s;
apr_interval_time_t timeout;
apr_time_t begin, end;
int i;
s = apr_thread_mutex_create(&timeout_mutex, APR_THREAD_MUTEX_TIMED, p);
ABTS_INT_EQUAL(tc, APR_SUCCESS, s);
ABTS_PTR_NOTNULL(tc, timeout_mutex);
timeout = apr_time_from_sec(5);
ABTS_INT_EQUAL(tc, 0, apr_thread_mutex_lock(timeout_mutex));
for (i = 0; i < MAX_RETRY; i++) {
begin = apr_time_now();
s = apr_thread_mutex_timedlock(timeout_mutex, timeout);
end = apr_time_now();
if (s != APR_SUCCESS && !APR_STATUS_IS_TIMEUP(s)) {
continue;
}
ABTS_INT_EQUAL(tc, 1, APR_STATUS_IS_TIMEUP(s));
ABTS_ASSERT(tc, "Timer returned too late", end - begin - timeout < 10000
00);
break;
}
ABTS_ASSERT(tc, "Too many retries", i < MAX_RETRY);
ABTS_INT_EQUAL(tc, 0, apr_thread_mutex_unlock(timeout_mutex));
APR_ASSERT_SUCCESS(tc, "Unable to destroy the mutex",
apr_thread_mutex_destroy(timeout_mutex));
}
#endif
#endif /* !APR_HAS_THREADS */ #endif /* !APR_HAS_THREADS */
#if !APR_HAS_THREADS #if !APR_HAS_THREADS
static void threads_not_impl(abts_case *tc, void *data) static void threads_not_impl(abts_case *tc, void *data)
{ {
ABTS_NOT_IMPL(tc, "Threads not implemented on this platform"); ABTS_NOT_IMPL(tc, "Threads not implemented on this platform");
} }
#endif #endif
abts_suite *testlock(abts_suite *suite) abts_suite *testlock(abts_suite *suite)
{ {
suite = ADD_SUITE(suite) suite = ADD_SUITE(suite)
#if !APR_HAS_THREADS #if !APR_HAS_THREADS
abts_run_test(suite, threads_not_impl, NULL); abts_run_test(suite, threads_not_impl, NULL);
#else #else
abts_run_test(suite, test_thread_mutex, NULL); abts_run_test(suite, test_thread_mutex, NULL);
#if APR_HAS_TIMEDLOCKS
abts_run_test(suite, test_thread_timedmutex, NULL);
#endif
abts_run_test(suite, test_thread_rwlock, NULL); abts_run_test(suite, test_thread_rwlock, NULL);
abts_run_test(suite, test_cond, NULL); abts_run_test(suite, test_cond, NULL);
abts_run_test(suite, test_timeoutcond, NULL); abts_run_test(suite, test_timeoutcond, NULL);
#if APR_HAS_TIMEDLOCKS
abts_run_test(suite, test_timeoutmutex, NULL);
#endif
#endif #endif
return suite; return suite;
} }
 End of changes. 6 change blocks. 
2 lines changed or deleted 83 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)