List:Internals« Previous MessageNext Message »
From:sasha Date:July 12 2001 2:59am
Subject:bk commit into 4.0 tree
View as plain text  
Below is the list of changes that have just been committed into a
4.0 repository of sasha. When sasha does a push, they will be propogated 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://www.mysql.com/doc/I/n/Installing_source_tree.html

ChangeSet@stripped, 2001-07-11 20:59:17-06:00, sasha@stripped
  fixed uninitialized use of variable in mysqltest
  fixed race condition in binary log auto-rotation
  get rid of extention in binary log to avoid non-rotatable logs

  sql/log.cc
    1.62 01/07/11 20:59:16 sasha@stripped +11 -10
    fixed race condition on binary log auto-rotate

  sql/mysqld.cc
    1.189 01/07/11 20:59:16 sasha@stripped +7 -0
    get rid of extention on binary log

  sql/sql_class.h
    1.81 01/07/11 20:59:16 sasha@stripped +1 -1
    argument to new file (inside_mutex)

  client/mysqltest.c
    1.48 01/07/11 20:59:15 sasha@stripped +16 -10
    fixed uninitialized use of variable bug

# 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:	sasha
# Host:	mysql.sashanet.com
# Root:	/home/sasha/src/bk/mysql-4.0

--- 1.61/sql/log.cc	Sat Jun 23 19:37:23 2001
+++ 1.62/sql/log.cc	Wed Jul 11 20:59:16 2001
@@ -514,17 +514,19 @@
   return inited && !strcmp(log_file_name, this->log_file_name);
 }
 
-void MYSQL_LOG::new_file()
+void MYSQL_LOG::new_file(bool inside_mutex)
 {
   // only rotate open logs that are marked non-rotatable
   // (binlog with constant name are non-rotatable)
   if (is_open() && ! no_rotate)
   {
     char new_name[FN_REFLEN], *old_name=name;
-    VOID(pthread_mutex_lock(&LOCK_log));
+    if (!inside_mutex)
+      VOID(pthread_mutex_lock(&LOCK_log));
     if (generate_new_name(new_name, name))
     {
-      VOID(pthread_mutex_unlock(&LOCK_log));
+      if (!inside_mutex)
+        VOID(pthread_mutex_unlock(&LOCK_log));
       return;					// Something went wrong
     }
     if (log_type == LOG_BIN)
@@ -551,7 +553,8 @@
     my_free(old_name,MYF(0));
     last_time=query_start=0;
     write_error=0;
-    VOID(pthread_mutex_unlock(&LOCK_log));
+    if (!inside_mutex)
+      VOID(pthread_mutex_unlock(&LOCK_log));
   }
 }
 
@@ -729,9 +732,9 @@
     if (file == &log_file)
       VOID(pthread_cond_broadcast(&COND_binlog_update));
   }
-  VOID(pthread_mutex_unlock(&LOCK_log));
   if(should_rotate)
-    new_file();
+    new_file(1); // inside mutex
+  VOID(pthread_mutex_unlock(&LOCK_log));
   return error;
 }
 
@@ -817,12 +820,10 @@
 	VOID(pthread_cond_broadcast(&COND_binlog_update));
       }
     }
+    if(should_rotate)
+      new_file(1); // inside mutex
     VOID(pthread_mutex_unlock(&LOCK_log));
   }
-
-  if(should_rotate)
-    new_file();
-  
   return error;
 }
 

--- 1.188/sql/mysqld.cc	Fri Jul  6 19:07:29 2001
+++ 1.189/sql/mysqld.cc	Wed Jul 11 20:59:16 2001
@@ -1498,6 +1498,13 @@
     strmov(strcend(tmp,'.'),extension);
     opt_name=tmp;
   }
+  // get rid of extention if the log is binary to avoid problems
+  if (type == LOG_BIN)
+  {
+    char* p = strrchr(opt_name, FN_EXTCHAR);
+    if (p)
+      *p = 0;
+  } 
   log->open(opt_name,type);
 }
 

