fix(rpc): stop server before joining threads in crpc_deinit
All checks were successful
Verification / Is-Buildable (push) Successful in 3m22s
All checks were successful
Verification / Is-Buildable (push) Successful in 3m22s
crpc_deinit() called TcpServer::join() without stop(), so with any live TCP client the accept thread never exited and deinit blocked forever on the caller's thread (froze the Unity main thread in OnDestroy during e2e). Call server->stop() first, which clears running_ and unblocks accept, then join.
This commit is contained in:
parent
7c9df13628
commit
cd97e7b3f1
@ -98,8 +98,13 @@ void crpc_init_with_address(const char *ip, int port) {
|
||||
}
|
||||
|
||||
void crpc_deinit() {
|
||||
if (server)
|
||||
if (server) {
|
||||
// Must stop() before join(): stop() clears running_ so the accept
|
||||
// thread can exit; join() alone would block forever while a client
|
||||
// thread is blocked in a read (deadlock observed in Unity e2e).
|
||||
server->stop();
|
||||
server->join();
|
||||
}
|
||||
server.reset();
|
||||
std::lock_guard lock(gc_mtx);
|
||||
gc.clear();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user