Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/mgmt/rpc/server/IPCSocketServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class IPCSocketServer : public BaseCommInterface
void close();
void late_check_peer_credentials(int peedFd, TSRPCHandlerOptions const &options, swoc::Errata &errata) const;

std::atomic_bool _running;
std::atomic_bool _running{false};

struct sockaddr_un _serverAddr;
int _socket{-1};
Expand Down
6 changes: 4 additions & 2 deletions src/mgmt/rpc/server/IPCSocketServer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ IPCSocketServer::init()
return ec;
}

// Set this before RPCServer creates the worker thread so an immediate stop
// cannot be overwritten when the worker eventually enters run().
_running.store(true);

return ec;
}

Expand Down Expand Up @@ -201,8 +205,6 @@ IPCSocketServer::poll_for_new_client(std::chrono::milliseconds timeout) const
void
IPCSocketServer::run()
{
_running.store(true);

while (_running) {
// poll till socket it's ready.
if (!this->poll_for_new_client()) {
Expand Down
12 changes: 6 additions & 6 deletions src/mgmt/rpc/server/RPCServer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ RPCServer::~RPCServer()
void * /* static */
RPCServer::run_thread(void *a)
{
void *ret = a;
if (jsonrpcServer->_init) {
jsonrpcServer->_rpcThread = jsonrpcServer->_init();
auto *server = static_cast<RPCServer *>(a);
if (server->_init) {
server->_rpcThread = server->_init();
}
jsonrpcServer->_socketImpl->run();
server->_socketImpl->run();
Dbg(dbg_ctl, "Socket stopped");
return ret;
return a;
}

void
Expand All @@ -75,7 +75,7 @@ RPCServer::start_thread(std::function<TSThread()> const &cb_init, std::function<
_init = cb_init;
_destroy = cb_destroy;

ink_thread_create(&_this_thread, run_thread, nullptr, 0, 0, nullptr);
ink_thread_create(&_this_thread, run_thread, this, 0, 0, nullptr);
}

void
Expand Down