1
0
Fork 0
This commit is contained in:
Jan Steemann 2013-12-20 15:12:21 +01:00
parent 2c8ef0125f
commit 55deb10126
8 changed files with 92 additions and 14 deletions

View File

@ -1,6 +1,8 @@
v1.4.x (XXXX-XX-XX)
-------------------
* fixed issue #711, #687: foxx-manager throws internal errors
* added `--server.ssl-protocol` option for client tools
this allows connecting from arangosh, arangoimp, arangoimp etc. to an ArangoDB
server that uses a non-default value for `--server.ssl-protocol`. The default

View File

@ -2728,7 +2728,7 @@ function ReplicationApplierSuite () {
// configure && start
replication.applier.properties({
endpoint: "tcp://9.9.9.9:9999",
endpoint: "tcp://9.9.9.9:9999", // should not exist
connectTimeout: 3,
maxConnectRetries: 1
});
@ -2775,15 +2775,14 @@ function ReplicationApplierSuite () {
state = replication.applier.state();
assertFalse(state.state.running);
// configure && start
replication.applier.properties({
endpoint: "tcp://www.arangodb.org:80",
endpoint: "tcp://www.arangodb.org:7999", // should not exist
connectTimeout: 3,
maxConnectRetries: 1
});
replication.applier.start();
replication.applier.start();
state = replication.applier.state();
assertTrue(state.state.running);
@ -2797,9 +2796,11 @@ function ReplicationApplierSuite () {
}
assertFalse(state.state.running);
assertTrue(state.state.totalFailedConnects <= i);
assertTrue(state.state.totalFailedConnects > 0);
assertTrue(state.state.progress.failedConnects > 0);
assertTrue(state.state.lastError.errorNum === errors.ERROR_REPLICATION_INVALID_RESPONSE.code ||
state.state.lastError.errorNum === errors.ERROR_REPLICATION_MASTER_ERROR.code);
state.state.lastError.errorNum === errors.ERROR_REPLICATION_MASTER_ERROR.code ||
state.state.lastError.errorNum === errors.ERROR_REPLICATION_NO_RESPONSE.code);
break;
}
@ -2827,7 +2828,7 @@ function ReplicationApplierSuite () {
// configure && start
replication.applier.properties({
endpoint: "tcp://9.9.9.9:9999"
endpoint: "tcp://9.9.9.9:9999" // should not exist
});
replication.applier.start();
@ -2874,7 +2875,7 @@ function ReplicationApplierSuite () {
}
replication.applier.properties({
endpoint: "tcp://9.9.9.9:9999"
endpoint: "tcp://9.9.9.9:9999"
});
properties = replication.applier.properties();
@ -3139,7 +3140,7 @@ function ReplicationSyncSuite () {
/// @brief executes the test suites
////////////////////////////////////////////////////////////////////////////////
jsunity.run(ReplicationLoggerSuite);
//jsunity.run(ReplicationLoggerSuite);
jsunity.run(ReplicationApplierSuite);
jsunity.run(ReplicationSyncSuite);

View File

@ -102,6 +102,7 @@ bool ClientConnection::checkSocket () {
if (res != TRI_ERROR_NO_ERROR) {
TRI_set_errno(errno);
_isConnected = false;
return false;
}
@ -110,6 +111,7 @@ bool ClientConnection::checkSocket () {
}
TRI_set_errno(so_error);
_isConnected = false;
return false;
}
@ -264,6 +266,7 @@ bool ClientConnection::readClientConnection (StringBuffer& stringBuffer) {
if (lenRead == 0) {
// nothing more to read
_isConnected = false;
break;
}

View File

@ -142,6 +142,7 @@ namespace triagens {
case (IN_READ_CHUNKED_HEADER):
case (IN_READ_CHUNKED_BODY): {
TRI_set_errno(TRI_ERROR_NO_ERROR);
if (_connection->handleRead(remainingTime, _readBuffer)) {
switch (_state) {
case (IN_READ_HEADER):
@ -161,6 +162,15 @@ namespace triagens {
}
}
else {
if (! _result->hasContentLength() &&
! _connection->isConnected() &&
_state == IN_READ_BODY) {
// no content-length header in response, now set the length
_result->setContentLength(_readBuffer.length());
readBody();
break;
}
setErrorMessage(TRI_last_error(), false);
this->close();
}
@ -387,8 +397,13 @@ namespace triagens {
_state = IN_READ_CHUNKED_HEADER;
return readChunkedHeader();
}
else if (_result->getContentLength()) {
else if (! _result->hasContentLength()) {
// no content-length header in response
_state = IN_READ_BODY;
return readBody();
}
else if (_result->hasContentLength() && _result->getContentLength() > 0) {
// found content-length header in response
if (_result->getContentLength() > _maxPacketSize) {
setErrorMessage("Content-Length > max packet size found", true);
@ -432,7 +447,7 @@ namespace triagens {
return true;
}
if (_readBuffer.length() >= _result->getContentLength()) {
if (_result->hasContentLength() && _readBuffer.length() >= _result->getContentLength()) {
if (_result->isDeflated()) {
// body is compressed using deflate. inflate it
_readBuffer.inflate(_result->getBody());

View File

@ -54,6 +54,7 @@ namespace triagens {
_returnCode = 0;
_returnMessage = "";
_contentLength = 0;
_hasContentLength = false;
_chunked = false;
_deflated = false;
_requestResultType = UNKNOWN;

View File

@ -123,6 +123,14 @@ namespace triagens {
this->_returnMessage = message;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief whether or not the response contained a content length header
////////////////////////////////////////////////////////////////////////////////
bool hasContentLength () const {
return _hasContentLength;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief returns the content length
////////////////////////////////////////////////////////////////////////////////
@ -137,6 +145,7 @@ namespace triagens {
void setContentLength (size_t len) {
_contentLength = len;
_hasContentLength = true;
}
////////////////////////////////////////////////////////////////////////////////
@ -230,6 +239,7 @@ namespace triagens {
int _returnCode;
string _returnMessage;
size_t _contentLength;
bool _hasContentLength;
bool _chunked;
bool _deflated;

View File

@ -274,7 +274,7 @@ bool SslClientConnection::writeClientConnection (void* buffer, size_t length, si
////////////////////////////////////////////////////////////////////////////////
bool SslClientConnection::readClientConnection (StringBuffer& stringBuffer) {
if (_ssl == 0) {
if (_ssl == 0 || ! _isConnected) {
return false;
}
@ -285,6 +285,7 @@ bool SslClientConnection::readClientConnection (StringBuffer& stringBuffer) {
return false;
}
again:
int lenRead = SSL_read(_ssl, stringBuffer.end(), READBUFFER_SIZE - 1);
switch (SSL_get_error(_ssl, lenRead)) {
@ -294,9 +295,12 @@ bool SslClientConnection::readClientConnection (StringBuffer& stringBuffer) {
case SSL_ERROR_ZERO_RETURN:
SSL_shutdown(_ssl);
_isConnected = false;
return true;
case SSL_ERROR_WANT_READ:
goto again;
case SSL_ERROR_WANT_WRITE:
case SSL_ERROR_WANT_CONNECT:
case SSL_ERROR_SYSCALL:
@ -326,7 +330,43 @@ bool SslClientConnection::readable () {
// which are available inside ssl for reading.
// ...........................................................................
return (SSL_pending(_ssl) > 0);
if (SSL_pending(_ssl) > 0) {
return true;
}
if (prepare(0.0, false)) {
return checkSocket();
}
return false;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief return whether the socket is workable
////////////////////////////////////////////////////////////////////////////////
bool SslClientConnection::checkSocket () {
int so_error = -1;
socklen_t len = sizeof so_error;
assert(_socket.fileHandle > 0);
int res = getsockopt(_socket.fileHandle, SOL_SOCKET, SO_ERROR, (char*)(&so_error), &len);
if (res != TRI_ERROR_NO_ERROR) {
_isConnected = false;
TRI_set_errno(errno);
return false;
}
if (so_error == 0) {
return true;
}
TRI_set_errno(so_error);
_isConnected = false;
return false;
}
////////////////////////////////////////////////////////////////////////////////

View File

@ -131,6 +131,12 @@ namespace triagens {
bool readable ();
////////////////////////////////////////////////////////////////////////////////
/// @brief return whether the socket is still workable
////////////////////////////////////////////////////////////////////////////////
bool checkSocket ();
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////