r24085 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r24084‎ | r24085 | r24086 >
Date:11:03, 14 July 2007
Author:river
Status:old
Tags:
Comment:
add -u flag: don't call fdatasync() on every write to the log position file
Modified paths:
  • /trunk/tools/trainwreck/trainwreck.c (modified) (history)

Diff [purge]

Index: trunk/tools/trainwreck/trainwreck.c
@@ -178,6 +178,8 @@
179179 static pthread_cond_t wi_cond = PTHREAD_COND_INITIALIZER;
180180 static logpos_t lowest_log_pos;
181181
 182+static int unsynced;
 183+
182184 #define CTL_STOP 1
183185 #define CTL_START 2
184186 #define CTL_SHUTDOWN 3
@@ -195,7 +197,7 @@
196198
197199 setup_status_door();
198200
199 - while ((c = getopt(argc, argv, "f:F:p:Da")) != -1) {
 201+ while ((c = getopt(argc, argv, "f:F:p:Dau")) != -1) {
200202 switch (c) {
201203 case 'a':
202204 autostart = 1;
@@ -217,6 +219,10 @@
218220 debug = 1;
219221 break;
220222
 223+ case 'u':
 224+ unsynced = 1;
 225+ break;
 226+
221227 default:
222228 usage();
223229 exit(1);
@@ -281,7 +287,7 @@
282288 usage()
283289 {
284290 (void) fprintf(stderr,
285 - "usage: trainwreck [-d] [-f <cfg>] [-F binlog] [-p binlogpos]\n");
 291+ "usage: trainwreck [-adu] [-f <cfg>] [-F binlog] [-p binlogpos]\n");
286292 }
287293
288294 static void
@@ -547,6 +553,9 @@
548554 exit(1);
549555 }
550556
 557+ if (debug)
 558+ logmsg("got binlog event");
 559+
551560 ent->le_file = strdup(curfile);
552561 curpos = ent->le_pos;
553562
@@ -1023,7 +1032,8 @@
10241033 int4store(buf, pos);
10251034 (void) strlcpy(buf + 4, log, sizeof(buf) - 4);
10261035 (void) write(writer->wr_rstat, buf, 4 + strlen(log));
1027 - (void) fdatasync(writer->wr_rstat);
 1036+ if (!unsynced)
 1037+ (void) fdatasync(writer->wr_rstat);
10281038 }
10291039
10301040 static int

Status & tagging log