diff --git a/server/config.cpp b/server/config.cpp index 277e00ab..68baceb4 100644 --- a/server/config.cpp +++ b/server/config.cpp @@ -90,7 +90,7 @@ void Config::init(const std::string& root_directory, const std::string& user, co try { ifstream ifs(filename_, std::ifstream::in); - if (ifs.good()) + if ((ifs.good()) && (ifs.peek() != std::ifstream::traits_type::eof())) { json j; ifs >> j; diff --git a/server/streamreader/airplay_stream.cpp b/server/streamreader/airplay_stream.cpp index 9a66e18b..08af19f4 100644 --- a/server/streamreader/airplay_stream.cpp +++ b/server/streamreader/airplay_stream.cpp @@ -240,9 +240,17 @@ void AirplayStream::pipeReadLine() << "\n"; 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 { - 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; }