Commit 1581aae5 authored by unknown's avatar unknown

I hope I've fixed all the bugs by now, let's test it


sql/log_event.h:
  changed new/delete for Log_event to use my_malloc/my_free
sql/mysql_priv.h:
  wait for slave to get going
sql/mysqld.cc:
  wait for slave to get going in SLAVE START
sql/slave.cc:
  fixed more memory leaks
sql/sql_repl.cc:
  file name was not being \0 terminated in send_file
parent 72e03410
......@@ -65,6 +65,16 @@ class Log_event
int valid_exec_time; // if false, the exec time setting is bogus
uint32 server_id;
static void *operator new(size_t size)
{
return (void*) my_malloc((uint)size, MYF(MY_WME|MY_FAE));
}
static void operator delete(void *ptr, size_t size)
{
my_free((byte*)ptr, MYF(MY_WME|MY_ALLOW_ZERO_PTR));
}
int write(IO_CACHE* file);
int write_header(IO_CACHE* file);
virtual int write_data(IO_CACHE* file __attribute__((unused))) { return 0; }
......
......@@ -486,7 +486,7 @@ extern pthread_mutex_t LOCK_mysql_create_db,LOCK_Acl,LOCK_open,
LOCK_delayed_status, LOCK_delayed_create, LOCK_crypt, LOCK_timezone,
LOCK_binlog_update, LOCK_slave, LOCK_server_id;
extern pthread_cond_t COND_refresh,COND_thread_count, COND_binlog_update,
COND_slave_stopped;
COND_slave_stopped, COND_slave_start;
extern pthread_attr_t connection_attrib;
extern bool opt_endinfo,using_udf_functions, locked_in_memory;
extern ulong ha_read_count, ha_write_count, ha_delete_count, ha_update_count,
......
......@@ -263,7 +263,7 @@ pthread_mutex_t LOCK_mysql_create_db, LOCK_Acl, LOCK_open, LOCK_thread_count,
LOCK_binlog_update, LOCK_slave, LOCK_server_id;
pthread_cond_t COND_refresh,COND_thread_count,COND_binlog_update,
COND_slave_stopped;
COND_slave_stopped, COND_slave_start;
pthread_cond_t COND_thread_cache,COND_flush_thread_cache;
pthread_t signal_thread;
pthread_attr_t connection_attrib;
......@@ -1414,6 +1414,7 @@ int main(int argc, char **argv)
(void) pthread_mutex_init(&LOCK_server_id, NULL);
(void) pthread_cond_init(&COND_binlog_update, NULL);
(void) pthread_cond_init(&COND_slave_stopped, NULL);
(void) pthread_cond_init(&COND_slave_start, NULL);
if (set_default_charset_by_name(default_charset, MYF(MY_WME)))
unireg_abort(1);
......
......@@ -938,8 +938,8 @@ static int exec_event(THD* thd, NET* net, MASTER_INFO* mi, int event_len)
return 1;
}
free_root(&thd->mem_root,0);
delete ev;
free_root(&thd->mem_root,0);
if(thd->fatal_error)
{
......@@ -957,12 +957,14 @@ static int exec_event(THD* thd, NET* net, MASTER_INFO* mi, int event_len)
close_temporary_tables(thd);
mi->inc_pos(event_len);
flush_master_info(mi);
delete ev;
break;
case STOP_EVENT:
close_temporary_tables(thd);
mi->inc_pos(event_len);
flush_master_info(mi);
delete ev;
break;
case ROTATE_EVENT:
{
......@@ -1013,15 +1015,18 @@ pthread_handler_decl(handle_slave,arg __attribute__((unused)))
THD *thd; // needs to be first for thread_stack
MYSQL *mysql = NULL ;
pthread_mutex_lock(&LOCK_slave);
if(!server_id)
{
pthread_cond_broadcast(&COND_slave_start);
pthread_mutex_unlock(&LOCK_slave);
sql_print_error("Server id not set, will not start slave");
pthread_exit((void*)1);
}
pthread_mutex_lock(&LOCK_slave);
if(slave_running)
{
pthread_cond_broadcast(&COND_slave_start);
pthread_mutex_unlock(&LOCK_slave);
pthread_exit((void*)1); // safety just in case
}
......@@ -1030,7 +1035,8 @@ pthread_handler_decl(handle_slave,arg __attribute__((unused)))
#ifndef DBUG_OFF
events_till_abort = abort_slave_event_count;
#endif
pthread_mutex_unlock(&LOCK_slave);
pthread_cond_broadcast(&COND_slave_start);
pthread_mutex_unlock(&LOCK_slave);
int error = 1;
bool retried_once = 0;
......
......@@ -34,7 +34,7 @@ static int send_file(THD *thd)
char fname[FN_REFLEN+1];
char *buf;
const char *errmsg = 0;
int old_timeout;
int old_timeout,fname_len;
DBUG_ENTER("send_file");
// the client might be slow loading the data, give him wait_timeout to do
......@@ -51,12 +51,14 @@ static int send_file(THD *thd)
// we need net_flush here because the client will not know it needs to send
// us the file name until it has processed the load event entry
if (net_flush(net) || my_net_read(net) == packet_error)
if (net_flush(net) || (fname_len = my_net_read(net)) == packet_error)
{
errmsg = "Failed reading file name";
goto err;
}
*((char*)net->read_pos + 1 + fname_len) = 0; // terminate with \0
//for fn_format
fn_format(fname, (char*)net->read_pos + 1, "", "", 4);
// this is needed to make replicate-ignore-db
if (!strcmp(fname,"/dev/null"))
......@@ -513,6 +515,7 @@ int start_slave(THD* thd , bool net_report)
{
err = "cannot create slave thread";
}
pthread_cond_wait(&COND_slave_start, &LOCK_slave);
}
else
err = "Master host not set, or server id not configured";
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment