From bc059e42c3ae50e467603c17b761d05539fecfbe Mon Sep 17 00:00:00 2001
From: unknown <sasha@mysql.sashanet.com>
Date: Tue, 10 Jul 2001 20:35:42 -0600
Subject: [PATCH] mysql-test/t/rpl_sporadic_master.test     use truncate table
 sql/slave.cc     fixed race condition on server shutdown sql/sql_repl.cc    
 fixed uninitialized use of io_cache

mysql-test/t/rpl_sporadic_master.test:
  use truncate table
sql/slave.cc:
  fixed race condition on server shutdown
sql/sql_repl.cc:
  fixed uninitialized use of io_cache
---
 mysql-test/t/rpl_sporadic_master.test | 9 ++-------
 sql/slave.cc                          | 5 +++++
 sql/sql_repl.cc                       | 2 +-
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/mysql-test/t/rpl_sporadic_master.test b/mysql-test/t/rpl_sporadic_master.test
index 80d99de650..b22a95612b 100644
--- a/mysql-test/t/rpl_sporadic_master.test
+++ b/mysql-test/t/rpl_sporadic_master.test
@@ -5,18 +5,13 @@ connection master;
 drop table if exists t1;
 create table t1(n int not null auto_increment primary key);
 insert into t1 values (NULL),(NULL);
-delete from t1;
-set insert_id=1;
+truncate table t1;
 insert into t1 values (NULL),(NULL);
-set insert_id=3;
 insert into t1 values (NULL),(NULL);
 flush logs;
-delete from t1;
-set insert_id=1;
+truncate table t1;
 insert into t1 values (NULL),(NULL);
-set insert_id=3;
 insert into t1 values (NULL),(NULL);
-set insert_id=5;
 insert into t1 values (NULL),(NULL);
 save_master_pos;
 connection slave;
diff --git a/sql/slave.cc b/sql/slave.cc
index 92c6c8b2b2..cafa6ffdb0 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -190,6 +190,11 @@ static void free_string_array(DYNAMIC_ARRAY *a)
 
 void end_slave()
 {
+  pthread_mutex_lock(&LOCK_slave);
+  while (slave_running)
+    pthread_cond_wait(&COND_slave_stopped, &LOCK_slave);
+  pthread_mutex_unlock(&LOCK_slave);
+  
   end_master_info(&glob_mi);
   if(do_table_inited)
     hash_free(&replicate_do_table);
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc
index 4841da1b0a..9c1fbbe4ac 100644
--- a/sql/sql_repl.cc
+++ b/sql/sql_repl.cc
@@ -350,6 +350,7 @@ void mysql_binlog_send(THD* thd, char* log_ident, ulong pos, ushort flags)
   int left_events = max_binlog_dump_events;
 #endif
   DBUG_ENTER("mysql_binlog_send");
+  bzero((char*) &log,sizeof(log));
 
 #ifndef DBUG_OFF
   if (opt_sporadic_binlog_dump_fail && (binlog_dump_count++ % 2))
@@ -359,7 +360,6 @@ void mysql_binlog_send(THD* thd, char* log_ident, ulong pos, ushort flags)
   }
 #endif
 
-  bzero((char*) &log,sizeof(log));
 
   if (!mysql_bin_log.is_open())
   {
-- 
2.30.9