From d289512aebb3d04e39545d67080d6a438e42a301 Mon Sep 17 00:00:00 2001 From: Miguel Portilla Date: Thu, 28 Jun 2018 15:20:29 -0400 Subject: [PATCH] Improve SSLHTTPPeer asynchronous shutdown --- src/ripple/json/impl/json_value.cpp | 9 +++++---- src/ripple/server/impl/SSLHTTPPeer.h | 10 ++++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/ripple/json/impl/json_value.cpp b/src/ripple/json/impl/json_value.cpp index 81327f09d0..7fee5a95a8 100644 --- a/src/ripple/json/impl/json_value.cpp +++ b/src/ripple/json/impl/json_value.cpp @@ -46,17 +46,18 @@ public: } char* duplicateStringValue ( const char* value, - unsigned int length = unknown ) override + unsigned int length = unknown ) override { - //@todo invesgate this old optimization + //@todo investigate this old optimization //if ( !value || value[0] == 0 ) // return 0; if ( length == unknown ) - length = (unsigned int)strlen (value); + length = value ? (unsigned int)strlen ( value ) : 0; char* newString = static_cast ( malloc ( length + 1 ) ); - memcpy ( newString, value, length ); + if ( value ) + memcpy ( newString, value, length ); newString[length] = 0; return newString; } diff --git a/src/ripple/server/impl/SSLHTTPPeer.h b/src/ripple/server/impl/SSLHTTPPeer.h index a44f35596b..e7dd7fef20 100644 --- a/src/ripple/server/impl/SSLHTTPPeer.h +++ b/src/ripple/server/impl/SSLHTTPPeer.h @@ -179,6 +179,16 @@ SSLHTTPPeer:: on_shutdown(error_code ec) { this->cancel_timer(); + + if (ec == boost::asio::error::operation_aborted) + return; + if (ec) + { + JLOG(this->journal_.debug()) << + "on_shutdown: " << ec.message(); + } + + // Close socket now in case this->destructor is delayed stream_.lowest_layer().close(ec); }