List:Commits« Previous MessageNext Message »
From:msvensson Date:December 13 2006 9:54pm
Subject:bk commit into 5.0 tree (msvensson:1.2352) BUG#24687
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of . When  does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2006-12-13 21:54:40+01:00, msvensson@shellback. +6 -0
  BUG#24687 func_misc test fails on win64
   - Use same precision (milliseconds) for all time functions
     used  when calculating time for pthread_cond_timedwait 

  include/config-win.h@stripped, 2006-12-13 21:53:27+01:00, msvensson@shellback. +0 -1
    Move all defines for 'pthread_cond_timedwait' to my_pthread.h

  include/my_global.h@stripped, 2006-12-13 21:53:27+01:00, msvensson@shellback. +1 -35
    Move all defines for 'pthread_cond_timedwait' to my_pthread.h

  include/my_pthread.h@stripped, 2006-12-13 21:53:27+01:00, msvensson@shellback. +68 -10
    Redefine "struct timespec" to better suite the needs 
    of 'pthread_cond_timedwait' for windows implementation
    Add define for set_timespec_nsec
    Move all defines related pthread_cond_timed wait to same file

  mysys/my_wincond.c@stripped, 2006-12-13 21:53:28+01:00, msvensson@shellback. +10 -1
    Use new members of "struct timespec"
    Make usre the calculated "timeout" value never exceed the value
    passed to set_timespec_x 

  server-tools/instance-manager/guardian.cc@stripped, 2006-12-13 21:53:28+01:00,
msvensson@shellback. +2 -3
    Use set_timespec macro

  server-tools/instance-manager/instance.cc@stripped, 2006-12-13 21:53:29+01:00,
msvensson@shellback. +2 -3
    Use set_timespec macro

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	msvensson
# Host:	shellback.
# Root:	C:/mysql/mysql-5.0-maint

--- 1.81/include/config-win.h	2006-06-01 11:34:37 +02:00
+++ 1.82/include/config-win.h	2006-12-13 21:53:27 +01:00
@@ -249,7 +249,6 @@
 #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
 

--- 1.92/include/my_pthread.h	2006-11-29 21:14:06 +01:00
+++ 1.93/include/my_pthread.h	2006-12-13 21:53:27 +01:00
@@ -69,14 +69,6 @@
 #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,33 @@
 typedef void * (__cdecl *pthread_handler)(void *);
 #endif
 
+/*
+  Struct and macros to be used in combination with the
+  windows implementation of pthread_cond_timedwait
+*/
+#include <sys/timeb.h>
+struct timespec {
+  /* Absolute time to wakeup */
+  time_t tv_sec;
+  unsigned short tv_msec;
+  /* Max timeout value for 'WaitForSingleObject' */
+  DWORD max_timeout_msec;
+};
+#define set_timespec(ABSTIME,SEC) { \
+  (ABSTIME).tv_sec= time((time_t*)0) + (time_t) (SEC); \
+  (ABSTIME).tv_msec= 0; \
+  (ABSTIME).max_timeout_msec= (SEC)*1000; \
+}
+#define set_timespec_nsec(ABSTIME,NSEC) { \
+  struct _timeb curtime; \
+  ulonglong now; \
+  _ftime(&curtime); \
+  now= curtime.time * 1000 + curtime.millitm + (NSEC/1000000); \
+  (ABSTIME).tv_msec= now % 1000; \
+  (ABSTIME).tv_sec= (time_t) (now / 1000 ); \
+  (ABSTIME).max_timeout_msec= (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 +183,6 @@
 #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)
@@ -472,6 +489,47 @@
 #define pthread_mutex_trylock(a) my_pthread_mutex_trylock((a))
 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 */
 

--- 1.6/mysys/my_wincond.c	2001-12-06 13:10:43 +01:00
+++ 1.7/mysys/my_wincond.c	2006-12-13 21:53:28 +01:00
@@ -59,9 +59,18 @@
   long timeout;
   _ftime(&curtime);
   timeout= ((long) (abstime->tv_sec - curtime.time)*1000L +
-		    (long)((abstime->tv_nsec/1000) - curtime.millitm)/1000L);
+		    (long)(abstime->tv_msec - curtime.millitm));
+
   if (timeout < 0)				/* Some safety */
     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->max_timeout_msec)
+    timeout= abstime->max_timeout_msec;
+
   InterlockedIncrement(&cond->waiting);
   LeaveCriticalSection(mutex);
   result=WaitForSingleObject(cond->semaphore,timeout);

--- 1.129/include/my_global.h	2006-11-30 17:24:52 +01:00
+++ 1.130/include/my_global.h	2006-12-13 21:53:27 +01:00
@@ -1010,41 +1010,7 @@
 #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

--- 1.25/server-tools/instance-manager/guardian.cc	2006-11-30 20:56:01 +01:00
+++ 1.26/server-tools/instance-manager/guardian.cc	2006-12-13 21:53:28 +01:00
@@ -228,9 +228,8 @@
 
       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,

--- 1.35/server-tools/instance-manager/instance.cc	2006-10-20 20:26:38 +02:00
+++ 1.36/server-tools/instance-manager/instance.cc	2006-12-13 21:53:29 +01:00
@@ -476,10 +476,9 @@
       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;
 

Thread
bk commit into 5.0 tree (msvensson:1.2352) BUG#24687msvensson13 Dec