prevent uncaught exception in thread
This commit is contained in:
parent
449604dc1a
commit
7e0c95d126
@ -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…
x
Reference in New Issue
Block a user