summaryrefslogtreecommitdiff
path: root/sql/sql_repl.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sql_repl.cc')
-rw-r--r--sql/sql_repl.cc27
1 files changed, 15 insertions, 12 deletions
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc
index 1ee484b1bc1..011638afc93 100644
--- a/sql/sql_repl.cc
+++ b/sql/sql_repl.cc
@@ -121,7 +121,7 @@ void mysql_binlog_send(THD* thd, char* log_ident, ulong pos, ushort flags)
errmsg = "Could not find first log";
goto err;
}
- log = my_fopen(log_file_name, O_RDONLY, MYF(MY_WME));
+ log = my_fopen(log_file_name, O_RDONLY|O_BINARY, MYF(MY_WME));
if(!log)
{
@@ -143,14 +143,17 @@ void mysql_binlog_send(THD* thd, char* log_ident, ulong pos, ushort flags)
while(!net->error && net->vio != 0 && !thd->killed)
{
- while(!(error = Log_event::read_log_event(log, packet)))
+ pthread_mutex_t *log_lock = mysql_bin_log.get_log_lock();
+
+ while(!(error = Log_event::read_log_event(log, packet, log_lock)))
{
if(my_net_write(net, (char*)packet->ptr(), packet->length()) )
{
errmsg = "Failed on my_net_write()";
goto err;
}
- DBUG_PRINT("info", ("log event code %d",(*packet)[LOG_EVENT_OFFSET+1] ));
+ DBUG_PRINT("info", ("log event code %d",
+ (*packet)[LOG_EVENT_OFFSET+1] ));
if((*packet)[LOG_EVENT_OFFSET+1] == LOAD_EVENT)
{
if(send_file(thd))
@@ -168,7 +171,8 @@ void mysql_binlog_send(THD* thd, char* log_ident, ulong pos, ushort flags)
goto err;
}
- if(!(flags & BINLOG_DUMP_NON_BLOCK) && mysql_bin_log.is_active(log_file_name))
+ if(!(flags & BINLOG_DUMP_NON_BLOCK) &&
+ mysql_bin_log.is_active(log_file_name))
// block until there is more data in the log
// unless non-blocking mode requested
{
@@ -183,7 +187,6 @@ void mysql_binlog_send(THD* thd, char* log_ident, ulong pos, ushort flags)
// if we did not miss anything, we just wait for other threads
// to signal us
{
- pthread_mutex_t *log_lock = mysql_bin_log.get_log_lock();
clearerr(log);
// tell the kill thread how to wake us up
@@ -196,18 +199,19 @@ void mysql_binlog_send(THD* thd, char* log_ident, ulong pos, ushort flags)
bool read_packet = 0, fatal_error = 0;
- pthread_mutex_lock(log_lock); // no one will update the log while we are reading
+ // no one will update the log while we are reading
// now, but we'll be quick and just read one record
-
-
- switch(Log_event::read_log_event(log, packet))
+ switch(Log_event::read_log_event(log, packet, log_lock))
{
case 0:
- read_packet = 1; // we read successfully, so we'll need to send it to the
+ read_packet = 1;
+ // we read successfully, so we'll need to send it to the
// slave
break;
case LOG_READ_EOF:
+ pthread_mutex_lock(log_lock);
pthread_cond_wait(&COND_binlog_update, log_lock);
+ pthread_mutex_unlock(log_lock);
break;
default:
@@ -215,7 +219,6 @@ void mysql_binlog_send(THD* thd, char* log_ident, ulong pos, ushort flags)
break;
}
- pthread_mutex_unlock(log_lock);
pthread_mutex_lock(&thd->mysys_var->mutex);
thd->mysys_var->current_mutex= 0;
@@ -275,7 +278,7 @@ void mysql_binlog_send(THD* thd, char* log_ident, ulong pos, ushort flags)
break;
(void) my_fclose(log, MYF(MY_WME));
- log = my_fopen(log_file_name, O_RDONLY, MYF(MY_WME));
+ log = my_fopen(log_file_name, O_RDONLY|O_BINARY, MYF(MY_WME));
if(!log)
goto err;
// fake Rotate_log event just in case it did not make it to the log