WSConnection clean shutdown, fix hubTrigger ownership (it's deleted by the event loop)

This commit is contained in:
Doug Hoyte
2023-08-16 13:37:03 -04:00
parent aec8dbc33a
commit 42fe1f16ca
3 changed files with 18 additions and 6 deletions

View File

@ -149,7 +149,7 @@ struct MsgNegentropy : NonCopyable {
struct RelayServer {
std::unique_ptr<uS::Async> hubTrigger;
uS::Async *hubTrigger = nullptr;
// Thread Pools

View File

@ -39,7 +39,7 @@ void RelayServer::runWebsocket(ThreadPool<MsgWebsocket>::Thread &thr) {
};
uWS::Hub hub;
uWS::Group<uWS::SERVER> *hubGroup;
uWS::Group<uWS::SERVER> *hubGroup = nullptr;
flat_hash_map<uint64_t, Connection*> connIdToConnection;
uint64_t nextConnectionId = 1;
bool gracefulShutdown = false;
@ -219,7 +219,7 @@ void RelayServer::runWebsocket(ThreadPool<MsgWebsocket>::Thread &thr) {
}
};
hubTrigger = std::make_unique<uS::Async>(hub.getLoop());
hubTrigger = new uS::Async(hub.getLoop());
hubTrigger->setData(&asyncCb);
hubTrigger->start([](uS::Async *a){