From f7a6407ab1213d95f074e47c39061f541f630944 Mon Sep 17 00:00:00 2001 From: Robin Sommer Date: Thu, 12 Jul 2012 13:44:24 -0700 Subject: [PATCH] Reworking thread termination logic. Turns out the finish methods weren't called correctly, caused by a mess up with method names which all sounded too similar and the wrong one ended up being called. I've reworked this by changing the thread/writer/reader interfaces, which actually also simplifies them by getting rid of the requirement for writer backends to call their parent methods (i.e., less opportunity for errors). This commit also includes the following (because I noticed the problem above when working on some of these): - The ASCII log writer now includes "#start " and "#end lines in the each file. The latter supersedes Bernhard's "EOF" patch. This required a number of tests updates. The standard canonifier removes the timestamps, but some tests compare files directly, which doesn't work if they aren't printing out the same timestamps (like the comm tests). - The above required yet another change to the writer API to network_time to methods. - Renamed ASCII logger "header" options to "meta". - Fixes #763 "Escape # when first character in log file line". All btests pass for me on Linux FC15. Will try MacOS next. --- src/logging/writers/Ascii.cc | 7 +------ src/threading/MsgThread.cc | 2 ++ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/logging/writers/Ascii.cc b/src/logging/writers/Ascii.cc index a0d4504d64..3bc4ef4b38 100644 --- a/src/logging/writers/Ascii.cc +++ b/src/logging/writers/Ascii.cc @@ -52,12 +52,6 @@ Ascii::Ascii(WriterFrontend* frontend) : WriterBackend(frontend) Ascii::~Ascii() { - if ( ! ascii_done ) - { - fprintf(stderr, "missing finish message\n"); - abort(); - } - // Normally, the file will be closed here already via the Finish() // message. But when we terminate abnormally, we may still have it // open. @@ -170,6 +164,7 @@ bool Ascii::DoFinish(double network_time) } ascii_done = true; + CloseFile(network_time); return true; } diff --git a/src/threading/MsgThread.cc b/src/threading/MsgThread.cc index e4cda1e84d..45fbf6afa5 100644 --- a/src/threading/MsgThread.cc +++ b/src/threading/MsgThread.cc @@ -175,6 +175,8 @@ void MsgThread::OnStop() usleep(1000); } + Finished(); + // One more message to make sure the current queue read operation unblocks. SendIn(new UnblockMessage(this), true); }