Commit eb2cee8a authored by Eisenhauer, Greg's avatar Eisenhauer, Greg Committed by Bolea Sanchez, Vicente Adolfo
Browse files

Tweak POSIX fail on EOF to kill heisenbug (#4035)

Tweak POSIX fail on EOF to kill heisenbug
parent 7e88591a
Loading
Loading
Loading
Loading
+13 −5
Original line number Diff line number Diff line
/*
 * Distributed under the OSI-approved Apache License, Version 2.0.  See
 * accompanying file Copyright.txt for details.
 *
 * FilePOSIX.cpp file I/O using POSIX I/O library
 *
@@ -437,9 +435,19 @@ void FilePOSIX::Read(char *buffer, size_t size, size_t start)
            {
                if (m_FailOnEOF)
                {
                    // we got an EOF on data that *should* be present,
                    // but maybe we've got filesystem consistency
                    // issues.  We'll wait, but if the backoff time
                    // reaches 30 seconds (nearly 45 seconds total
                    // wait time) and we still don't have data, treat
                    // this as a real failure and throw an exception.
                    std::this_thread::sleep_for(std::chrono::nanoseconds(backoff_ns));
                    backoff_ns *= 2;
                    if (std::chrono::nanoseconds(backoff_ns) > std::chrono::seconds(30))
                        helper::Throw<std::ios_base::failure>(
                            "Toolkit", "transport::file::FilePOSIX", "Read",
                        "Read past end of file on " + m_Name + " " + SysErrMsg());
                            "Read past end of file on " + m_Name + " trying to read " +
                                std::to_string(size) + " bytes " + SysErrMsg());
                }
                else
                {