Fixes #289: Client now also attempts to reconnect if writing request to server fails

This commit is contained in:
eidheim 2020-02-03 10:39:51 +01:00
commit 02bcd02891

View file

@ -559,8 +559,12 @@ namespace SimpleWeb {
return;
if(!ec)
this->read(session);
else {
if(session->connection->attempt_reconnect && ec != error::operation_aborted)
reconnect(session, ec);
else
session->callback(ec);
}
});
}
@ -620,7 +624,15 @@ namespace SimpleWeb {
session->callback(ec);
}
else {
if(session->connection->attempt_reconnect && ec != error::operation_aborted) {
if(session->connection->attempt_reconnect && ec != error::operation_aborted)
reconnect(session, ec);
else
session->callback(ec);
}
});
}
void reconnect(const std::shared_ptr<Session> &session, const error_code &ec) {
LockGuard lock(connections_mutex);
auto it = connections.find(session->connection);
if(it != connections.end()) {
@ -638,11 +650,6 @@ namespace SimpleWeb {
session->callback(ec);
}
}
else
session->callback(ec);
}
});
}
void read_content(const std::shared_ptr<Session> &session, std::size_t remaining_length) {
session->connection->set_timeout();