Skip to content

Commit

Permalink
Fix pipe reconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
badaix committed Jun 29, 2024
1 parent 302893e commit dea298b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
6 changes: 3 additions & 3 deletions common/sample_format.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,17 @@ class SampleFormat

inline double msRate() const
{
return (double)rate_ / 1000.;
return static_cast<double>(rate_) / 1000.;
}

inline double usRate() const
{
return (double)rate_ / 1000000.;
return static_cast<double>(rate_) / 1000000.;
}

inline double nsRate() const
{
return (double)rate_ / 1000000000.;
return static_cast<double>(rate_) / 1000000000.;
}

private:
Expand Down
12 changes: 11 additions & 1 deletion server/streamreader/pipe_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
// standard headers
#include <cerrno>
#include <memory>
#include <system_error>


using namespace std;
Expand Down Expand Up @@ -59,7 +60,16 @@ void PipeStream::connect()
{
int fd = open(uri_.path.c_str(), O_RDONLY | O_NONBLOCK);
if (fd < 0)
throw SnapException("failed to open fifo \"" + uri_.path + "\": " + cpt::to_string(errno));
{
std::string error = "failed to open fifo \"" + uri_.path + "\": " + cpt::to_string(errno);
if (errno == static_cast<int>(std::errc::no_such_file_or_directory))
{
LOG(ERROR, LOG_TAG) << error << "\n";
wait(read_timer_, 200ms, [this] { connect(); });
return;
}
throw SnapException(error);
}

int pipe_size = -1;
#if !defined(MACOS) && !defined(FREEBSD)
Expand Down

0 comments on commit dea298b

Please sign in to comment.