mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +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);
|
||||
freeaddrinfo(addr);
|
||||
state = ConnectionState::CLOSED;
|
||||
throw error;
|
||||
logger.error() << error.what();
|
||||
return;
|
||||
}
|
||||
logger.info() << "connected to " << to_string(addr);
|
||||
state = ConnectionState::CONNECTED;
|
||||
|
|
@ -311,7 +312,9 @@ public:
|
|||
void connect(runnable callback) override {
|
||||
thread = std::make_unique<std::thread>([this, callback]() {
|
||||
connectSocket();
|
||||
callback();
|
||||
if (state == ConnectionState::CONNECTED) {
|
||||
callback();
|
||||
}
|
||||
while (state == ConnectionState::CONNECTED) {
|
||||
int size = recvsocket(descriptor, buffer.data(), buffer.size());
|
||||
if (size == 0) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue