1
0
Fork 0

AgencyComm evaluates fully sent requests properly.

This commit is contained in:
Kaveh Vahedipour 2017-01-24 09:14:28 +01:00
parent 95a165d5f4
commit f45d775106
2 changed files with 12 additions and 3 deletions

View File

@ -329,6 +329,7 @@ AgencyCommResult::AgencyCommResult()
_values(),
_statusCode(0),
_connected(false),
_sent(false),
_clientId("") {}
AgencyCommResult::AgencyCommResult(
@ -339,6 +340,7 @@ AgencyCommResult::AgencyCommResult(
_values(),
_statusCode(code),
_connected(false),
_sent(false),
_clientId(clientId) {}
bool AgencyCommResult::connected() const { return _connected; }
@ -347,6 +349,8 @@ std::string AgencyCommResult::clientId() const { return _clientId; }
int AgencyCommResult::httpCode() const { return _statusCode; }
bool AgencyCommResult::sent() const { return _sent; }
int AgencyCommResult::errorCode() const {
try {
std::shared_ptr<VPackBuilder> bodyBuilder =
@ -409,6 +413,8 @@ void AgencyCommResult::clear() {
_message = "";
_body = "";
_statusCode = 0;
_sent = false;
_connected = false;
}
VPackSlice AgencyCommResult::slice() const { return _vpack->slice(); }
@ -1369,7 +1375,7 @@ AgencyCommResult AgencyComm::sendWithFailover(
}
// break on a watch timeout (drop connection)
if (!clientId.empty() &&
if (!clientId.empty() && result._sent &&
(result._statusCode == 0 || result._statusCode == 503)) {
VPackBuilder b;
@ -1484,8 +1490,7 @@ AgencyCommResult AgencyComm::send(
TRI_ASSERT(!url.empty());
AgencyCommResult result;
result._connected = false;
result._statusCode = 0;
if (!clientId.empty()) {
result._clientId = clientId;
}
@ -1526,6 +1531,7 @@ AgencyCommResult AgencyComm::send(
return result;
}
result._sent = response->haveSentRequestFully();
result._connected = true;
if (response->getHttpReturnCode() ==

View File

@ -243,6 +243,8 @@ class AgencyCommResult {
std::string const body() const { return _body; }
std::string const& bodyRef() const { return _body; }
bool sent() const;
void clear();
VPackSlice slice() const;
@ -257,6 +259,7 @@ class AgencyCommResult {
std::map<std::string, AgencyCommResultEntry> _values;
int _statusCode;
bool _connected;
bool _sent;
private:
std::shared_ptr<velocypack::Builder> _vpack;