From 1aad903b710c2dc8452cfa64fcda43e5906cfa83 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 18 Dec 2006 10:22:48 +0100 Subject: [PATCH 1/2] Use MYSQLTEST_VARDIR variable --- mysql-test/r/symlink.result | 4 ++-- mysql-test/t/symlink.test | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/symlink.result b/mysql-test/r/symlink.result index 1589f98a8af..4725bcc0ac9 100644 --- a/mysql-test/r/symlink.result +++ b/mysql-test/r/symlink.result @@ -115,12 +115,12 @@ show create table t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( `a` int(11) default NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TEST_DIR/var/log/' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQLTEST_VARDIR/log/' show create table t1; Table Create Table t1 CREATE TEMPORARY TABLE `t1` ( `a` int(11) default NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQL_TEST_DIR/var/log/' +) ENGINE=MyISAM DEFAULT CHARSET=latin1 DATA DIRECTORY='MYSQLTEST_VARDIR/log/' create table t1 (a int) engine=myisam select 42 a; select * from t1; a diff --git a/mysql-test/t/symlink.test b/mysql-test/t/symlink.test index 7924f00a9c8..d79b6905224 100644 --- a/mysql-test/t/symlink.test +++ b/mysql-test/t/symlink.test @@ -147,20 +147,20 @@ connect (session2,localhost,root,,); connection session1; disable_query_log; -eval create temporary table t1 (a int) engine=myisam data directory="$MYSQL_TEST_DIR/var/log" select 9 a; +eval create temporary table t1 (a int) engine=myisam data directory="$MYSQLTEST_VARDIR/log" select 9 a; enable_query_log; # If running test suite with a non standard tmp dir, the "show create table" # will print "DATA_DIRECTORY=". Use replace_result to mask it out ---replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR show create table t1; connection session2; disable_query_log; -eval create temporary table t1 (a int) engine=myisam data directory="$MYSQL_TEST_DIR/var/log" select 99 a; +eval create temporary table t1 (a int) engine=myisam data directory="$MYSQLTEST_VARDIR/log" select 99 a; enable_query_log; # If running test suite with a non standard tmp dir, the "show create table" # will print "DATA_DIRECTORY=". Use replace_result to mask it out ---replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR show create table t1; connection default; From 43a251011cf7413c3d6728d6f447b78344259c1d Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 18 Dec 2006 11:09:47 +0100 Subject: [PATCH 2/2] Change windows pthread_cond_timedwait to use an absolute time value include/my_pthread.h: Calculate absolute time value int set_timespec_* mysys/my_wincond.c: Use absolute timevalue in pthread_cond_timedwwait --- include/my_pthread.h | 14 ++++++++------ mysys/my_wincond.c | 19 ++++++++++--------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/include/my_pthread.h b/include/my_pthread.h index ebba0ab32e1..631ca1d7c03 100644 --- a/include/my_pthread.h +++ b/include/my_pthread.h @@ -94,17 +94,19 @@ typedef void * (__cdecl *pthread_handler)(void *); __int64 i64; }; struct timespec { - union ft64 start; + union ft64 tv; /* The max timeout value in millisecond for pthread_cond_timedwait */ - long timeout_msec; + long max_timeout_msec; }; #define set_timespec(ABSTIME,SEC) { \ - GetSystemTimeAsFileTime(&((ABSTIME).start.ft)); \ - (ABSTIME).timeout_msec= (long)((SEC)*1000); \ + GetSystemTimeAsFileTime(&((ABSTIME).tv.ft)); \ + (ABSTIME).tv.i64+= (__int64)(SEC)*10000000; \ + (ABSTIME).max_timeout_msec= (long)((SEC)*1000); \ } #define set_timespec_nsec(ABSTIME,NSEC) { \ - GetSystemTimeAsFileTime(&((ABSTIME).start.ft)); \ - (ABSTIME).timeout_msec= (long)((NSEC)/1000000); \ + GetSystemTimeAsFileTime(&((ABSTIME).tv.ft)); \ + (ABSTIME).tv.i64+= (__int64)(NSEC)/100; \ + (ABSTIME).max_timeout_msec= (long)((NSEC)/1000000); \ } void win_pthread_init(void); diff --git a/mysys/my_wincond.c b/mysys/my_wincond.c index 327addff2cc..b56dacc135a 100644 --- a/mysys/my_wincond.c +++ b/mysys/my_wincond.c @@ -37,7 +37,7 @@ int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr) int pthread_cond_destroy(pthread_cond_t *cond) { - return CloseHandle(cond->semaphore) ? 0 : EINVAL; + return CloseHandle(cond->semaphore) ? 0 : EINVAL; } @@ -51,6 +51,7 @@ int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex) return 0 ; } + int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, struct timespec *abstime) { @@ -61,26 +62,26 @@ int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, GetSystemTimeAsFileTime(&now.ft); /* - - subtract start time from current time(values are in 100ns units + Calculate time left to abstime + - subtract start time from current time(values are in 100ns units) - convert to millisec by dividing with 10000 - - subtract time since start from max timeout */ - timeout= abstime->timeout_msec - (long)((now.i64 - abstime->start.i64) / 10000); + timeout= (long)((abstime->tv.i64 - now.i64) / 10000); /* Don't allow the timeout to be negative */ if (timeout < 0) - timeout = 0L; + timeout= 0L; /* - Make sure the calucated time does not exceed original timeout + Make sure the calucated timeout does not exceed original timeout value which could cause "wait for ever" if system time changes */ - if (timeout > abstime->timeout_msec) - timeout= abstime->timeout_msec; + if (timeout > abstime->max_timeout_msec) + timeout= abstime->max_timeout_msec; InterlockedIncrement(&cond->waiting); LeaveCriticalSection(mutex); - result=WaitForSingleObject(cond->semaphore,timeout); + result= WaitForSingleObject(cond->semaphore,timeout); InterlockedDecrement(&cond->waiting); EnterCriticalSection(mutex);