face: don't set TransportState to FAILED if connection is closed cleanly
Change-Id: I0989cdf49558574f30b55a172d467b39683f9bb6
Refs: #4099
diff --git a/daemon/face/stream-transport.hpp b/daemon/face/stream-transport.hpp
index cba7c78..2a57d68 100644
--- a/daemon/face/stream-transport.hpp
+++ b/daemon/face/stream-transport.hpp
@@ -276,10 +276,13 @@
void
StreamTransport<T>::handleError(const boost::system::error_code& error)
{
- if (error != boost::asio::error::eof)
+ if (error == boost::asio::error::eof) {
+ this->setState(TransportState::CLOSING);
+ }
+ else {
NFD_LOG_FACE_ERROR("Send or receive operation failed: " << error.message());
-
- this->setState(TransportState::FAILED);
+ this->setState(TransportState::FAILED);
+ }
doClose();
}
diff --git a/daemon/face/transport.hpp b/daemon/face/transport.hpp
index ff5363f..85a0fd7 100644
--- a/daemon/face/transport.hpp
+++ b/daemon/face/transport.hpp
@@ -40,9 +40,9 @@
*/
enum class TransportState {
NONE,
- UP, ///< the transport is up
- DOWN, ///< the transport is down temporarily, and is being recovered
- CLOSING, ///< the transport is requested to be closed
+ UP, ///< the transport is up and can transmit packets
+ DOWN, ///< the transport is temporarily down, and is being recovered
+ CLOSING, ///< the transport is being closed gracefully, either by the peer or by a call to close()
FAILED, ///< the transport is being closed due to a failure
CLOSED ///< the transport is closed, and can be safely deallocated
};