Merge pull request #625 from jonahquark81/master

Minor tweaks to resolve #623 & #624
This commit is contained in:
Johannes Pohl 2020-05-31 13:43:38 +02:00 committed by GitHub
commit c07b56816d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View file

@ -90,7 +90,7 @@ void Config::init(const std::string& root_directory, const std::string& user, co
try try
{ {
ifstream ifs(filename_, std::ifstream::in); ifstream ifs(filename_, std::ifstream::in);
if (ifs.good()) if ((ifs.good()) && (ifs.peek() != std::ifstream::traits_type::eof()))
{ {
json j; json j;
ifs >> j; ifs >> j;

View file

@ -240,9 +240,17 @@ void AirplayStream::pipeReadLine()
<< "\n"; << "\n";
wait(pipe_open_timer_, 2500ms, [this] { pipeReadLine(); }); wait(pipe_open_timer_, 2500ms, [this] { pipeReadLine(); });
} }
if (ec.value() == boost::asio::error::bad_descriptor)
{
// If shairport-sync has not finished setting up the pipe, bad file descriptor is returned.
// retry in a few seconds
LOG(INFO, LOG_TAG) << "Waiting for metadata, retrying in 2500ms"
<< "\n";
wait(pipe_open_timer_, 2500ms, [this] { pipeReadLine(); });
}
else else
{ {
LOG(ERROR, LOG_TAG) << "Error while reading from metadata pipe: " << ec.message() << "\n"; LOG(ERROR, LOG_TAG) << "Error while reading from metadata pipe: " << ec.message() << "\n";
} }
return; return;
} }