summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <nick@mysql.com>2002-10-07 16:39:52 -0600
committerunknown <nick@mysql.com>2002-10-07 16:39:52 -0600
commita1517908c1efa396ab01e8ab2c212ed8d75cd8d5 (patch)
tree7cfc8ac2ad7c6c9e397df0b333a8b7c8007e22c8 /sql
parent2ab04c8ceed83350682a8cac2e2415c677f18ca2 (diff)
downloadmariadb-git-a1517908c1efa396ab01e8ab2c212ed8d75cd8d5.tar.gz
touchup to last fix
sql/log.cc: moved mutex back to after is_open() test, but still protecting name dereference (the real problem)
Diffstat (limited to 'sql')
-rw-r--r--sql/log.cc66
1 files changed, 34 insertions, 32 deletions
diff --git a/sql/log.cc b/sql/log.cc
index e3f85c8def5..33c7414644a 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -513,44 +513,46 @@ bool MYSQL_LOG::is_active(const char* log_file_name)
void MYSQL_LOG::new_file(bool inside_mutex)
{
+ if (!is_open())
+ return;
+
if (!inside_mutex)
VOID(pthread_mutex_lock(&LOCK_log));
- if (is_open())
- {
- char new_name[FN_REFLEN], *old_name=name;
+
+ char new_name[FN_REFLEN], *old_name = name;
- if (!no_rotate)
+ if (!no_rotate)
+ {
+ /*
+ only rotate open logs that are marked non-rotatable
+ (binlog with constant name are non-rotatable)
+ */
+ if (generate_new_name(new_name, name))
+ {
+ if (!inside_mutex)
+ VOID(pthread_mutex_unlock(&LOCK_log));
+ return; // Something went wrong
+ }
+ if (log_type == LOG_BIN)
{
/*
- only rotate open logs that are marked non-rotatable
- (binlog with constant name are non-rotatable)
+ We log the whole file name for log file as the user may decide
+ to change base names at some point.
*/
- if (generate_new_name(new_name, name))
- {
- if (!inside_mutex)
- VOID(pthread_mutex_unlock(&LOCK_log));
- return; // Something went wrong
- }
- if (log_type == LOG_BIN)
- {
- /*
- We log the whole file name for log file as the user may decide
- to change base names at some point.
- */
- Rotate_log_event r(new_name+dirname_length(new_name));
- r.write(&log_file);
- VOID(pthread_cond_broadcast(&COND_binlog_update));
- }
+ Rotate_log_event r(new_name+dirname_length(new_name));
+ r.write(&log_file);
+ VOID(pthread_cond_broadcast(&COND_binlog_update));
}
- else
- strmov(new_name, old_name); // Reopen old file name
- name=0;
- close();
- open(old_name, log_type, new_name);
- my_free(old_name,MYF(0));
- last_time=query_start=0;
- write_error=0;
}
+ else
+ strmov(new_name, old_name); // Reopen old file name
+ name=0;
+ close();
+ open(old_name, log_type, new_name);
+ my_free(old_name,MYF(0));
+ last_time=query_start=0;
+ write_error=0;
+
if (!inside_mutex)
VOID(pthread_mutex_unlock(&LOCK_log));
}
@@ -564,8 +566,8 @@ bool MYSQL_LOG::write(THD *thd,enum enum_server_command command,
int error=0;
VOID(pthread_mutex_lock(&LOCK_log));
- /* Test if someone closed after the is_open test */
- if (log_type != LOG_CLOSED)
+ /* Test if someone closed between the is_open test and lock */
+ if (is_open())
{
time_t skr;
ulong id;