xvc_server: Make thread exit cleanly (#526)

This commit is contained in:
Marcus Comstedt 2025-03-10 21:25:13 +01:00 committed by GitHub
parent b2c2ae80c0
commit 703af08c91
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 50 additions and 45 deletions

View File

@ -156,6 +156,7 @@ void XVC_server::thread_listen()
maxfd = _sock;
try {
while (!_must_stop) {
fd_set read = conn, except = conn;
int fd;
@ -211,6 +212,9 @@ void XVC_server::thread_listen()
}
}
}
} catch (const std::runtime_error& e) {
std::cerr << "thread exiting with error: " << e.what() << std::endl;
}
_is_stopped = true;
}
@ -224,6 +228,7 @@ bool XVC_server::listen_loop()
_must_stop = true;
close_connection();
while (!_is_stopped){}
_thread->join();
delete _thread;
return true;