If a thread doesn't terminate, we log that but not longer proceed

(because it could hang later still).

Also logging to stderr as well to make sure one sees it.

Also adding code to the ASCII writer to catch termination
inconsistencies.
This commit is contained in:
Robin Sommer 2012-07-16 13:40:19 -07:00
parent 1ca0d970fc
commit c8789cff94
8 changed files with 23 additions and 10 deletions

@ -1 +1 @@
Subproject commit 4ad8d15b6395925c9875c9d2912a6cc3b4918e0a
Subproject commit b4094cb75e0a7769123f7db1f5d73f3f9f1c3977

@ -1 +1 @@
Subproject commit c691c01e9cefae5a79bcd4b0f84ca387c8c587a7
Subproject commit 2038e3de042115c3caa706426e16c830c1fd1e9e

@ -1 +1 @@
Subproject commit 8234b8903cbc775f341bdb6a1c0159981d88d27b
Subproject commit 07866915a1450ddd25b888917f494b4824b0cc3f

@ -1 +1 @@
Subproject commit d5ecd1a42c04b0dca332edc31811e5a6d0f7f2fb
Subproject commit 892b60edb967bb456872638f22ba994e84530137

2
cmake

@ -1 +1 @@
Subproject commit 2a72c5e08e018cf632033af3920432d5f684e130
Subproject commit 96f3d92acadbe1ae64f410e974c5ff503903394b

View file

@ -16,6 +16,7 @@ using threading::Field;
Ascii::Ascii(WriterFrontend* frontend) : WriterBackend(frontend)
{
file = 0;
ascii_done = false;
output_to_stdout = BifConst::LogAscii::output_to_stdout;
include_meta = BifConst::LogAscii::include_meta;
@ -51,6 +52,12 @@ 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.
@ -156,6 +163,13 @@ bool Ascii::DoFlush(double network_time)
bool Ascii::DoFinish(double network_time)
{
if ( ascii_done )
{
fprintf(stderr, "duplicate finish message\n");
abort();
}
ascii_done = true;
CloseFile(network_time);
return true;
}

View file

@ -40,6 +40,7 @@ private:
FILE* file;
string fname;
ODesc desc;
bool ascii_done;
// Options set from the script-level.
bool output_to_stdout;

View file

@ -166,17 +166,15 @@ void MsgThread::OnStop()
int cnt = 0;
while ( ! finished )
{
if ( ++cnt > 1000 ) // Insurance against broken threads ...
if ( ++cnt % 2000 == 0 ) // Insurance against broken threads ...
{
reporter->Warning("thread %s didn't finish in time", Name().c_str());
break;
reporter->Warning("thread %s has not yet terminated ...", Name().c_str());
fprintf(stderr, "warning: thread %s has not yet terminated ...", Name().c_str());
}
usleep(1000);
}
Finished();
// One more message to make sure the current queue read operation unblocks.
SendIn(new UnblockMessage(this), true);
}