Skip to content

Commit

Permalink
Simplify code flow.
Browse files Browse the repository at this point in the history
Change-Id: Ifc18ae945f9946e511a394dd92d4e884e6d3ae6d
Signed-off-by: Michael Meeks <[email protected]>
  • Loading branch information
mmeeks committed Oct 26, 2024
1 parent 749f035 commit ef6ccef
Showing 1 changed file with 29 additions and 29 deletions.
58 changes: 29 additions & 29 deletions net/Socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1480,40 +1480,40 @@ std::ostream& StreamSocket::stream(std::ostream& os) const

bool StreamSocket::checkRemoval(std::chrono::steady_clock::time_point now)
{
if( isIPType() )
{
// Forced removal on outside-facing IPv[46] network connections only
const auto durLast =
std::chrono::duration_cast<std::chrono::milliseconds>(now - getLastSeenTime());
/// TO Criteria: Violate maximum idle (_pollTimeout default 64s)
const bool isIdle = _pollTimeout > std::chrono::microseconds::zero() &&
durLast > _pollTimeout;
/// TO Criteria: Shall terminate?
const bool isTermination = SigUtil::getTerminationFlag();
if (isIdle || isTermination )
if( !isIPType() )
return false;

// Forced removal on outside-facing IPv[46] network connections only
const auto durLast =
std::chrono::duration_cast<std::chrono::milliseconds>(now - getLastSeenTime());
/// TO Criteria: Violate maximum idle (_pollTimeout default 64s)
const bool isIdle = _pollTimeout > std::chrono::microseconds::zero() &&
durLast > _pollTimeout;
/// TO Criteria: Shall terminate?
const bool isTermination = SigUtil::getTerminationFlag();
if (isIdle || isTermination )
{
LOG_WRN("CheckRemoval: Timeout: {Idle " << isIdle
<< ", Termination " << isTermination << "}, "
<< getStatsString(now) << ", "
<< *this);
if (_socketHandler)
{
LOG_WRN("CheckRemoval: Timeout: {Idle " << isIdle
<< ", Termination " << isTermination << "}, "
<< getStatsString(now) << ", "
<< *this);
if (_socketHandler)
{
_socketHandler->onDisconnect();
if( isOpen() ) {
// Note: Ensure proper semantics of onDisconnect()
LOG_WRN("Socket still open post onDisconnect(), forced shutdown.");
shutdown(); // signal
closeConnection(); // real -> setClosed()
}
}
else
{
_socketHandler->onDisconnect();
if( isOpen() ) {
// Note: Ensure proper semantics of onDisconnect()
LOG_WRN("Socket still open post onDisconnect(), forced shutdown.");
shutdown(); // signal
closeConnection(); // real -> setClosed()
}
assert(isOpen() == false); // should have issued shutdown
return true;
}
else
{
shutdown(); // signal
closeConnection(); // real -> setClosed()
}
assert(isOpen() == false); // should have issued shutdown
return true;
}
return false;
}
Expand Down

0 comments on commit ef6ccef

Please sign in to comment.