1
0
Fork 0

Merge branch 'devel' of github.com:triAGENS/ArangoDB into devel

This commit is contained in:
Michael Hackstein 2014-03-06 17:53:52 +01:00
commit a59b4f7767
9 changed files with 46 additions and 44 deletions

View File

@ -38,7 +38,7 @@ var base64Encode = require("internal").base64Encode;
// Our default configurations: // Our default configurations:
var PlannerLocalDefaults = { var PlannerLocalDefaults = {
"agencyPrefix" : "meier", "agencyPrefix" : "arango",
"numberOfAgents" : 1, "numberOfAgents" : 1,
"numberOfDBservers" : 2, "numberOfDBservers" : 2,
"startSecondaries" : false, "startSecondaries" : false,
@ -327,7 +327,7 @@ function fillConfigWithDefaults (config, defaultConfig) {
/// default values: /// default values:
/// ///
/// { /// {
/// "agencyPrefix" : "meier", /// "agencyPrefix" : "arango",
/// "numberOfAgents" : 1, /// "numberOfAgents" : 1,
/// "numberOfDBservers" : 2, /// "numberOfDBservers" : 2,
/// "startSecondaries" : false, /// "startSecondaries" : false,

View File

@ -175,7 +175,7 @@
#define TRI_CONNECT_AI_FLAGS AI_PASSIVE | AI_NUMERICSERV | AI_ALL #define TRI_CONNECT_AI_FLAGS AI_PASSIVE | AI_NUMERICSERV | AI_ALL
#define INVALID_SOCKET -1 #define TRI_INVALID_SOCKET -1
#define TRI_CLOSE_SOCKET TRI_closesocket #define TRI_CLOSE_SOCKET TRI_closesocket
#define TRI_READ_SOCKET(a,b,c,d) TRI_readsocket((a), (b), (c), (d)) #define TRI_READ_SOCKET(a,b,c,d) TRI_readsocket((a), (b), (c), (d))
@ -313,7 +313,7 @@
#define TRI_CONNECT_AI_FLAGS AI_PASSIVE | AI_NUMERICSERV #define TRI_CONNECT_AI_FLAGS AI_PASSIVE | AI_NUMERICSERV
#define INVALID_SOCKET -1 #define TRI_INVALID_SOCKET -1
#define TRI_CLOSE_SOCKET TRI_closesocket #define TRI_CLOSE_SOCKET TRI_closesocket
#define TRI_READ_SOCKET(a,b,c,d) TRI_readsocket((a), (b), (c), (d)) #define TRI_READ_SOCKET(a,b,c,d) TRI_readsocket((a), (b), (c), (d))
@ -469,7 +469,7 @@
#define TRI_CONNECT_AI_FLAGS AI_PASSIVE | AI_NUMERICSERV | AI_ALL #define TRI_CONNECT_AI_FLAGS AI_PASSIVE | AI_NUMERICSERV | AI_ALL
#define INVALID_SOCKET -1 #define TRI_INVALID_SOCKET -1
#define TRI_CLOSE_SOCKET TRI_closesocket #define TRI_CLOSE_SOCKET TRI_closesocket
#define TRI_READ_SOCKET(a,b,c,d) TRI_readsocket((a), (b), (c), (d)) #define TRI_READ_SOCKET(a,b,c,d) TRI_readsocket((a), (b), (c), (d))
@ -679,6 +679,8 @@ typedef unsigned char bool;
#define TRI_CONNECT_AI_FLAGS AI_PASSIVE | AI_NUMERICSERV | AI_ALL #define TRI_CONNECT_AI_FLAGS AI_PASSIVE | AI_NUMERICSERV | AI_ALL
#define TRI_INVALID_SOCKET INVALID_SOCKET
#define TRI_CLOSE_SOCKET TRI_closesocket #define TRI_CLOSE_SOCKET TRI_closesocket
#define TRI_READ_SOCKET(a,b,c,d) TRI_readsocket((a), (b), (c), (d)) #define TRI_READ_SOCKET(a,b,c,d) TRI_readsocket((a), (b), (c), (d))
#define TRI_WRITE_SOCKET(a,b,c,d) TRI_writesocket((a), (b), (c), (d)) #define TRI_WRITE_SOCKET(a,b,c,d) TRI_writesocket((a), (b), (c), (d))

View File

@ -49,10 +49,10 @@
/// @brief closes a socket /// @brief closes a socket
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int TRI_closesocket(TRI_socket_t s) { int TRI_closesocket (TRI_socket_t s) {
int res = 0; int res = 0;
#ifdef _WIN32 #ifdef _WIN32
if (s.fileDescriptor != INVALID_SOCKET) { if (s.fileDescriptor != -1) {
res = _close(s.fileDescriptor); res = _close(s.fileDescriptor);
/* /*
To close a file opened with _open_osfhandle, call _close. To close a file opened with _open_osfhandle, call _close.
@ -60,7 +60,7 @@ int TRI_closesocket(TRI_socket_t s) {
so it is not necessary to call the Win32 function CloseHandle on the original handle. so it is not necessary to call the Win32 function CloseHandle on the original handle.
*/ */
} }
else if (s.fileHandle != INVALID_SOCKET) { else if (s.fileHandle != TRI_INVALID_SOCKET) {
res = shutdown(s.fileHandle, SD_SEND); res = shutdown(s.fileHandle, SD_SEND);
if (res != 0) { if (res != 0) {
LOG_WARNING("socket shutdown error: %d", WSAGetLastError()); LOG_WARNING("socket shutdown error: %d", WSAGetLastError());
@ -78,7 +78,7 @@ int TRI_closesocket(TRI_socket_t s) {
} }
} }
#else #else
if (s.fileDescriptor != INVALID_SOCKET) { if (s.fileDescriptor != TRI_INVALID_SOCKET) {
res = close(s.fileDescriptor); res = close(s.fileDescriptor);
} }
#endif #endif
@ -86,7 +86,7 @@ int TRI_closesocket(TRI_socket_t s) {
} }
int TRI_readsocket(TRI_socket_t s, void* buffer, size_t numBytesToRead, int flags) { int TRI_readsocket (TRI_socket_t s, void* buffer, size_t numBytesToRead, int flags) {
int res; int res;
#ifdef _WIN32 #ifdef _WIN32
res = recv(s.fileHandle, (char*)(buffer), (int)(numBytesToRead), flags); res = recv(s.fileHandle, (char*)(buffer), (int)(numBytesToRead), flags);
@ -97,7 +97,7 @@ int TRI_readsocket(TRI_socket_t s, void* buffer, size_t numBytesToRead, int flag
} }
int TRI_writesocket(TRI_socket_t s, const void* buffer, size_t numBytesToWrite, int flags) { int TRI_writesocket (TRI_socket_t s, const void* buffer, size_t numBytesToWrite, int flags) {
int res; int res;
#ifdef _WIN32 #ifdef _WIN32
res = send(s.fileHandle, (const char*)(buffer), (int)(numBytesToWrite), flags); res = send(s.fileHandle, (const char*)(buffer), (int)(numBytesToWrite), flags);
@ -147,7 +147,7 @@ bool TRI_SetNonBlockingSocket (TRI_socket_t s) {
int res; int res;
DWORD ul = 1; DWORD ul = 1;
res = ioctlsocket(s.fileHandle, FIONBIO, &ul); res = ioctlsocket(s.fileHandle, FIONBIO, &ul);
return (res != INVALID_SOCKET); return (res == 0);
} }
#else #else

View File

@ -58,15 +58,6 @@ extern "C" {
/// @{ /// @{
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief invalid socket
////////////////////////////////////////////////////////////////////////////////
#ifndef INVALID_SOCKET
#define INVALID_SOCKET (-1)
#endif
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief socket types /// @brief socket types
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -103,8 +94,8 @@ extern "C" {
static inline TRI_socket_t TRI_socket (int domain, int type, int protocol) { static inline TRI_socket_t TRI_socket (int domain, int type, int protocol) {
TRI_socket_t res; TRI_socket_t res;
#ifdef _WIN32 #ifdef _WIN32
res.fileHandle = socket(domain, type, protocol); res.fileHandle = socket(domain, type, protocol);
res.fileDescriptor = INVALID_SOCKET; res.fileDescriptor = -1;
#else #else
res.fileDescriptor = socket(domain, type, protocol); res.fileDescriptor = socket(domain, type, protocol);
#endif #endif
@ -131,8 +122,8 @@ static inline TRI_socket_t TRI_accept (TRI_socket_t s, struct sockaddr* address,
socklen_t* address_len) { socklen_t* address_len) {
TRI_socket_t res; TRI_socket_t res;
#ifdef _WIN32 #ifdef _WIN32
res.fileHandle = accept(s.fileHandle, address, address_len); res.fileHandle = accept(s.fileHandle, address, address_len);
res.fileDescriptor = INVALID_SOCKET; res.fileDescriptor = -1;
#else #else
res.fileDescriptor = accept(s.fileDescriptor, address, address_len); res.fileDescriptor = accept(s.fileDescriptor, address, address_len);
#endif #endif
@ -231,9 +222,9 @@ static inline int TRI_setsockopt (TRI_socket_t s, int level, int optname,
static inline bool TRI_isvalidsocket (TRI_socket_t s) { static inline bool TRI_isvalidsocket (TRI_socket_t s) {
#ifdef _WIN32 #ifdef _WIN32
return s.fileHandle != INVALID_SOCKET; return s.fileHandle != TRI_INVALID_SOCKET;
#else #else
return s.fileDescriptor != INVALID_SOCKET; return s.fileDescriptor != TRI_INVALID_SOCKET;
#endif #endif
} }
@ -243,10 +234,10 @@ static inline bool TRI_isvalidsocket (TRI_socket_t s) {
static inline void TRI_invalidatesocket (TRI_socket_t* s) { static inline void TRI_invalidatesocket (TRI_socket_t* s) {
#ifdef _WIN32 #ifdef _WIN32
s->fileHandle = INVALID_SOCKET; s->fileHandle = TRI_INVALID_SOCKET;
s->fileDescriptor = INVALID_SOCKET; s->fileDescriptor = -1;
#else #else
s->fileDescriptor = INVALID_SOCKET; s->fileDescriptor = TRI_INVALID_SOCKET;
#endif #endif
} }
@ -257,13 +248,15 @@ static inline void TRI_invalidatesocket (TRI_socket_t* s) {
/// the right thing we need in all but one places. /// the right thing we need in all but one places.
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
static inline int TRI_get_fd_or_handle_of_socket (TRI_socket_t s) {
#ifdef _WIN32 #ifdef _WIN32
return (int)(s.fileHandle); static inline SOCKET TRI_get_fd_or_handle_of_socket (TRI_socket_t s) {
#else return s.fileHandle;
return s.fileDescriptor;
#endif
} }
#else
static inline int TRI_get_fd_or_handle_of_socket (TRI_socket_t s) {
return s.fileDescriptor;
}
#endif
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief closes an open socket /// @brief closes an open socket

View File

@ -103,7 +103,7 @@ namespace triagens {
_maximalHeaderSize(0), _maximalHeaderSize(0),
_maximalBodySize(0) { _maximalBodySize(0) {
LOG_TRACE("connection established, client %d, server ip %s, server port %d, client ip %s, client port %d", LOG_TRACE("connection established, client %d, server ip %s, server port %d, client ip %s, client port %d",
TRI_get_fd_or_handle_of_socket(socket), (int) TRI_get_fd_or_handle_of_socket(socket),
_connectionInfo.serverAddress.c_str(), _connectionInfo.serverAddress.c_str(),
(int) _connectionInfo.serverPort, (int) _connectionInfo.serverPort,
_connectionInfo.clientAddress.c_str(), _connectionInfo.clientAddress.c_str(),

View File

@ -276,7 +276,7 @@ namespace triagens {
LOG_DEBUG("trying to establish secure connection"); LOG_DEBUG("trying to establish secure connection");
// convert in a SSL BIO structure // convert in a SSL BIO structure
BIO * sbio = BIO_new_socket(TRI_get_fd_or_handle_of_socket(socket), BIO_NOCLOSE); BIO * sbio = BIO_new_socket((int) TRI_get_fd_or_handle_of_socket(socket), BIO_NOCLOSE);
if (sbio == 0) { if (sbio == 0) {
LOG_WARNING("cannot build new SSL BIO: %s", triagens::basics::lastSSLError().c_str()); LOG_WARNING("cannot build new SSL BIO: %s", triagens::basics::lastSSLError().c_str());

View File

@ -113,11 +113,12 @@ bool ListenTask::setup (Scheduler* scheduler, EventLoop loop) {
return false; return false;
} }
_listenSocket.fileDescriptor = _open_osfhandle (_listenSocket.fileHandle, 0); int res = _open_osfhandle (_listenSocket.fileHandle, 0);
if (_listenSocket.fileDescriptor == INVALID_SOCKET) {
if (res == - 1) {
LOG_ERROR("In ListenTask::setup could not convert socket handle to socket descriptor -- _open_osfhandle(...) failed"); LOG_ERROR("In ListenTask::setup could not convert socket handle to socket descriptor -- _open_osfhandle(...) failed");
int res = closesocket(_listenSocket.fileHandle); res = TRI_CLOSE_SOCKET(_listenSocket);
if (res != 0) { if (res != 0) {
res = WSAGetLastError(); res = WSAGetLastError();
@ -126,6 +127,8 @@ bool ListenTask::setup (Scheduler* scheduler, EventLoop loop) {
TRI_invalidatesocket(&_listenSocket); TRI_invalidatesocket(&_listenSocket);
return false; return false;
} }
_listenSocket.fileDescriptor = res;
#endif #endif

View File

@ -429,18 +429,22 @@ bool SocketTask::setup (Scheduler* scheduler, EventLoop loop) {
return false; return false;
} }
_commSocket.fileDescriptor = _open_osfhandle (_commSocket.fileHandle, 0); int res = _open_osfhandle(_commSocket.fileHandle, 0);
if (_commSocket.fileDescriptor == -1) {
if (res == -1) {
LOG_ERROR("In SocketTask::setup could not convert socket handle to socket descriptor -- _open_osfhandle(...) failed"); LOG_ERROR("In SocketTask::setup could not convert socket handle to socket descriptor -- _open_osfhandle(...) failed");
int res = closesocket(_commSocket.fileHandle); res = TRI_CLOSE_SOCKET(_commSocket);
if (res != 0) { if (res != 0) {
res = WSAGetLastError(); res = WSAGetLastError();
LOG_ERROR("In SocketTask::setup closesocket(...) failed with error code: %d", (int) res); LOG_ERROR("In SocketTask::setup closesocket(...) failed with error code: %d", (int) res);
} }
TRI_invalidatesocket(&_commSocket); TRI_invalidatesocket(&_commSocket);
return false; return false;
} }
_commSocket.fileDescriptor = res;
#endif #endif

View File

@ -162,7 +162,7 @@ bool SslClientConnection::connectSocket () {
return false; return false;
} }
if (SSL_set_fd(_ssl, TRI_get_fd_or_handle_of_socket(_socket)) != 1) { if (SSL_set_fd(_ssl, (int) TRI_get_fd_or_handle_of_socket(_socket)) != 1) {
_endpoint->disconnect(); _endpoint->disconnect();
SSL_free(_ssl); SSL_free(_ssl);
_ssl = 0; _ssl = 0;