Skip to content

Commit

Permalink
Merge pull request fix8#175 from gunjan-munjal/bugfix/FX-884_deadlock…
Browse files Browse the repository at this point in the history
…_corrected

FX-884 deadlock correction
  • Loading branch information
dakka authored May 18, 2018
2 parents 4d24bf5 + b27addb commit 2a7a60b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
5 changes: 3 additions & 2 deletions include/fix8/session.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -657,8 +657,9 @@ class Session
/// Force persister to sync next send/receive seqnums
F8API void update_persist_seqnums();

/// stop the session.
F8API void stop();
/*! stop the session.
\param clearTimer - false if timer event queue clearing is to be omitted */
F8API void stop(const bool clearTimer = true);

/*! Get the connection object.
\return the connection object */
Expand Down
13 changes: 9 additions & 4 deletions runtime/session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,16 +227,17 @@ int Session::start(Connection *connection, bool wait, const unsigned send_seqnum
}

//-------------------------------------------------------------------------------------------------
void Session::stop()
void Session::stop(const bool clearTimer)
{
if (_control & shutdown)
return;
_control |= shutdown;

if (_connection)
{
if (_connection->get_role() == Connection::cn_initiator)
_timer.clear();
if (_connection->get_role() == Connection::cn_initiator &&
clearTimer)
_timer.clear();
else
{
f8_scoped_spin_lock guard(_per_spl, _connection->get_pmodel() == pm_coro);
Expand Down Expand Up @@ -832,7 +833,11 @@ bool Session::heartbeat_service()
log(ostr.str(), Logger::Error);
try
{
stop();
// do not clear the timer, as the lock required for the same is already taken by the timer thread
// not removing the remaining events will cause some extra work to be done,
// but that work will be limited by the fact that the work checks if the session is already shutdown
// activation_service and heartbeat_service both have shutdown checks
stop(false);
}
catch (Poco::Net::NetException& e)
{
Expand Down

0 comments on commit 2a7a60b

Please sign in to comment.