r32311 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r32310‎ | r32311 | r32312 >
Date:23:26, 21 March 2008
Author:river
Status:old
Tags:
Comment:
- incorrect realloc() in do_ignore_errno corrupts heap
- failure to open logpos is not a fatal error
Modified paths:
  • /trunk/tools/trainwreck/Makefile (modified) (history)
  • /trunk/tools/trainwreck/trainwreck.c (modified) (history)

Diff [purge]

Index: trunk/tools/trainwreck/trainwreck.c
@@ -459,9 +459,8 @@
460460 {
461461 set_thread_name("reader");
462462
463 - logmsg("waiting for writers to become ready...");
464 -
465463 (void) pthread_mutex_lock(&wi_mtx);
 464+ logmsg("waiting for %d writers to become ready...", writers_initialising);
466465 while (writers_initialising > 0)
467466 (void) pthread_cond_wait(&wi_cond, &wi_mtx);
468467 (void) pthread_mutex_unlock(&wi_mtx);
@@ -881,7 +880,6 @@
882881
883882 writers_initialising = nwriters;
884883 (void) pthread_mutex_unlock(&wst_mtx);
885 -
886884
887885 for (i = 0; i < nwriters; ++i) {
888886 (void) pthread_create(&writers[i].wr_thread, NULL, slave_write_thread, &writers[i]);
@@ -926,8 +924,8 @@
927925 }
928926
929927 if (retrieve_binlog_position(self) != 0) {
930 - logmsg("could not retrieve binlog position");
931 - return 0;
 928+ logmsg("could not retrieve binlog position; trying to continue anyway");
 929+ /*return 0;*/
932930 }
933931
934932 (void) pthread_mutex_lock(&wi_mtx);
@@ -1032,7 +1030,7 @@
10331031 do_ignore_errno(n)
10341032 unsigned n;
10351033 {
1036 - ignorable_errno = realloc(ignorable_errno, nignorable + 1);
 1034+ ignorable_errno = realloc(ignorable_errno, sizeof(int) * (nignorable + 1));
10371035 ignorable_errno[nignorable] = n;
10381036 nignorable++;
10391037 }
@@ -1115,6 +1113,7 @@
11161114 writer_t *writer;
11171115 {
11181116 int rstat;
 1117+ssize_t n;
11191118 struct stat st;
11201119 char *buf;
11211120 char sname[128];
@@ -1143,7 +1142,7 @@
11441143 }
11451144
11461145 buf = calloc(1, st.st_size + 1);
1147 - if (read(rstat, buf, st.st_size) != st.st_size) {
 1146+ if ((n = read(rstat, buf, st.st_size)) != st.st_size) {
11481147 logmsg("short read on state file \"%s\": %s",
11491148 sname, strerror(errno));
11501149 exit(1);
Index: trunk/tools/trainwreck/Makefile
@@ -1,9 +1,13 @@
2 -CC = gcc
3 -#CFLAGS = -g -mt -m64 -xc99=none
4 -CFLAGS = -g -D_REENTRANT -m64
 2+#CC = gcc
 3+CC = cc
 4+CFLAGS = -g -mt -xc99=none -D_FILE_OFFSET_BITS=64
 5+#CFLAGS = -g -D_REENTRANT -m64 -DBIG_TABLES -DHAVE_RWLOCK_T
 6+#CFLAGS = -g -D_REENTRANT -D_FILE_OFFSET_BITS=64
57 LDFLAGS =
68 MYSQL_CFLAGS:sh = mysql_config --include
7 -MYSQL_LIBS:sh = mysql_config --libs_r
 9+#MYSQL_LIBS:sh = mysql_config --libs_r
 10+#MYSQL_LIBS = -L/usr/local/mysql/lib/mysql -R/usr/local/mysql/lib/mysql -lmysqlclient
 11+MYSQL_LIBS = -L/opt/mysql/lib/mysql -R/opt/mysql/lib/mysql -lmysqlclient
812 INCLUDES =
913 LIBS = -lrt -ldoor
1014 PROG = trainwreck

Status & tagging log