mirror of
https://github.com/MariaDB/server.git
synced 2025-01-23 07:14:17 +01:00
daa05c3f29
svn merge --accept=postpone -r 12459:12461 ../../mysql.branches/2.0.1/tokudb/ git-svn-id: file:///svn/toku/tokudb@12462 c7de825b-a66e-492c-adef-691d508d4ae1
45 lines
1.5 KiB
C
45 lines
1.5 KiB
C
#include <toku_assert.h>
|
|
#include <test.h>
|
|
#include <toku_pthread.h>
|
|
#include <stdio.h>
|
|
#include <unistd.h>
|
|
|
|
void *f(void *arg) {
|
|
int r;
|
|
toku_pthread_rwlock_t *mylock = arg;
|
|
printf("%s:%d\n", __FUNCTION__, __LINE__); fflush(stdout);
|
|
r = toku_pthread_rwlock_wrlock(mylock); assert(r == 0);
|
|
printf("%s:%d\n", __FUNCTION__, __LINE__); fflush(stdout);
|
|
r = toku_pthread_rwlock_wrunlock(mylock); assert(r == 0);
|
|
printf("%s:%d\n", __FUNCTION__, __LINE__); fflush(stdout);
|
|
return arg;
|
|
}
|
|
|
|
int test_main(int argc, char *argv[]) {
|
|
int r;
|
|
toku_pthread_rwlock_t rwlock;
|
|
toku_pthread_t tid;
|
|
void *retptr;
|
|
|
|
r = toku_pthread_rwlock_init(&rwlock, NULL); assert(r == 0);
|
|
printf("%s:%d\n", __FUNCTION__, __LINE__); fflush(stdout);
|
|
r = toku_pthread_rwlock_rdlock(&rwlock); assert(r == 0);
|
|
|
|
r = toku_pthread_create(&tid, NULL, f, &rwlock); assert(r == 0);
|
|
|
|
printf("%s:%d\n", __FUNCTION__, __LINE__); fflush(stdout);
|
|
sleep(10);
|
|
printf("%s:%d\n", __FUNCTION__, __LINE__); fflush(stdout);
|
|
r = toku_pthread_rwlock_rdlock(&rwlock); assert(r == 0);
|
|
printf("%s:%d\n", __FUNCTION__, __LINE__); fflush(stdout);
|
|
r = toku_pthread_rwlock_rdunlock(&rwlock); assert(r == 0);
|
|
printf("%s:%d\n", __FUNCTION__, __LINE__); fflush(stdout);
|
|
r = toku_pthread_rwlock_rdunlock(&rwlock); assert(r == 0);
|
|
printf("%s:%d\n", __FUNCTION__, __LINE__); fflush(stdout);
|
|
|
|
r = toku_pthread_join(tid, &retptr); assert(r == 0);
|
|
|
|
r = toku_pthread_rwlock_destroy(&rwlock); assert(r == 0);
|
|
|
|
return 0;
|
|
}
|