From 72ff275e3c0013d4a95e5de4533fb1ff3bdbf175 Mon Sep 17 00:00:00 2001 From: Igor Canadi Date: Mon, 28 Apr 2014 23:30:27 -0400 Subject: [PATCH] Fix TransactionLogIterator EOF caching Summary: When TransactionLogIterator comes to EOF, it calls UnmarkEOF and continues reading. However, if glibc cached the EOF status of the file, it will get EOF again, even though the new data might have been written to it. This has been causing errors in Mac OS. Test Plan: test passes, was failing before Reviewers: dhruba, haobo, sdong Reviewed By: haobo CC: leveldb Differential Revision: https://reviews.facebook.net/D18381 --- db/db_test.cc | 4 ---- util/env_posix.cc | 3 +++ 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/db/db_test.cc b/db/db_test.cc index 188cfff3d..20fdbd290 100644 --- a/db/db_test.cc +++ b/db/db_test.cc @@ -5555,9 +5555,6 @@ TEST(DBTest, TransactionLogIteratorMoveOverZeroFiles) { } while (ChangeCompactOptions()); } -// TODO(kailiu) disable the in non-linux platforms to temporarily solve -// // the unit test failure. -#ifdef OS_LINUX TEST(DBTest, TransactionLogIteratorStallAtLastRecord) { do { Options options = OptionsForLogIterTest(); @@ -5575,7 +5572,6 @@ TEST(DBTest, TransactionLogIteratorStallAtLastRecord) { ASSERT_TRUE(iter->Valid()); } while (ChangeCompactOptions()); } -#endif TEST(DBTest, TransactionLogIteratorJustEmptyFile) { do { diff --git a/util/env_posix.cc b/util/env_posix.cc index 9e76a126d..5cbd5bd00 100644 --- a/util/env_posix.cc +++ b/util/env_posix.cc @@ -182,6 +182,9 @@ class PosixSequentialFile: public SequentialFile { if (r < n) { if (feof(file_)) { // We leave status as ok if we hit the end of the file + // We also clear the error so that the reads can continue + // if a new data is written to the file + clearerr(file_); } else { // A partial read with an error: return a non-ok status s = IOError(filename_, errno);