don't log repeated exceptions

This commit is contained in:
Johannes Pohl 2016-11-24 17:21:39 +01:00
parent 9ec135e1b8
commit 8cf069642d
2 changed files with 16 additions and 3 deletions

View file

@ -62,6 +62,7 @@ void PipeStream::worker()
{ {
timeval tvChunk; timeval tvChunk;
std::unique_ptr<msg::PcmChunk> chunk(new msg::PcmChunk(sampleFormat_, pcmReadMs_)); std::unique_ptr<msg::PcmChunk> chunk(new msg::PcmChunk(sampleFormat_, pcmReadMs_));
string lastException = "";
while (active_) while (active_)
{ {
@ -121,11 +122,17 @@ void PipeStream::worker()
pcmListener_->onResync(this, currentTick - nextTick); pcmListener_->onResync(this, currentTick - nextTick);
nextTick = currentTick; nextTick = currentTick;
} }
lastException = "";
} }
} }
catch(const std::exception& e) catch(const std::exception& e)
{ {
logE << "(PipeStream) Exception: " << e.what() << std::endl; if (lastException != e.what())
{
logE << "(PipeStream) Exception: " << e.what() << std::endl;
lastException = e.what();
}
if (!sleep(100)) if (!sleep(100))
break; break;
} }

View file

@ -146,8 +146,8 @@ void ProcessStream::worker()
{ {
timeval tvChunk; timeval tvChunk;
std::unique_ptr<msg::PcmChunk> chunk(new msg::PcmChunk(sampleFormat_, pcmReadMs_)); std::unique_ptr<msg::PcmChunk> chunk(new msg::PcmChunk(sampleFormat_, pcmReadMs_));
setState(kPlaying); setState(kPlaying);
string lastException = "";
while (active_) while (active_)
{ {
@ -208,11 +208,17 @@ void ProcessStream::worker()
pcmListener_->onResync(this, currentTick - nextTick); pcmListener_->onResync(this, currentTick - nextTick);
nextTick = currentTick; nextTick = currentTick;
} }
lastException = "";
} }
} }
catch(const std::exception& e) catch(const std::exception& e)
{ {
logE << "(ProcessStream) Exception: " << e.what() << std::endl; if (lastException != e.what())
{
logE << "(PipeStream) Exception: " << e.what() << std::endl;
lastException = e.what();
}
process_->kill(); process_->kill();
if (!sleep(30000)) if (!sleep(30000))
break; break;