diff options
author | unknown <Kristofer.Pettersson@naruto.> | 2006-12-14 15:52:06 +0100 |
---|---|---|
committer | unknown <Kristofer.Pettersson@naruto.> | 2006-12-14 15:52:06 +0100 |
commit | 2772d72a93788506b262eb3d022ee191bd913929 (patch) | |
tree | d6b73bffa0d596ec61c53425a0fe91f63cfd9c6f | |
parent | a9b7f5e61e94244db558052cc680e20ff41b25f7 (diff) | |
parent | e1411580c15de8051640448359a5eb7bd4c02b62 (diff) | |
download | mariadb-git-2772d72a93788506b262eb3d022ee191bd913929.tar.gz |
Merge kpettersson@bk-internal:/home/bk/mysql-5.0-maint
into naruto.:C:/cpp/mysql-5.0-maint
-rw-r--r-- | client/mysqltest.c | 5 | ||||
-rw-r--r-- | include/config-win.h | 1 | ||||
-rw-r--r-- | include/my_global.h | 36 | ||||
-rw-r--r-- | include/my_pthread.h | 79 | ||||
-rw-r--r-- | mysql-test/r/archive.result | 6 | ||||
-rw-r--r-- | mysql-test/t/archive.test | 10 | ||||
-rw-r--r-- | mysys/my_wincond.c | 28 | ||||
-rw-r--r-- | server-tools/instance-manager/guardian.cc | 5 | ||||
-rw-r--r-- | server-tools/instance-manager/instance.cc | 5 |
9 files changed, 114 insertions, 61 deletions
diff --git a/client/mysqltest.c b/client/mysqltest.c index ad5c3d6a5d1..a58f2ae376e 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -2976,7 +2976,12 @@ void safe_connect(MYSQL* mysql, const char *name, const char *host, if ((mysql_errno(mysql) == CR_CONN_HOST_ERROR || mysql_errno(mysql) == CR_CONNECTION_ERROR) && failed_attempts < opt_max_connect_retries) + { + verbose_msg("Connect attempt %d/%d failed: %d: %s", failed_attempts, + opt_max_connect_retries, mysql_errno(mysql), + mysql_error(mysql)); my_sleep(connection_retry_sleep); + } else { if (failed_attempts > 0) diff --git a/include/config-win.h b/include/config-win.h index 75133ddc837..3c76dee40a1 100644 --- a/include/config-win.h +++ b/include/config-win.h @@ -249,7 +249,6 @@ inline double ulonglong2double(ulonglong value) #define tell(A) _telli64(A) #endif -#define set_timespec(ABSTIME,SEC) { (ABSTIME).tv_sec=time((time_t*)0) + (time_t) (SEC); (ABSTIME).tv_nsec=0; } #define STACK_DIRECTION -1 diff --git a/include/my_global.h b/include/my_global.h index 7c072b2fc5c..d297f6f543c 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -1010,41 +1010,7 @@ typedef char bool; /* Ordinary boolean values 0 1 */ #define MY_HOW_OFTEN_TO_ALARM 2 /* How often we want info on screen */ #define MY_HOW_OFTEN_TO_WRITE 1000 /* How often we want info on screen */ -#ifdef HAVE_TIMESPEC_TS_SEC -#ifndef set_timespec -#define set_timespec(ABSTIME,SEC) \ -{ \ - (ABSTIME).ts_sec=time(0) + (time_t) (SEC); \ - (ABSTIME).ts_nsec=0; \ -} -#endif /* !set_timespec */ -#ifndef set_timespec_nsec -#define set_timespec_nsec(ABSTIME,NSEC) \ -{ \ - ulonglong now= my_getsystime() + (NSEC/100); \ - (ABSTIME).ts_sec= (now / ULL(10000000)); \ - (ABSTIME).ts_nsec= (now % ULL(10000000) * 100 + ((NSEC) % 100)); \ -} -#endif /* !set_timespec_nsec */ -#else -#ifndef set_timespec -#define set_timespec(ABSTIME,SEC) \ -{\ - struct timeval tv;\ - gettimeofday(&tv,0);\ - (ABSTIME).tv_sec=tv.tv_sec+(time_t) (SEC);\ - (ABSTIME).tv_nsec=tv.tv_usec*1000;\ -} -#endif /* !set_timespec */ -#ifndef set_timespec_nsec -#define set_timespec_nsec(ABSTIME,NSEC) \ -{\ - ulonglong now= my_getsystime() + (NSEC/100); \ - (ABSTIME).tv_sec= (time_t) (now / ULL(10000000)); \ - (ABSTIME).tv_nsec= (long) (now % ULL(10000000) * 100 + ((NSEC) % 100)); \ -} -#endif /* !set_timespec_nsec */ -#endif /* HAVE_TIMESPEC_TS_SEC */ + /* Define-funktions for reading and storing in machine independent format diff --git a/include/my_pthread.h b/include/my_pthread.h index 300291610d3..ebba0ab32e1 100644 --- a/include/my_pthread.h +++ b/include/my_pthread.h @@ -69,14 +69,6 @@ typedef struct { #endif } pthread_cond_t; - -#ifndef OS2 -struct timespec { /* For pthread_cond_timedwait() */ - time_t tv_sec; - long tv_nsec; -}; -#endif - typedef int pthread_mutexattr_t; #define win_pthread_self my_thread_var->pthread_self #ifdef OS2 @@ -87,6 +79,34 @@ typedef void * (_Optlink *pthread_handler)(void *); typedef void * (__cdecl *pthread_handler)(void *); #endif +/* + Struct and macros to be used in combination with the + windows implementation of pthread_cond_timedwait +*/ + +/* + Declare a union to make sure FILETIME is properly aligned + so it can be used directly as a 64 bit value. The value + stored is in 100ns units. + */ + union ft64 { + FILETIME ft; + __int64 i64; + }; +struct timespec { + union ft64 start; + /* The max timeout value in millisecond for pthread_cond_timedwait */ + long timeout_msec; +}; +#define set_timespec(ABSTIME,SEC) { \ + GetSystemTimeAsFileTime(&((ABSTIME).start.ft)); \ + (ABSTIME).timeout_msec= (long)((SEC)*1000); \ +} +#define set_timespec_nsec(ABSTIME,NSEC) { \ + GetSystemTimeAsFileTime(&((ABSTIME).start.ft)); \ + (ABSTIME).timeout_msec= (long)((NSEC)/1000000); \ +} + void win_pthread_init(void); int win_pthread_setspecific(void *A,void *B,uint length); int pthread_create(pthread_t *,pthread_attr_t *,pthread_handler,void *); @@ -164,8 +184,6 @@ extern int pthread_mutex_destroy (pthread_mutex_t *); #define pthread_condattr_init(A) #define pthread_condattr_destroy(A) -/*Irena: compiler does not like this: */ -/*#define my_pthread_getprio(pthread_t thread_id) pthread_dummy(0) */ #define my_pthread_getprio(thread_id) pthread_dummy(0) #elif defined(HAVE_UNIXWARE7_THREADS) @@ -473,6 +491,47 @@ void my_pthread_attr_getstacksize(pthread_attr_t *attrib, size_t *size); int my_pthread_mutex_trylock(pthread_mutex_t *mutex); #endif +/* + The defines set_timespec and set_timespec_nsec should be used + for calculating an absolute time at which + pthread_cond_timedwait should timeout +*/ +#ifdef HAVE_TIMESPEC_TS_SEC +#ifndef set_timespec +#define set_timespec(ABSTIME,SEC) \ +{ \ + (ABSTIME).ts_sec=time(0) + (time_t) (SEC); \ + (ABSTIME).ts_nsec=0; \ +} +#endif /* !set_timespec */ +#ifndef set_timespec_nsec +#define set_timespec_nsec(ABSTIME,NSEC) \ +{ \ + ulonglong now= my_getsystime() + (NSEC/100); \ + (ABSTIME).ts_sec= (now / ULL(10000000)); \ + (ABSTIME).ts_nsec= (now % ULL(10000000) * 100 + ((NSEC) % 100)); \ +} +#endif /* !set_timespec_nsec */ +#else +#ifndef set_timespec +#define set_timespec(ABSTIME,SEC) \ +{\ + struct timeval tv;\ + gettimeofday(&tv,0);\ + (ABSTIME).tv_sec=tv.tv_sec+(time_t) (SEC);\ + (ABSTIME).tv_nsec=tv.tv_usec*1000;\ +} +#endif /* !set_timespec */ +#ifndef set_timespec_nsec +#define set_timespec_nsec(ABSTIME,NSEC) \ +{\ + ulonglong now= my_getsystime() + (NSEC/100); \ + (ABSTIME).tv_sec= (time_t) (now / ULL(10000000)); \ + (ABSTIME).tv_nsec= (long) (now % ULL(10000000) * 100 + ((NSEC) % 100)); \ +} +#endif /* !set_timespec_nsec */ +#endif /* HAVE_TIMESPEC_TS_SEC */ + /* safe_mutex adds checking to mutex for easier debugging */ #if defined(__NETWARE__) && !defined(SAFE_MUTEX_DETECT_DESTROY) diff --git a/mysql-test/r/archive.result b/mysql-test/r/archive.result index 3be1cdcf15a..f73a80dde65 100644 --- a/mysql-test/r/archive.result +++ b/mysql-test/r/archive.result @@ -11120,7 +11120,13 @@ auto fld1 companynr fld3 fld4 fld5 fld6 2 011401 37 breaking dreaded Steinberg W 3 011402 37 Romans scholastics jarring 4 011403 37 intercepted audiology tinily +SELECT COUNT(auto) FROM t2; +COUNT(auto) +1213 INSERT DELAYED INTO t2 VALUES (4,011403,37,'intercepted','audiology','tinily',''); +SELECT COUNT(auto) FROM t2; +COUNT(auto) +1214 ALTER TABLE t2 DROP COLUMN fld6; SHOW CREATE TABLE t2; Table Create Table diff --git a/mysql-test/t/archive.test b/mysql-test/t/archive.test index f712a770712..80533f21311 100644 --- a/mysql-test/t/archive.test +++ b/mysql-test/t/archive.test @@ -1345,10 +1345,14 @@ SELECT * FROM t2; CHECK TABLE t2; SELECT * FROM t2; - -# Just test syntax, we will never know if the output is right or wrong -# Must be the last test +# Test INSERT DELAYED and wait until the table has one more record +SELECT COUNT(auto) FROM t2; INSERT DELAYED INTO t2 VALUES (4,011403,37,'intercepted','audiology','tinily',''); +while (`SELECT COUNT(auto)!=1214 FROM t2`) +{ + sleep 0.1; +} +SELECT COUNT(auto) FROM t2; # Adding test for alter table ALTER TABLE t2 DROP COLUMN fld6; diff --git a/mysys/my_wincond.c b/mysys/my_wincond.c index 8c497e8f250..327addff2cc 100644 --- a/mysys/my_wincond.c +++ b/mysys/my_wincond.c @@ -54,14 +54,30 @@ int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex) int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, struct timespec *abstime) { - struct _timeb curtime; int result; - long timeout; - _ftime(&curtime); - timeout= ((long) (abstime->tv_sec - curtime.time)*1000L + - (long)((abstime->tv_nsec/1000) - curtime.millitm)/1000L); - if (timeout < 0) /* Some safety */ + long timeout; + union ft64 now; + + GetSystemTimeAsFileTime(&now.ft); + + /* + - 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); + + /* Don't allow the timeout to be negative */ + if (timeout < 0) timeout = 0L; + + /* + Make sure the calucated time 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; + InterlockedIncrement(&cond->waiting); LeaveCriticalSection(mutex); result=WaitForSingleObject(cond->semaphore,timeout); diff --git a/server-tools/instance-manager/guardian.cc b/server-tools/instance-manager/guardian.cc index 0a037b5b98a..9fabb1923a8 100644 --- a/server-tools/instance-manager/guardian.cc +++ b/server-tools/instance-manager/guardian.cc @@ -228,9 +228,8 @@ void Guardian_thread::run() node= node->next; } - timeout.tv_sec= time(NULL) + monitoring_interval; - timeout.tv_nsec= 0; - + set_timespec(timeout, monitoring_interval); + /* check the loop predicate before sleeping */ if (!(shutdown_requested && (!(guarded_instances)))) thread_registry.cond_timedwait(&thread_info, &COND_guardian, diff --git a/server-tools/instance-manager/instance.cc b/server-tools/instance-manager/instance.cc index daa8082ef2f..39793b9a234 100644 --- a/server-tools/instance-manager/instance.cc +++ b/server-tools/instance-manager/instance.cc @@ -476,10 +476,9 @@ int Instance::stop() waitchild= options.shutdown_delay_val; kill_instance(SIGTERM); - /* sleep on condition to wait for SIGCHLD */ - timeout.tv_sec= time(NULL) + waitchild; - timeout.tv_nsec= 0; + /* sleep on condition to wait for SIGCHLD */ + set_timespec(timeout, waitchild); if (pthread_mutex_lock(&LOCK_instance)) return ER_STOP_INSTANCE; |