From cb671ea1ca409c4dc436925f726230f5b77fb528 Mon Sep 17 00:00:00 2001 From: phantomape Date: Sun, 29 Mar 2020 21:54:47 -0700 Subject: [PATCH] env: Add clearerr() before repeating an interrupted file read (#6609) Summary: This change updates PosixSequentialFile::Read to call clearerr() before fread()ing again after an EINTR is returned on a previous fread. The original fix is from https://github.com/cockroachdb/rocksdb/commit/bd8f1ebb91bbf0e668d24faef273042cc1fe52de. Fixing https://github.com/facebook/rocksdb/issues/6509 Signed-off-by: phantomape Pull Request resolved: https://github.com/facebook/rocksdb/pull/6609 Reviewed By: zhichao-cao Differential Revision: D20731482 Pulled By: riversand963 fbshipit-source-id: 7f1f3a1449077d5560f45c465a78d08633740ba0 --- env/io_posix.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/env/io_posix.cc b/env/io_posix.cc index b44dbd717..e2dc47ae4 100644 --- a/env/io_posix.cc +++ b/env/io_posix.cc @@ -234,6 +234,7 @@ IOStatus PosixSequentialFile::Read(size_t n, const IOOptions& /*opts*/, IOStatus s; size_t r = 0; do { + clearerr(file_); r = fread_unlocked(scratch, 1, n, file_); } while (r == 0 && ferror(file_) && errno == EINTR); *result = Slice(scratch, r);