"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "test/testmutexscope.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).

testmutexscope.c  (apr-1.6.5.tar.bz2):testmutexscope.c  (apr-1.7.0.tar.bz2)
skipping to change at line 46 skipping to change at line 46
#else /* APR_HAS_THREADS */ #else /* APR_HAS_THREADS */
static apr_thread_mutex_t *thread_mutex; static apr_thread_mutex_t *thread_mutex;
static apr_proc_mutex_t *proc_mutex; static apr_proc_mutex_t *proc_mutex;
static apr_global_mutex_t *global_mutex; static apr_global_mutex_t *global_mutex;
static apr_pool_t *p; static apr_pool_t *p;
static volatile int counter; static volatile int counter;
typedef enum {TEST_GLOBAL, TEST_PROC} test_mode_e; typedef enum {TEST_GLOBAL, TEST_PROC} test_mode_e;
static void lock_init(apr_lockmech_e mech, test_mode_e test_mode) static int lock_init(apr_lockmech_e mech, test_mode_e test_mode)
{ {
apr_status_t rv;
if (test_mode == TEST_PROC) { if (test_mode == TEST_PROC) {
assert(apr_proc_mutex_create(&proc_mutex, rv = apr_proc_mutex_create(&proc_mutex,
NULL, NULL,
mech, mech,
p) == APR_SUCCESS); p);
} }
else { else {
assert(apr_global_mutex_create(&global_mutex, rv = apr_global_mutex_create(&global_mutex,
NULL, NULL,
mech, mech,
p) == APR_SUCCESS); p);
} }
return rv;
} }
static void lock_destroy(test_mode_e test_mode) static void lock_destroy(test_mode_e test_mode)
{ {
if (test_mode == TEST_PROC) { if (test_mode == TEST_PROC) {
assert(apr_proc_mutex_destroy(proc_mutex) == APR_SUCCESS); assert(apr_proc_mutex_destroy(proc_mutex) == APR_SUCCESS);
} }
else { else {
assert(apr_global_mutex_destroy(global_mutex) == APR_SUCCESS); assert(apr_global_mutex_destroy(global_mutex) == APR_SUCCESS);
} }
skipping to change at line 123 skipping to change at line 125
printf("Trying %s mutexes with mechanism `%s'...\n", printf("Trying %s mutexes with mechanism `%s'...\n",
test_mode == TEST_GLOBAL ? "global" : "proc", mech_name); test_mode == TEST_GLOBAL ? "global" : "proc", mech_name);
assert(numThreads <= sizeof(threads) / sizeof(threads[0])); assert(numThreads <= sizeof(threads) / sizeof(threads[0]));
assert(apr_pool_create(&p, NULL) == APR_SUCCESS); assert(apr_pool_create(&p, NULL) == APR_SUCCESS);
assert(apr_thread_mutex_create(&thread_mutex, 0, p) == APR_SUCCESS); assert(apr_thread_mutex_create(&thread_mutex, 0, p) == APR_SUCCESS);
assert(apr_thread_mutex_lock(thread_mutex) == APR_SUCCESS); assert(apr_thread_mutex_lock(thread_mutex) == APR_SUCCESS);
lock_init(mech, test_mode); rv = lock_init(mech, test_mode);
if (rv != APR_SUCCESS) {
char errmsg[256];
printf("%s mutexes with mechanism `%s': %s\n",
test_mode == TEST_GLOBAL ? "Global" : "Proc", mech_name,
apr_strerror(rv, errmsg, sizeof errmsg));
if (rv != APR_ENOTIMPL || mech == APR_LOCK_DEFAULT) {
exit(1);
}
return;
}
counter = 0; counter = 0;
i = 0; i = 0;
while (i < numThreads) while (i < numThreads)
{ {
rv = apr_thread_create(&threads[i], rv = apr_thread_create(&threads[i],
NULL, NULL,
eachThread, eachThread,
(void *)test_mode, (void *)test_mode,
skipping to change at line 145 skipping to change at line 157
if (rv != APR_SUCCESS) { if (rv != APR_SUCCESS) {
fprintf(stderr, "apr_thread_create->%d\n", rv); fprintf(stderr, "apr_thread_create->%d\n", rv);
exit(1); exit(1);
} }
++i; ++i;
} }
apr_sleep(apr_time_from_sec(5)); apr_sleep(apr_time_from_sec(5));
if (test_mode == TEST_PROC) { if (test_mode == TEST_PROC) {
printf(" Mutex mechanism `%s' is %sglobal in scope on this platform.\n", printf(" mutex mechanism `%s' is %sglobal in scope on this platform.\n",
mech_name, counter == 1 ? "" : "*NOT* "); mech_name, counter == 1 ? "" : "*NOT* ");
} }
else { else {
if (counter != 1) { if (counter != 1) {
fprintf(stderr, "\n!!!apr_global_mutex operations are broken on this " fprintf(stderr, "\n!!!apr_global_mutex operations are broken on this "
"platform for mutex mechanism `%s'!\n" "platform for mutex mechanism `%s'!\n"
"They don't block out threads within the same process.\n", "They don't block out threads within the same process.\n",
mech_name); mech_name);
fprintf(stderr, "counter value: %d\n", counter); fprintf(stderr, "counter value: %d\n", counter);
exit(1); exit(1);
} }
else { else {
printf(" no problems encountered...\n"); printf(" no problem encountered...\n");
} }
} }
assert(apr_thread_mutex_unlock(thread_mutex) == APR_SUCCESS); assert(apr_thread_mutex_unlock(thread_mutex) == APR_SUCCESS);
i = 0; i = 0;
while (i < numThreads) while (i < numThreads)
{ {
apr_status_t ignored; apr_status_t ignored;
skipping to change at line 208 skipping to change at line 220
#endif #endif
#if APR_HAS_POSIXSEM_SERIALIZE #if APR_HAS_POSIXSEM_SERIALIZE
,{APR_LOCK_POSIXSEM, "posix"} ,{APR_LOCK_POSIXSEM, "posix"}
#endif #endif
#if APR_HAS_FCNTL_SERIALIZE #if APR_HAS_FCNTL_SERIALIZE
,{APR_LOCK_FCNTL, "fcntl"} ,{APR_LOCK_FCNTL, "fcntl"}
#endif #endif
#if APR_HAS_PROC_PTHREAD_SERIALIZE #if APR_HAS_PROC_PTHREAD_SERIALIZE
,{APR_LOCK_PROC_PTHREAD, "proc_pthread"} ,{APR_LOCK_PROC_PTHREAD, "proc_pthread"}
#endif #endif
,{APR_LOCK_DEFAULT_TIMED, "default_timed"}
}; };
int i; int i;
assert(apr_initialize() == APR_SUCCESS); assert(apr_initialize() == APR_SUCCESS);
for (i = 0; i < sizeof(lockmechs) / sizeof(lockmechs[0]); i++) { for (i = 0; i < sizeof(lockmechs) / sizeof(lockmechs[0]); i++) {
test_mech(lockmechs[i].mech, lockmechs[i].mech_name); test_mech(lockmechs[i].mech, lockmechs[i].mech_name);
} }
apr_terminate(); apr_terminate();
 End of changes. 9 change blocks. 
12 lines changed or deleted 25 lines changed or added

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