List:Maria Storage Engine« Previous MessageNext Message »
From:Guilhem Bichot Date:February 12 2009 9:12pm
Subject:bzr commit into MySQL/Maria:mysql-maria branch (guilhem:2734)
View as plain text  
#At bzr+ssh://bk-internal.mysql.com/bzrroot/server/mysql-maria/ based on revid:guilhem@stripped

 2734 Guilhem Bichot	2009-02-12 [merge]
      merge from latest 5.1-maria
      modified:
        configure.in
        dbug/dbug.c
        dbug/user.r
        unittest/mysys/waiting_threads-t.c

=== modified file 'configure.in'
--- a/configure.in	2009-02-12 14:08:56 +0000
+++ b/configure.in	2009-02-12 21:12:32 +0000
@@ -814,7 +814,7 @@ AC_HEADER_DIRENT
 AC_HEADER_STDC
 AC_HEADER_SYS_WAIT
 AC_CHECK_HEADERS(fcntl.h float.h floatingpoint.h ieeefp.h limits.h \
- memory.h pwd.h select.h \
+ memory.h pwd.h select.h fnmatch.h \
  stdlib.h stddef.h sys/stat.h \
  strings.h string.h synch.h sys/mman.h sys/socket.h netinet/in.h arpa/inet.h \
  sys/timeb.h sys/types.h sys/un.h sys/vadvise.h sys/wait.h term.h \

=== modified file 'dbug/dbug.c'
--- a/dbug/dbug.c	2009-02-12 14:08:56 +0000
+++ b/dbug/dbug.c	2009-02-12 21:12:32 +0000
@@ -75,7 +75,7 @@
  *        (the logic is - think of a call stack as of a path.
  *        "function" means only this function, "function/" means the hierarchy.
  *        in the future, filters like function1/function2 could be supported.
- *        wildcards are a natural extension too: * and ?)
+ *        following this logic glob(7) wildcards are supported.)
  *
  */
 
@@ -88,6 +88,13 @@
 #include <my_global.h>
 #include <m_string.h>
 #include <errno.h>
+
+#ifdef HAVE_FNMATCH_H
+#include <fnmatch.h>
+#else
+#define fnmatch(A,B,C) strcmp(A,B)
+#endif
+
 #if defined(MSDOS) || defined(__WIN__)
 #include <process.h>
 #endif
