Fixes #289: Client now also attempts to reconnect if writing request to server fails
This commit is contained in:
parent
3be67623fa
commit
02bcd02891
1 changed files with 27 additions and 20 deletions
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue