mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-12 06:21:50 +00:00
prevent uncaught exception in thread
This commit is contained in:
parent
449604dc1a
commit
7e0c95d126
1 changed files with 5 additions and 2 deletions
|
|
@ -286,7 +286,8 @@ class SocketConnection : public Connection {
|
||||||
closesocket(descriptor);
|
closesocket(descriptor);
|
||||||
freeaddrinfo(addr);
|
freeaddrinfo(addr);
|
||||||
state = ConnectionState::CLOSED;
|
state = ConnectionState::CLOSED;
|
||||||
throw error;
|
logger.error() << error.what();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
logger.info() << "connected to " << to_string(addr);
|
logger.info() << "connected to " << to_string(addr);
|
||||||
state = ConnectionState::CONNECTED;
|
state = ConnectionState::CONNECTED;
|
||||||
|
|
@ -311,7 +312,9 @@ public:
|
||||||
void connect(runnable callback) override {
|
void connect(runnable callback) override {
|
||||||
thread = std::make_unique<std::thread>([this, callback]() {
|
thread = std::make_unique<std::thread>([this, callback]() {
|
||||||
connectSocket();
|
connectSocket();
|
||||||
callback();
|
if (state == ConnectionState::CONNECTED) {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
while (state == ConnectionState::CONNECTED) {
|
while (state == ConnectionState::CONNECTED) {
|
||||||
int size = recvsocket(descriptor, buffer.data(), buffer.size());
|
int size = recvsocket(descriptor, buffer.data(), buffer.size());
|
||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue