Skip to content

Commit

Permalink
Merge pull request #487 from yvxiang/fix_close
Browse files Browse the repository at this point in the history
Wait fd been close
  • Loading branch information
lylei authored Sep 23, 2016
2 parents b5fe415 + 74c7f87 commit b5c0ec2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/chunkserver/data_block.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Block::~Block() {
if (file_desc_ >= 0) {
close(file_desc_);
g_writing_blocks.Dec();
file_desc_ = -1;
file_desc_ = -2;
}
if (recv_window_) {
if (recv_window_->Size()) {
Expand Down Expand Up @@ -292,7 +292,7 @@ bool Block::Close() {
this->AddRef();
thread_pool_->AddPriorityTask(boost::bind(&Block::DiskWrite, this));

while (file_desc_ != -1) {
while (file_desc_ != -2) {
close_cv_.Wait();
}
if (meta_.version() == -1) {
Expand Down Expand Up @@ -362,12 +362,12 @@ void Block::DiskWrite() {
}
if (finished_ || deleted_) {
assert (deleted_ || block_buf_list_.empty());
if (file_desc_ != -1) {
if (file_desc_ != -2) {
int ret = close(file_desc_);
LOG(INFO, "[DiskWrite] close file %s", disk_file_.c_str());
assert(ret == 0);
g_writing_blocks.Dec();
file_desc_ = -1;
file_desc_ = -2;
if (recv_window_ && recv_window_->Size()) {
LOG(INFO, "#%ld recv_window fragments: %d\n",
meta_.block_id(), recv_window_->Size());
Expand Down

0 comments on commit b5c0ec2

Please sign in to comment.