Fix log manager hanging on waiting for pending file rotations.

This changes writer implementations to always respond to rotation
messages in their DoRotate() method, even for failure/no-op cases
with a new RotationFailedMessage.  This informs the manager to
decrement its count of pending rotations.

Addresses #860.
This commit is contained in:
Jon Siwek 2012-07-27 13:31:17 -05:00 committed by Robin Sommer
parent 4bdac985cb
commit 4359bf6b42
8 changed files with 79 additions and 1 deletions

View file

@ -1215,12 +1215,16 @@ bool Manager::Flush(EnumVal* id)
void Manager::Terminate()
{
// Make sure we process all the pending rotations.
while ( rotations_pending )
while ( rotations_pending > 0 )
{
thread_mgr->ForceProcessing(); // A blatant layering violation ...
usleep(1000);
}
if ( rotations_pending < 0 )
reporter->InternalError("Negative pending log rotations: %d", rotations_pending);
for ( vector<Stream *>::iterator s = streams.begin(); s != streams.end(); ++s )
{
if ( ! *s )
@ -1384,3 +1388,11 @@ bool Manager::FinishedRotation(WriterFrontend* writer, const char* new_name, con
return result;
}
bool Manager::FailedRotation(WriterFrontend* writer, const char* filename,
double open, double close, bool terminating)
{
--rotations_pending;
DBG_LOG(DBG_LOGGING, "Failed rotating writer '%s', file '%s' at %.6f,",
writer->Name(), filename, network_time);
return true;
}