Skip to content

Commit

Permalink
Revert "When closing the socket, force close the socket after a timeout"
Browse files Browse the repository at this point in the history
This reverts commit d4805cd.
Contributes to CURA-1453 and CURA-1391
  • Loading branch information
sedwards2009 committed May 4, 2016
1 parent 5e2c5de commit 9bf9af5
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions src/Socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,21 +177,10 @@ void Socket::close()
// Make the socket request close.
d->next_state = SocketState::Closing;

int timeout = 0;
// Wait with closing until we properly clear the send queue.
while(d->next_state == SocketState::Closing || d->state == SocketState::Closing)
while(d->state == SocketState::Closing)
{
std::this_thread::sleep_for(std::chrono::milliseconds(100));

// In certain situations, the socket seems to stall on recv.
timeout += 100;
if(timeout > 1000)
{
d->error(ErrorCode::ReceiveFailedError, "Failed to cleanly close socket, force closing it");
d->platform_socket.shutdown(PlatformSocket::ShutdownDirection::ShutdownBoth);
d->platform_socket.close();
d->next_state = SocketState::Error;
}
}
}
else
Expand Down

0 comments on commit 9bf9af5

Please sign in to comment.