--- 1.80/sql/sql_class.h	Tue Jul 10 06:52:35 2001
+++ 1.81/sql/sql_class.h	Wed Jul 11 20:59:16 2001
@@ -80,7 +80,7 @@
   void init(enum_log_type log_type_arg);
   void open(const char *log_name,enum_log_type log_type,
 	    const char *new_name=0);
-  void new_file(void);
+  void new_file(bool inside_mutex=0);
   bool open_index(int options);
   void close_index();
   bool write(THD *thd, enum enum_server_command command,const char *format,...);

--- 1.47/client/mysqltest.c	Sat Jun 30 13:08:33 2001
+++ 1.48/client/mysqltest.c	Wed Jul 11 20:59:15 2001
@@ -207,7 +207,7 @@
 static void init_var_hash();
 static byte* get_var_key(const byte* rec, uint* len,
 			 my_bool __attribute__((unused)) t);
-static VAR* var_init(const char* name, int name_len, const char* val,
+static VAR* var_init(VAR* v, const char* name, int name_len, const char* val,
 		     int val_len);
 
 static void var_free(void* v);
@@ -529,7 +529,7 @@
   VAR* v;
   if((v = (VAR*)hash_search(&var_hash, name, len)))
     return v;
-  v = var_init(name, len, "", 0);
+  v = var_init(0, name, len, "", 0);
   hash_insert(&var_hash, (byte*)v);
   return v;
 }
@@ -678,6 +678,7 @@
 {
   char* p=q->first_argument;
   VAR v;
+  var_init(&v, 0, 0, 0, 0);
   eval_expr(&v, p, 0); /* NULL terminated */
   if (v.str_val_len)
     {
@@ -697,6 +698,7 @@
 {
   char* p=q->first_argument;
   VAR v;
+  var_init(&v,0,0,0,0);
   eval_expr(&v, p, 0); /* NULL terminated */
   if (v.str_val_len)
   {
@@ -1172,6 +1174,7 @@
   char* p=q->first_argument;
   const char* expr_start, *expr_end;
   VAR v;
+  var_init(&v,0,0,0,0);
   if (cur_block == block_stack_end)
 	die("Nesting too deeply");
   if (!*block_ok)
@@ -1837,29 +1840,32 @@
   return (byte*)key;
 }
 
-static VAR* var_init(const char* name, int name_len, const char* val,
+static VAR* var_init(VAR* v, const char* name, int name_len, const char* val,
 		     int val_len)
 {
   int val_alloc_len;
   VAR* tmp_var;
-  if(!name_len)
+  if(!name_len && name)
     name_len = strlen(name);
-  if(!val_len)
+  if(!val_len && val)
     val_len = strlen(val) ;
   val_alloc_len = val_len + 16; /* room to grow */
-  if(!(tmp_var = (VAR*)my_malloc(sizeof(*tmp_var) 
+  if(!(tmp_var=v) && !(tmp_var = (VAR*)my_malloc(sizeof(*tmp_var) 
 				 + name_len, MYF(MY_WME))))
     die("Out of memory");
-  tmp_var->name = (char*)tmp_var + sizeof(*tmp_var);
+  
+  tmp_var->name = (name) ? (char*)tmp_var + sizeof(*tmp_var) : 0;
+
   if(!(tmp_var->str_val = my_malloc(val_alloc_len, MYF(MY_WME))))
     die("Out of memory");
   
   memcpy(tmp_var->name, name, name_len);
-  memcpy(tmp_var->str_val, val, val_len + 1);
+  if(val)
+    memcpy(tmp_var->str_val, val, val_len + 1);
   tmp_var->name_len = name_len;
   tmp_var->str_val_len = val_len;
   tmp_var->alloced_len = val_alloc_len;
-  tmp_var->int_val = atoi(val);
+  tmp_var->int_val = (val) ? atoi(val) : 0;
   tmp_var->int_dirty = 0;
   return tmp_var;
 }
@@ -1878,7 +1884,7 @@
   if(!(tmp = getenv(name)))
     tmp = def_val;
     
-  v = var_init(name, 0, tmp, 0); 
+  v = var_init(0, name, 0, tmp, 0); 
   hash_insert(&var_hash, (byte*)v);
 }
 
Thread
bk commit into 4.0 treesasha12 Jul