Skip to content
Snippets Groups Projects
Commit ffff0675 authored by Nicolas Pope's avatar Nicolas Pope
Browse files

#72 Ensure recv finished before close

parent 43c18db8
No related branches found
No related tags found
No related merge requests found
...@@ -218,10 +218,16 @@ void Peer::_updateURI() { ...@@ -218,10 +218,16 @@ void Peer::_updateURI() {
} }
void Peer::rawClose() { void Peer::rawClose() {
UNIQUE_LOCK(send_mtx_, lk_send);
// UNIQUE_LOCK(recv_mtx_, lk_recv); // UNIQUE_LOCK(recv_mtx_, lk_recv);
sock_->close();
status_ = NodeStatus::kDisconnected; status_ = NodeStatus::kDisconnected;
// Must make sure no jobs are active
while (job_count_ > 0) {
std::this_thread::sleep_for(std::chrono::milliseconds(1));
}
UNIQUE_LOCK(send_mtx_, lk_send);
sock_->close();
} }
void Peer::close(bool retry) { void Peer::close(bool retry) {
...@@ -288,7 +294,9 @@ void Peer::_createJob() { ...@@ -288,7 +294,9 @@ void Peer::_createJob() {
} }
void Peer::data() { void Peer::data() {
ftl::Counter counter(&job_count_);
if (!sock_->is_valid()) { return; } if (!sock_->is_valid()) { return; }
if (status_ == NodeStatus::kDisconnected) return;
int rc = 0; int rc = 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment