xvc_server: Make thread exit cleanly (#526)
This commit is contained in:
parent
b2c2ae80c0
commit
703af08c91
|
|
@ -156,6 +156,7 @@ void XVC_server::thread_listen()
|
||||||
|
|
||||||
maxfd = _sock;
|
maxfd = _sock;
|
||||||
|
|
||||||
|
try {
|
||||||
while (!_must_stop) {
|
while (!_must_stop) {
|
||||||
fd_set read = conn, except = conn;
|
fd_set read = conn, except = conn;
|
||||||
int fd;
|
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;
|
_is_stopped = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -224,6 +228,7 @@ bool XVC_server::listen_loop()
|
||||||
_must_stop = true;
|
_must_stop = true;
|
||||||
close_connection();
|
close_connection();
|
||||||
while (!_is_stopped){}
|
while (!_is_stopped){}
|
||||||
|
_thread->join();
|
||||||
delete _thread;
|
delete _thread;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue