Improve SSLHTTPPeer asynchronous shutdown

This commit is contained in:
Miguel Portilla
2018-06-28 15:20:29 -04:00
committed by Nik Bougalis
parent d98c4992dd
commit d289512aeb
2 changed files with 15 additions and 4 deletions

View File

@@ -46,17 +46,18 @@ public:
} }
char* duplicateStringValue ( const char* value, 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 ) //if ( !value || value[0] == 0 )
// return 0; // return 0;
if ( length == unknown ) if ( length == unknown )
length = (unsigned int)strlen (value); length = value ? (unsigned int)strlen ( value ) : 0;
char* newString = static_cast<char*> ( malloc ( length + 1 ) ); char* newString = static_cast<char*> ( malloc ( length + 1 ) );
memcpy ( newString, value, length ); if ( value )
memcpy ( newString, value, length );
newString[length] = 0; newString[length] = 0;
return newString; return newString;
} }

View File

@@ -179,6 +179,16 @@ SSLHTTPPeer<Handler>::
on_shutdown(error_code ec) on_shutdown(error_code ec)
{ {
this->cancel_timer(); 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); stream_.lowest_layer().close(ec);
} }