summaryrefslogtreecommitdiff
path: root/sql/log.cc
diff options
context:
space:
mode:
authorunknown <monty@mashka.mysql.fi>2002-06-11 11:20:31 +0300
committerunknown <monty@mashka.mysql.fi>2002-06-11 11:20:31 +0300
commit70aa7424c41c45a8fb171bbdd9e24d74b70a7765 (patch)
tree8fcaabe013fff43cf466235067f2c47f0cd66531 /sql/log.cc
parent30d5eb22877d0546fb4bd93ead7e8602285d449b (diff)
downloadmariadb-git-70aa7424c41c45a8fb171bbdd9e24d74b70a7765.tar.gz
Big code cleanup/review before 4.0.2 release.
(All commit emails since 4.0.1 checked) This had to be done now, before the 4.1 tree changes to much, to make it easy to propagate bug fixes to the 4.1 tree. BUILD/SETUP.sh: Added -DPEDANTIC_SAFEMALLOC as standard debug option Docs/manual.texi: Changes for new version. client/mysql.cc: Fixed default value for rehash cleanup client/mysqladmin.c: Cleanup client/mysqlbinlog.cc: cleanup client/mysqldump.c: Cleanup client/mysqlmanager-pwgen.c: Cleanup client/mysqlmanagerc.c: Cleanup client/mysqltest.c: Cleanup dbug/dbug.c: Cleanup extra/resolve_stack_dump.c: Cleanup & Simple optimizations include/ft_global.h: Cleanup include/my_alloc.h: Cleanup include/my_global.h: Cleanup include/my_sys.h: Cleanup include/myisam.h: Cleanup libmysql/libmysql.c: Cleanup libmysql/manager.c: Cleanup myisam/ft_boolean_search.c: Cleanup myisam/ft_dump.c: Change strcpy -> strmov myisam/ft_eval.c: Cleanup myisam/ft_nlq_search.c: Cleanup myisam/ft_test1.c: strncpy -> strnmov myisam/ft_update.c: Cleanup myisam/mi_static.c: Cleanup myisam/mi_test2.c: Cleanup myisam/mi_write.c: Cleanup mysys/mf_fn_ext.c: Cleanup mysys/mf_iocache.c: Cleanup mysys/mf_iocache2.c: Cleanup mysys/my_getopt.c: Cleanup mysys/my_read.c: Cleanup mysys/my_thr_init.c: Cleanup mysys/queues.c: Cleanup mysys/safemalloc.c: Cleanup sql/field.cc: Indentation cleanups sql/ha_berkeley.cc: Indentation cleanups sql/ha_myisam.cc: Cleanup sql/item.h: Indentation cleanups sql/item_cmpfunc.cc: Indentation cleanups sql/item_create.cc: cleanup sql/item_func.cc: Cleanup sql/item_func.h: Indentation cleanups sql/item_strfunc.cc: Indentation cleanups sql/item_sum.cc: Indentation cleanups sql/item_timefunc.cc: Indentation cleanups sql/lock.cc: Indentation cleanups sql/log.cc: Cleanup strnmov -> strmake sql/log_event.cc: Cleanup + optimizations Fixed memory leak Added missing pthread_mutex_unlock() (On error condition) sql/log_event.h: Indentation and comment cleanup Merged #ifdef's into common blocks for better readability sql/mini_client.cc: Indentation cleanup sql/mysql_priv.h: Cleanup Changed int function to bool sql/mysqld.cc: Indentation and comment cleanup sql/net_pkg.cc: Indentation cleanup sql/net_serv.cc: Changed int function -> bool sql/nt_servc.cc: Cleanup sql/opt_range.cc: Indentation cleanup sql/repl_failsafe.cc: Cleanup + simple optimization strnmov -> strmake sql/slave.cc: strnmov -> strmake Cleanups sql/slave.h: Cleanup sql/sql_acl.cc: Indentation and DBUG_PRINT cleanup Changed WITH MAX... to not use = sql/sql_base.cc: Indentation cleanup sql/sql_cache.cc: Indentation cleanup sql/sql_class.cc: Indentation cleanup sql/sql_class.h: Renamed some struct slots sql/sql_delete.cc: Indentation cleanup sql/sql_handler.cc: Indentation cleanup sql/sql_insert.cc: Use new slot names. sql/sql_lex.cc: Indentation cleanup sql/sql_lex.h: Indentation cleanup sql/sql_load.cc: Indentation cleanup sql/sql_parse.cc: Indentation cleanup Removed not used check from LOCK TABLES sql/sql_repl.cc: strnmov -> strmake sql/sql_repl.h: Removed test if file is included (We want to know if it's included twice to avoid this) sql/sql_select.cc: Indentation cleanup sql/sql_show.cc: Indentation cleanup sql/sql_string.cc: Indentation cleanup sql/sql_table.cc: Indentation cleanup sql/sql_union.cc: Use renamed struct slot sql/sql_update.cc: Indentation cleanup sql/sql_yacc.yy: Removed = after GRANT ... MAX_ to make the syntax uniform sql/table.cc: Indentation cleanup sql/table.h: Indentation cleanup sql/time.cc: Indentation cleanup sql/udf_example.cc: Indentation cleanup sql/unireg.cc: strnmov -> strmake tests/grant.pl: Added test for LOCK TABLES tools/mysqlmanager.c: Cleanup fopen() -> my_fopen() vio/viosocket.c: DBUG_PRINT cleanups vio/viosslfactories.c: Indentation cleanup Checking of results from malloc() Fixed possible memory leak BitKeeper/etc/ignore: Added scripts/mysql_secure_installation to the ignore list BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted
Diffstat (limited to 'sql/log.cc')
-rw-r--r--sql/log.cc52
1 files changed, 34 insertions, 18 deletions
diff --git a/sql/log.cc b/sql/log.cc
index 0f8c4a8c4a8..793dfaf6d82 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -384,6 +384,7 @@ int MYSQL_LOG::reset_logs(THD* thd)
int error=0;
const char* save_name;
enum_log_type save_log_type;
+
pthread_mutex_lock(&LOCK_log);
if (find_first_log(&linfo,""))
{
@@ -406,6 +407,7 @@ int MYSQL_LOG::reset_logs(THD* thd)
need_start_event=1;
open(save_name,save_log_type,0,io_cache_type,no_auto_events);
my_free((gptr)save_name,MYF(0));
+
err:
pthread_mutex_unlock(&LOCK_log);
return error;
@@ -414,17 +416,19 @@ err:
int MYSQL_LOG::purge_first_log(struct st_relay_log_info* rli)
{
- // pre-conditions
- DBUG_ASSERT(is_open());
- DBUG_ASSERT(index_file >= 0);
- DBUG_ASSERT(rli->slave_running == 1);
- DBUG_ASSERT(!strcmp(rli->linfo.log_file_name,rli->relay_log_name));
/*
+ Test pre-conditions.
+
Assume that we have previously read the first log and
stored it in rli->relay_log_name
*/
+ DBUG_ASSERT(is_open());
+ DBUG_ASSERT(index_file >= 0);
+ DBUG_ASSERT(rli->slave_running == 1);
+ DBUG_ASSERT(!strcmp(rli->linfo.log_file_name,rli->relay_log_name));
DBUG_ASSERT(rli->linfo.index_file_offset ==
strlen(rli->relay_log_name) + 1);
+
int tmp_fd;
char* fname, *io_buf;
int error = 0;
@@ -486,9 +490,11 @@ err:
pthread_mutex_lock(&rli->log_space_lock);
rli->log_space_total -= s.st_size;
pthread_mutex_unlock(&rli->log_space_lock);
- // ok to broadcast after the critical region as there is no risk of
- // the mutex being destroyed by this thread later - this helps save
- // context switches
+ /*
+ Ok to broadcast after the critical region as there is no risk of
+ the mutex being destroyed by this thread later - this helps save
+ context switches
+ */
pthread_cond_broadcast(&rli->log_space_cond);
if ((error=find_first_log(&rli->linfo,"",0/*no mutex*/)))
@@ -500,8 +506,8 @@ err:
goto err2;
}
rli->relay_log_pos = BIN_LOG_HEADER_SIZE;
- strnmov(rli->relay_log_name,rli->linfo.log_file_name,
- sizeof(rli->relay_log_name));
+ strmake(rli->relay_log_name,rli->linfo.log_file_name,
+ sizeof(rli->relay_log_name)-1);
flush_relay_log_info(rli);
}
/*
@@ -689,7 +695,7 @@ void MYSQL_LOG::new_file(bool inside_mutex)
if (!no_rotate)
{
/*
- only rotate open logs that are marked non-rotatable
+ Only rotate open logs that are marked non-rotatable
(binlog with constant name are non-rotatable)
*/
if (generate_new_name(new_name, name))
@@ -720,9 +726,11 @@ void MYSQL_LOG::new_file(bool inside_mutex)
r.write(&log_file);
bytes_written += r.get_event_len();
}
- // update needs to be signaled even if there is no rotate event
- // log rotation should give the waiting thread a signal to
- // discover EOF and move on to the next log
+ /*
+ Update needs to be signaled even if there is no rotate event
+ log rotation should give the waiting thread a signal to
+ discover EOF and move on to the next log.
+ */
signal_update();
}
else
@@ -745,8 +753,10 @@ bool MYSQL_LOG::append(Log_event* ev)
pthread_mutex_lock(&LOCK_log);
DBUG_ASSERT(log_file.type == SEQ_READ_APPEND);
- // Log_event::write() is smart enough to use my_b_write() or
- // my_b_append() depending on the kind of cache we have
+ /*
+ Log_event::write() is smart enough to use my_b_write() or
+ my_b_append() depending on the kind of cache we have.
+ */
if (ev->write(&log_file))
{
error=1;
@@ -758,11 +768,13 @@ bool MYSQL_LOG::append(Log_event* ev)
new_file(1);
}
signal_update();
+
err:
pthread_mutex_unlock(&LOCK_log);
return error;
}
+
bool MYSQL_LOG::appendv(const char* buf, uint len,...)
{
bool error = 0;
@@ -1232,8 +1244,12 @@ void MYSQL_LOG::close(bool exiting)
}
- /* Check if a string is a valid number */
- /* Output: TRUE -> number */
+/*
+ Check if a string is a valid number
+ Return:
+ TRUE String is a number
+ FALSE Error
+*/
static bool test_if_number(register const char *str,
long *res, bool allow_wildcards)