Revert HDFS-10543 patch due to correctness issues it caused. Done by James Clampffer

This commit is contained in:
James 2016-07-27 17:02:11 -04:00 committed by James Clampffer
parent a586ccbcfa
commit d75c835696
1 changed files with 15 additions and 23 deletions

View File

@ -78,9 +78,7 @@ Status FileHandleImpl::PositionRead(void *buf, size_t *nbyte, off_t offset) {
LOG_TRACE(kFileHandle, << "FileHandleImpl::[sync]PositionRead(" LOG_TRACE(kFileHandle, << "FileHandleImpl::[sync]PositionRead("
<< FMT_THIS_ADDR << ", buf=" << buf << FMT_THIS_ADDR << ", buf=" << buf
<< ", nbyte=" << *nbyte << ") called"); << ", nbyte=" << *nbyte << ") called");
size_t totalBytesRead = 0;
Status stat = Status::OK();
while (*nbyte != 0 && offset < (off_t)(file_info_->file_length_)) {
auto callstate = std::make_shared<std::promise<std::tuple<Status, size_t>>>(); auto callstate = std::make_shared<std::promise<std::tuple<Status, size_t>>>();
std::future<std::tuple<Status, size_t>> future(callstate->get_future()); std::future<std::tuple<Status, size_t>> future(callstate->get_future());
@ -93,19 +91,13 @@ Status FileHandleImpl::PositionRead(void *buf, size_t *nbyte, off_t offset) {
/* wait for async to finish */ /* wait for async to finish */
auto returnstate = future.get(); auto returnstate = future.get();
stat = std::get<0>(returnstate); auto stat = std::get<0>(returnstate);
if (!stat.ok()) { if (!stat.ok()) {
return stat; return stat;
} }
size_t bytesRead = std::get<1>(returnstate); *nbyte = std::get<1>(returnstate);
*nbyte = *nbyte - bytesRead;
totalBytesRead += bytesRead;
offset += bytesRead;
}
/* Update the bytes read for return */
*nbyte = totalBytesRead;
return stat; return stat;
} }
@ -118,8 +110,8 @@ Status FileHandleImpl::Read(void *buf, size_t *nbyte) {
if(!stat.ok()) { if(!stat.ok()) {
return stat; return stat;
} }
offset_ += *nbyte;
offset_ += *nbyte;
return Status::OK(); return Status::OK();
} }