Skip to content

Commit

Permalink
[remove] Debug async close
Browse files Browse the repository at this point in the history
  • Loading branch information
seelabs committed Dec 6, 2023
1 parent fcec6cf commit d2ab431
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/ripple/server/impl/BaseWSPeer.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@
#include <ripple/protocol/BuildInfo.h>
#include <ripple/server/impl/BasePeer.h>
#include <ripple/server/impl/LowestLayer.h>

#include <boost/beast/core/multi_buffer.hpp>
#include <boost/beast/http/message.hpp>
#include <boost/beast/websocket.hpp>
#include <boost/stacktrace.hpp>

#include <cassert>
#include <functional>

Expand Down Expand Up @@ -63,6 +66,23 @@ class BaseWSPeer : public BasePeer<Handler, Impl>, public WSSession
void(boost::beast::websocket::frame_type, boost::beast::string_view)>
control_callback_;

std::atomic<int> closeCounter{0};
boost::stacktrace::stacktrace closeTrace;
void
checkAsyncClose()
{
if (closeCounter.fetch_add(1, std::memory_order_relaxed))
{
JLOG(this->j_.fatal()) << "xyzzy cur:\n" << closeTrace;
JLOG(this->j_.fatal()) << "xyzzy pre:\n"
<< boost::stacktrace::stacktrace();
}
else
{
closeTrace = boost::stacktrace::stacktrace();
}
}

public:
template <class Body, class Headers>
BaseWSPeer(
Expand Down Expand Up @@ -259,6 +279,7 @@ BaseWSPeer<Handler, Impl>::close(
do_close_ = true;
if (wq_.empty())
{
checkAsyncClose();
impl().ws_.async_close(
reason,
bind_executor(
Expand Down Expand Up @@ -348,6 +369,8 @@ BaseWSPeer<Handler, Impl>::on_write_fin(error_code const& ec)
return fail(ec, "write_fin");
wq_.pop_front();
if (do_close_)
{
checkAsyncClose();
impl().ws_.async_close(
cr_,
bind_executor(
Expand All @@ -356,6 +379,7 @@ BaseWSPeer<Handler, Impl>::on_write_fin(error_code const& ec)
&BaseWSPeer::on_close,
impl().shared_from_this(),
std::placeholders::_1)));
}
else if (!wq_.empty())
on_write({});
}
Expand Down

0 comments on commit d2ab431

Please sign in to comment.