@@ -1547,7 +1554,7 @@ static int InList(struct link *linkp, co
 
   for (result=MATCHED; linkp != NULL; linkp= linkp->next_link)
   {
-    if (!strcmp(linkp->str, cp))
+    if (!fnmatch(linkp->str, cp, 0))
       return linkp->flags;
     if (!(linkp->flags & EXCLUDE))
       result=NOT_MATCHED;

=== modified file 'dbug/user.r'
--- a/dbug/user.r	2008-04-28 16:24:05 +0000
+++ b/dbug/user.r	2009-02-11 18:57:38 +0000
@@ -941,6 +941,9 @@ a complete log file in case of crashes. 
 multi-threaded environment.
 .LI d[,keywords]
 Enable output from macros with specified keywords.
+Every keyword can be a
+.I glob(7)
+pattern.
 An empty list of keywords implies that all keywords are selected.
 .LI D[,time]
 Delay for specified time after each output line, to let output drain.
@@ -948,6 +951,9 @@ Time is given in tenths of a second (val
 Default is zero.
 .LI f[,functions]
 Limit debugger actions to the specified list of functions.
+Every function can be a
+.I glob(7)
+pattern.
 An empty list of functions implies that all functions are selected.
 Every function in the list may optionally be followed by a '/' -
 this will implicitly select all the functions down the call stack.
@@ -966,6 +972,9 @@ Mark each debugger output line with the 
 current process.
 .LI g,[functions]
 Enable profiling for the specified list of functions.
+Every function can be a
+.I glob(7)
+pattern.
 An empty list of functions enables profiling for all functions.
 See
 .B PROFILING\ WITH\ DBUG
@@ -984,7 +993,11 @@ Like 'a[,file]' but overwrite old file, 
 .LI O[,file]
 Like 'A[,file]' but overwrite old file, do not append.
 .LI p[,processes]
-Limit debugger actions to the specified processes.  An empty list
+Limit debugger actions to the specified processes.
+Every name can be a
+.I glob(7)
+pattern.
+An empty list
 implies all processes.  This is useful for processes which run child
 processes.  Note that each debugger output line can be marked with the
 name of the current process via the 'P' flag.  The process name must

=== modified file 'unittest/mysys/waiting_threads-t.c'
--- a/unittest/mysys/waiting_threads-t.c	2009-01-19 15:27:49 +0000
+++ b/unittest/mysys/waiting_threads-t.c	2009-02-12 10:06:03 +0000
@@ -24,6 +24,7 @@ struct test_wt_thd {
 
 uint i, cnt;
 pthread_mutex_t lock;
+pthread_cond_t thread_sync;
 
 ulong wt_timeout_short=100, wt_deadlock_search_depth_short=4;
 ulong wt_timeout_long=10000, wt_deadlock_search_depth_long=15;
@@ -48,9 +49,19 @@ pthread_handler_t test_wt(void *arg)
 
   my_thread_init();
 
-  pthread_mutex_lock(&lock);
+  pthread_mutex_lock(&mutex);
   id= cnt++;
-  pthread_mutex_unlock(&lock);
+  wt_thd_lazy_init(& thds[id].thd,
+                   & wt_deadlock_search_depth_short, & wt_timeout_short,
+                   & wt_deadlock_search_depth_long, & wt_timeout_long);
+
+  /* now, wait for everybody to be ready to run */
+  if (cnt >= THREADS)
+    pthread_cond_broadcast(&thread_sync);
+  else
+    while (cnt < THREADS)
+      pthread_cond_wait(&thread_sync, &mutex);
+  pthread_mutex_unlock(&mutex);
 
   my_rnd_init(&rand, (ulong)(intptr)&m, id);
   if (kill_strategy == YOUNGEST)
@@ -111,23 +122,23 @@ retry:
       thds[id].thd.weight++;
   }
 
+  pthread_mutex_lock(&mutex);
+  /* wait for everybody to finish */
+  if (!--cnt)
+    pthread_cond_broadcast(&thread_sync);
+  else
+    while (cnt)
+      pthread_cond_wait(&thread_sync, &mutex);
+
   pthread_mutex_lock(& thds[id].lock);
   pthread_mutex_lock(&lock);
   wt_thd_release_all(& thds[id].thd);
   pthread_mutex_unlock(&lock);
   pthread_mutex_unlock(& thds[id].lock);
+  wt_thd_destroy(& thds[id].thd);
 
-#ifndef DBUG_OFF
-  {
-#define DEL "(deleted)"
-    char *x=malloc(strlen(thds[id].thd.name)+sizeof(DEL)+1);
-    strxmov(x, thds[id].thd.name, DEL, 0);
-    thds[id].thd.name=x;
-  }
-#endif
-
-  pthread_mutex_lock(&mutex);
-  if (!--running_threads) pthread_cond_signal(&cond);
+  if (!--running_threads) /* now, signal when everybody is done with deinit */
+    pthread_cond_signal(&cond);
   pthread_mutex_unlock(&mutex);
   DBUG_PRINT("wt", ("exiting"));
   my_thread_end();
@@ -137,6 +148,7 @@ retry:
 void do_one_test()
 {
   double sum, sum0;
+  DBUG_ENTER("do_one_test");
 
   reset(wt_cycle_stats);
   reset(wt_wait_stats);
@@ -162,10 +174,13 @@ void do_one_test()
            wt_wait_table[cnt], wt_wait_stats[cnt]);
   diag("timed out: %u", wt_wait_stats[cnt]);
   diag("successes: %u", wt_success_stats);
+
+  DBUG_VOID_RETURN;
 }
 
 void do_tests()
 {
+  DBUG_ENTER("do_tests");
   plan(14);
   compile_time_assert(THREADS >= 4);
 
@@ -174,19 +189,18 @@ void do_tests()
   bad= my_atomic_initialize();
   ok(!bad, "my_atomic_initialize() returned %d", bad);
 
+  pthread_cond_init(&thread_sync, 0);
   pthread_mutex_init(&lock, 0);
   wt_init();
   for (cnt=0; cnt < THREADS; cnt++)
-  {
-    wt_thd_lazy_init(& thds[cnt].thd,
-                     & wt_deadlock_search_depth_short, & wt_timeout_short,
-                     & wt_deadlock_search_depth_long, & wt_timeout_long);
     pthread_mutex_init(& thds[cnt].lock, 0);
-  }
   {
-    WT_RESOURCE_ID resid[3];
-    for (i=0; i < 3; i++)
+    WT_RESOURCE_ID resid[4];
+    for (i=0; i < array_elements(resid); i++)
     {
+      wt_thd_lazy_init(& thds[i].thd,
+                       & wt_deadlock_search_depth_short, & wt_timeout_short,
+                       & wt_deadlock_search_depth_long, & wt_timeout_long);
       resid[i].value= i+1;
       resid[i].type= &restype;
     }
@@ -220,15 +234,13 @@ void do_tests()
     wt_thd_release_all(& thds[1].thd);
     wt_thd_release_all(& thds[2].thd);
     wt_thd_release_all(& thds[3].thd);
-    pthread_mutex_unlock(&lock);
 
-    for (cnt=0; cnt < 4; cnt++)
+    for (i=0; i < array_elements(resid); i++)
     {
-      wt_thd_destroy(& thds[cnt].thd);
-      wt_thd_lazy_init(& thds[cnt].thd,
-                       & wt_deadlock_search_depth_short, & wt_timeout_short,
-                       & wt_deadlock_search_depth_long, & wt_timeout_long);
+      wt_thd_release_all(& thds[i].thd);
+      wt_thd_destroy(& thds[i].thd);
     }
+    pthread_mutex_unlock(&lock);
   }
 
   wt_deadlock_search_depth_short=6;
@@ -244,30 +256,23 @@ void do_tests()
 
 #define test_kill_strategy(X)                   \
   diag("kill strategy: " #X);                   \
+  DBUG_EXECUTE("reset_file",                    \
+               { rewind(DBUG_FILE); ftruncate(fileno(DBUG_FILE), 0); }); \
+  DBUG_PRINT("info", ("kill strategy: " #X));   \
   kill_strategy=X;                              \
   do_one_test();
 
   test_kill_strategy(LATEST);
-  SKIP_BIG_TESTS(1)
-  {
-    test_kill_strategy(RANDOM);
-  }
+  test_kill_strategy(RANDOM);
   test_kill_strategy(YOUNGEST);
   test_kill_strategy(LOCKS);
 
   DBUG_PRINT("wt", ("================= cleanup ==================="));
-  pthread_mutex_lock(&lock);
   for (cnt=0; cnt < THREADS; cnt++)
-  {
-    wt_thd_release_all(& thds[cnt].thd);
-    wt_thd_destroy(& thds[cnt].thd);
     pthread_mutex_destroy(& thds[cnt].lock);
-#ifndef DBUG_OFF
-    free(thds[cnt].thd.name);
-#endif
-  }
-  pthread_mutex_unlock(&lock);
   wt_end();
   pthread_mutex_destroy(&lock);
+  pthread_cond_destroy(&thread_sync);
+  DBUG_VOID_RETURN;
 }
 

Thread
bzr commit into MySQL/Maria:mysql-maria branch (guilhem:2734) Guilhem Bichot13 Feb