mirror of https://gitee.com/bigwinds/arangodb
Merge branch 'devel' of https://github.com/triAGENS/ArangoDB into devel
This commit is contained in:
commit
6fde7e2f27
|
@ -151,8 +151,8 @@ unittests-boost: UnitTests/basics_suite UnitTests/geo_suite
|
||||||
|
|
||||||
noinst_PROGRAMS += UnitTests/basics_suite UnitTests/geo_suite
|
noinst_PROGRAMS += UnitTests/basics_suite UnitTests/geo_suite
|
||||||
|
|
||||||
UnitTests_basics_suite_CPPFLAGS = -I@top_srcdir@/arangod -I@top_srcdir@/lib
|
UnitTests_basics_suite_CPPFLAGS = -I@top_srcdir@/arangod -I@top_srcdir@/lib @ICU_CPPFLAGS@
|
||||||
UnitTests_basics_suite_LDADD = -L@top_builddir@/lib -larango -lboost_unit_test_framework
|
UnitTests_basics_suite_LDADD = -L@top_builddir@/lib -larango -lboost_unit_test_framework @ICU_LDFLAGS@
|
||||||
UnitTests_basics_suite_DEPENDENCIES = @top_builddir@/lib/libarango.a
|
UnitTests_basics_suite_DEPENDENCIES = @top_builddir@/lib/libarango.a
|
||||||
|
|
||||||
UnitTests_basics_suite_SOURCES = \
|
UnitTests_basics_suite_SOURCES = \
|
||||||
|
|
|
@ -417,7 +417,8 @@ bool TRI_AddVariableScopeAql (TRI_aql_context_t* const context,
|
||||||
TRI_aql_node_t* const definingNode) {
|
TRI_aql_node_t* const definingNode) {
|
||||||
TRI_aql_variable_t* variable;
|
TRI_aql_variable_t* variable;
|
||||||
TRI_aql_scope_t* scope;
|
TRI_aql_scope_t* scope;
|
||||||
|
void* result;
|
||||||
|
|
||||||
assert(context);
|
assert(context);
|
||||||
assert(name);
|
assert(name);
|
||||||
|
|
||||||
|
@ -431,8 +432,10 @@ bool TRI_AddVariableScopeAql (TRI_aql_context_t* const context,
|
||||||
}
|
}
|
||||||
|
|
||||||
scope = CurrentScope(context);
|
scope = CurrentScope(context);
|
||||||
assert(! TRI_InsertKeyAssociativePointer(&scope->_variables, variable->_name, (void*) variable, false));
|
|
||||||
|
|
||||||
|
result = TRI_InsertKeyAssociativePointer(&scope->_variables, variable->_name, (void*) variable, false);
|
||||||
|
assert(result == NULL);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,6 @@ int main (int argc, char* argv[]) {
|
||||||
// ...........................................................................
|
// ...........................................................................
|
||||||
// TODO: need a terminate function for windows to be called and cleanup
|
// TODO: need a terminate function for windows to be called and cleanup
|
||||||
// any windows specific stuff.
|
// any windows specific stuff.
|
||||||
// TODO: find the memory deallocation/allocation error
|
|
||||||
// ...........................................................................
|
// ...........................................................................
|
||||||
|
|
||||||
res = finaliseWindows(TRI_WIN_FINAL_WSASTARTUP_FUNCTION_CALL, 0);
|
res = finaliseWindows(TRI_WIN_FINAL_WSASTARTUP_FUNCTION_CALL, 0);
|
||||||
|
|
|
@ -420,6 +420,16 @@ void ArangoClient::parse (ProgramOptions& options,
|
||||||
/// @brief starts pager
|
/// @brief starts pager
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
|
||||||
|
void ArangoClient::startPager () {
|
||||||
|
// not supported
|
||||||
|
if (!_usePager || _usePager) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
void ArangoClient::startPager () {
|
void ArangoClient::startPager () {
|
||||||
if (! _usePager || _outputPager == "" || _outputPager == "stdout" || _outputPager == "-") {
|
if (! _usePager || _outputPager == "" || _outputPager == "stdout" || _outputPager == "-") {
|
||||||
_pager = stdout;
|
_pager = stdout;
|
||||||
|
@ -434,10 +444,21 @@ void ArangoClient::startPager () {
|
||||||
_usePager = false;
|
_usePager = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief stops pager
|
/// @brief stops pager
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
#ifdef _WIN32
|
||||||
|
|
||||||
|
void ArangoClient::stopPager () {
|
||||||
|
// not supported
|
||||||
|
if (!_usePager || _usePager) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
void ArangoClient::stopPager () {
|
void ArangoClient::stopPager () {
|
||||||
if (_pager != stdout) {
|
if (_pager != stdout) {
|
||||||
|
@ -446,6 +467,8 @@ void ArangoClient::stopPager () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief print to pager
|
/// @brief print to pager
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -59,7 +59,7 @@ namespace triagens {
|
||||||
/// constructor and destructor
|
/// constructor and destructor
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
ImportHelper::ImportHelper (httpclient::SimpleHttpClient* _client, size_t maxUploadSize)
|
ImportHelper::ImportHelper (httpclient::SimpleHttpClient* _client, uint64_t maxUploadSize)
|
||||||
: _client(_client),
|
: _client(_client),
|
||||||
_maxUploadSize(maxUploadSize),
|
_maxUploadSize(maxUploadSize),
|
||||||
_lineBuffer(TRI_UNKNOWN_MEM_ZONE),
|
_lineBuffer(TRI_UNKNOWN_MEM_ZONE),
|
||||||
|
@ -106,7 +106,7 @@ namespace triagens {
|
||||||
fd = STDIN_FILENO;
|
fd = STDIN_FILENO;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fd = open(fileName.c_str(), O_RDONLY);
|
fd = TRI_OPEN(fileName.c_str(), O_RDONLY);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
|
@ -154,7 +154,7 @@ namespace triagens {
|
||||||
while (! _hasError) {
|
while (! _hasError) {
|
||||||
v8::HandleScope scope;
|
v8::HandleScope scope;
|
||||||
|
|
||||||
ssize_t n = read(fd, buffer, sizeof(buffer));
|
ssize_t n = TRI_READ(fd, buffer, sizeof(buffer));
|
||||||
|
|
||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
TRI_Free(TRI_UNKNOWN_MEM_ZONE, separator);
|
TRI_Free(TRI_UNKNOWN_MEM_ZONE, separator);
|
||||||
|
@ -179,7 +179,7 @@ namespace triagens {
|
||||||
TRI_Free(TRI_UNKNOWN_MEM_ZONE, eol);
|
TRI_Free(TRI_UNKNOWN_MEM_ZONE, eol);
|
||||||
|
|
||||||
if (fileName != "-") {
|
if (fileName != "-") {
|
||||||
close(fd);
|
TRI_CLOSE(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
_outputBuffer.clear();
|
_outputBuffer.clear();
|
||||||
|
@ -203,7 +203,7 @@ namespace triagens {
|
||||||
fd = STDIN_FILENO;
|
fd = STDIN_FILENO;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fd = open(fileName.c_str(), O_RDONLY);
|
fd = TRI_OPEN(fileName.c_str(), O_RDONLY);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
|
@ -215,7 +215,7 @@ namespace triagens {
|
||||||
bool isArray = false;
|
bool isArray = false;
|
||||||
|
|
||||||
while (! _hasError) {
|
while (! _hasError) {
|
||||||
ssize_t n = read(fd, buffer, sizeof(buffer));
|
ssize_t n = TRI_READ(fd, buffer, sizeof(buffer));
|
||||||
|
|
||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
_errorMessage = TRI_LAST_ERROR_STR;
|
_errorMessage = TRI_LAST_ERROR_STR;
|
||||||
|
@ -260,7 +260,7 @@ namespace triagens {
|
||||||
_numberLines = _numberError + _numberOk;
|
_numberLines = _numberError + _numberOk;
|
||||||
|
|
||||||
if (fileName != "-") {
|
if (fileName != "-") {
|
||||||
close(fd);
|
TRI_CLOSE(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
_outputBuffer.clear();
|
_outputBuffer.clear();
|
||||||
|
|
|
@ -52,6 +52,10 @@
|
||||||
#include "BasicsC/csv.h"
|
#include "BasicsC/csv.h"
|
||||||
#include "Basics/StringBuffer.h"
|
#include "Basics/StringBuffer.h"
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include "BasicsC/win-utils.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace triagens {
|
namespace triagens {
|
||||||
namespace httpclient {
|
namespace httpclient {
|
||||||
class SimpleHttpClient;
|
class SimpleHttpClient;
|
||||||
|
@ -87,7 +91,7 @@ namespace triagens {
|
||||||
/// @brief constructor
|
/// @brief constructor
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
ImportHelper (httpclient::SimpleHttpClient* client, size_t maxUploadSize);
|
ImportHelper (httpclient::SimpleHttpClient* client, uint64_t maxUploadSize);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief destructor
|
/// @brief destructor
|
||||||
|
@ -202,7 +206,7 @@ namespace triagens {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
httpclient::SimpleHttpClient* _client;
|
httpclient::SimpleHttpClient* _client;
|
||||||
size_t _maxUploadSize;
|
uint64_t _maxUploadSize;
|
||||||
|
|
||||||
string _separator;
|
string _separator;
|
||||||
string _quote;
|
string _quote;
|
||||||
|
|
|
@ -81,7 +81,9 @@ V8ClientConnection::V8ClientConnection (Endpoint* endpoint,
|
||||||
_client(0),
|
_client(0),
|
||||||
_httpResult(0) {
|
_httpResult(0) {
|
||||||
|
|
||||||
|
|
||||||
_connection = GeneralClientConnection::factory(endpoint, requestTimeout, connectTimeout, numRetries);
|
_connection = GeneralClientConnection::factory(endpoint, requestTimeout, connectTimeout, numRetries);
|
||||||
|
|
||||||
if (_connection == 0) {
|
if (_connection == 0) {
|
||||||
throw "out of memory";
|
throw "out of memory";
|
||||||
}
|
}
|
||||||
|
|
|
@ -187,6 +187,33 @@ static void ParseProgramOptions (int argc, char* argv[]) {
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
int main (int argc, char* argv[]) {
|
int main (int argc, char* argv[]) {
|
||||||
|
|
||||||
|
int ret = EXIT_SUCCESS;
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
|
||||||
|
// ...........................................................................
|
||||||
|
// Call this function to do various initialistions for windows only
|
||||||
|
// ...........................................................................
|
||||||
|
|
||||||
|
// ...........................................................................
|
||||||
|
// Uncomment this to call this for extended debug information.
|
||||||
|
// If you familiar with valgrind ... then this is not like that, however
|
||||||
|
// you do get some similar functionality.
|
||||||
|
// ...........................................................................
|
||||||
|
//res = initialiseWindows(TRI_WIN_INITIAL_SET_DEBUG_FLAG, 0);
|
||||||
|
|
||||||
|
ret = initialiseWindows(TRI_WIN_INITIAL_SET_INVALID_HANLE_HANDLER, 0);
|
||||||
|
if (ret != 0) {
|
||||||
|
_exit(1);
|
||||||
|
}
|
||||||
|
ret = initialiseWindows(TRI_WIN_INITIAL_WSASTARTUP_FUNCTION_CALL, 0);
|
||||||
|
if (ret != 0) {
|
||||||
|
_exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
TRIAGENS_C_INITIALISE(argc, argv);
|
TRIAGENS_C_INITIALISE(argc, argv);
|
||||||
TRIAGENS_REST_INITIALISE(argc, argv);
|
TRIAGENS_REST_INITIALISE(argc, argv);
|
||||||
|
|
||||||
|
@ -339,7 +366,18 @@ int main (int argc, char* argv[]) {
|
||||||
|
|
||||||
TRIAGENS_REST_SHUTDOWN;
|
TRIAGENS_REST_SHUTDOWN;
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
#ifdef _WIN32
|
||||||
|
|
||||||
|
// ...........................................................................
|
||||||
|
// TODO: need a terminate function for windows to be called and cleanup
|
||||||
|
// any windows specific stuff.
|
||||||
|
// ...........................................................................
|
||||||
|
|
||||||
|
ret = finaliseWindows(TRI_WIN_FINAL_WSASTARTUP_FUNCTION_CALL, 0);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -1061,11 +1061,37 @@ static bool RunJsLint (v8::Handle<v8::Context> context) {
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
int main (int argc, char* argv[]) {
|
int main (int argc, char* argv[]) {
|
||||||
|
|
||||||
|
int ret = EXIT_SUCCESS;
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
|
||||||
|
// ...........................................................................
|
||||||
|
// Call this function to do various initialistions for windows only
|
||||||
|
// ...........................................................................
|
||||||
|
|
||||||
|
// ...........................................................................
|
||||||
|
// Uncomment this to call this for extended debug information.
|
||||||
|
// If you familiar with valgrind ... then this is not like that, however
|
||||||
|
// you do get some similar functionality.
|
||||||
|
// ...........................................................................
|
||||||
|
//res = initialiseWindows(TRI_WIN_INITIAL_SET_DEBUG_FLAG, 0);
|
||||||
|
|
||||||
|
ret = initialiseWindows(TRI_WIN_INITIAL_SET_INVALID_HANLE_HANDLER, 0);
|
||||||
|
if (ret != 0) {
|
||||||
|
_exit(1);
|
||||||
|
}
|
||||||
|
ret = initialiseWindows(TRI_WIN_INITIAL_WSASTARTUP_FUNCTION_CALL, 0);
|
||||||
|
if (ret != 0) {
|
||||||
|
_exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
TRIAGENS_C_INITIALISE(argc, argv);
|
TRIAGENS_C_INITIALISE(argc, argv);
|
||||||
TRIAGENS_REST_INITIALISE(argc, argv);
|
TRIAGENS_REST_INITIALISE(argc, argv);
|
||||||
|
|
||||||
TRI_InitialiseLogging(false);
|
TRI_InitialiseLogging(false);
|
||||||
int ret = EXIT_SUCCESS;
|
|
||||||
|
|
||||||
BaseClient.setEndpointString(Endpoint::getDefaultEndpoint());
|
BaseClient.setEndpointString(Endpoint::getDefaultEndpoint());
|
||||||
|
|
||||||
|
@ -1088,6 +1114,7 @@ int main (int argc, char* argv[]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (useServer) {
|
if (useServer) {
|
||||||
|
|
||||||
BaseClient.createEndpoint();
|
BaseClient.createEndpoint();
|
||||||
|
|
||||||
if (BaseClient.endpointServer() == 0) {
|
if (BaseClient.endpointServer() == 0) {
|
||||||
|
@ -1095,6 +1122,7 @@ int main (int argc, char* argv[]) {
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ClientConnection = CreateConnection();
|
ClientConnection = CreateConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1203,7 +1231,69 @@ int main (int argc, char* argv[]) {
|
||||||
// .............................................................................
|
// .............................................................................
|
||||||
|
|
||||||
// http://www.network-science.de/ascii/ Font: ogre
|
// http://www.network-science.de/ascii/ Font: ogre
|
||||||
|
|
||||||
if (! BaseClient.quiet()) {
|
if (! BaseClient.quiet()) {
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
|
||||||
|
// .............................................................................
|
||||||
|
// Quick hack for windows
|
||||||
|
// .............................................................................
|
||||||
|
|
||||||
|
|
||||||
|
if (BaseClient.colors()) {
|
||||||
|
int greenColour = FOREGROUND_GREEN | FOREGROUND_INTENSITY;
|
||||||
|
int redColour = FOREGROUND_RED | FOREGROUND_INTENSITY;
|
||||||
|
int defaultColour = 0;
|
||||||
|
CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
|
||||||
|
bool ok;
|
||||||
|
|
||||||
|
ok = GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbiInfo);
|
||||||
|
if (ok) {
|
||||||
|
defaultColour = csbiInfo.wAttributes;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetConsoleOutputCP(65001);
|
||||||
|
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), greenColour);
|
||||||
|
printf(" ");
|
||||||
|
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), redColour);
|
||||||
|
printf(" _ ");
|
||||||
|
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), defaultColour);
|
||||||
|
printf("\n");
|
||||||
|
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), greenColour);
|
||||||
|
printf(" __ _ _ __ __ _ _ __ __ _ ___ ");
|
||||||
|
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), redColour);
|
||||||
|
printf(" ___| |__ ");
|
||||||
|
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), defaultColour);
|
||||||
|
printf("\n");
|
||||||
|
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), greenColour);
|
||||||
|
printf(" / _` | '__/ _` | '_ \\ / _` |/ _ \\");
|
||||||
|
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), redColour);
|
||||||
|
printf("/ __| '_ \\ ");
|
||||||
|
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), defaultColour);
|
||||||
|
printf("\n");
|
||||||
|
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), greenColour);
|
||||||
|
printf("| (_| | | | (_| | | | | (_| | (_) ");
|
||||||
|
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), redColour);
|
||||||
|
printf("\\__ \\ | | |");
|
||||||
|
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), defaultColour);
|
||||||
|
printf("\n");
|
||||||
|
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), greenColour);
|
||||||
|
printf(" \\__,_|_| \\__,_|_| |_|\\__, |\\___/");
|
||||||
|
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), redColour);
|
||||||
|
printf("|___/_| |_|");
|
||||||
|
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), defaultColour);
|
||||||
|
printf("\n");
|
||||||
|
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), greenColour);
|
||||||
|
printf(" |___/ ");
|
||||||
|
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), redColour);
|
||||||
|
printf(" ");
|
||||||
|
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), defaultColour);
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
char const* g = TRI_SHELL_COLOR_GREEN;
|
char const* g = TRI_SHELL_COLOR_GREEN;
|
||||||
char const* r = TRI_SHELL_COLOR_RED;
|
char const* r = TRI_SHELL_COLOR_RED;
|
||||||
char const* z = TRI_SHELL_COLOR_RESET;
|
char const* z = TRI_SHELL_COLOR_RESET;
|
||||||
|
@ -1222,6 +1312,7 @@ int main (int argc, char* argv[]) {
|
||||||
printf("%s| (_| | | | (_| | | | | (_| | (_) %s\\__ \\ | | |%s\n", g, r, z);
|
printf("%s| (_| | | | (_| | | | | (_| | (_) %s\\__ \\ | | |%s\n", g, r, z);
|
||||||
printf("%s \\__,_|_| \\__,_|_| |_|\\__, |\\___/%s|___/_| |_|%s\n", g, r, z);
|
printf("%s \\__,_|_| \\__,_|_| |_|\\__, |\\___/%s|___/_| |_|%s\n", g, r, z);
|
||||||
printf("%s |___/ %s %s\n", g, r, z);
|
printf("%s |___/ %s %s\n", g, r, z);
|
||||||
|
#endif
|
||||||
|
|
||||||
cout << endl << "Welcome to arangosh " << TRIAGENS_VERSION << ". Copyright (c) 2012 triAGENS GmbH" << endl;
|
cout << endl << "Welcome to arangosh " << TRIAGENS_VERSION << ". Copyright (c) 2012 triAGENS GmbH" << endl;
|
||||||
|
|
||||||
|
@ -1308,6 +1399,7 @@ int main (int argc, char* argv[]) {
|
||||||
|
|
||||||
BaseClient.openLog();
|
BaseClient.openLog();
|
||||||
|
|
||||||
|
|
||||||
// .............................................................................
|
// .............................................................................
|
||||||
// run normal shell
|
// run normal shell
|
||||||
// .............................................................................
|
// .............................................................................
|
||||||
|
@ -1359,6 +1451,17 @@ int main (int argc, char* argv[]) {
|
||||||
|
|
||||||
TRIAGENS_REST_SHUTDOWN;
|
TRIAGENS_REST_SHUTDOWN;
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
|
||||||
|
// ...........................................................................
|
||||||
|
// TODO: need a terminate function for windows to be called and cleanup
|
||||||
|
// any windows specific stuff.
|
||||||
|
// ...........................................................................
|
||||||
|
|
||||||
|
ret = finaliseWindows(TRI_WIN_FINAL_WSASTARTUP_FUNCTION_CALL, 0);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,15 @@
|
||||||
|
/*jslint indent: 2, nomen: true, maxlen: 100, sloppy: true, plusplus: true */
|
||||||
|
/*global _, require, db, exports */
|
||||||
|
|
||||||
var Frank,
|
var Frank,
|
||||||
baseMiddleware,
|
BaseMiddleware,
|
||||||
_ = require("underscore"),
|
_ = require("underscore"),
|
||||||
internal = {};
|
internal = {};
|
||||||
|
|
||||||
internal.createUrlObject = function (url, constraint, method) {
|
internal.createUrlObject = function (url, constraint, method) {
|
||||||
var urlObject = {};
|
var urlObject = {};
|
||||||
|
|
||||||
if(!_.isString(url)) {
|
if (!_.isString(url)) {
|
||||||
throw "URL has to be a String";
|
throw "URL has to be a String";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,28 +40,29 @@ Frank = function (options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_.isString(templateCollection)) {
|
if (_.isString(templateCollection)) {
|
||||||
this.routingInfo.templateCollection = db._collection(templateCollection) || db._create(templateCollection);
|
this.routingInfo.templateCollection = db._collection(templateCollection) ||
|
||||||
|
db._create(templateCollection);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
_.extend(Frank.prototype, {
|
_.extend(Frank.prototype, {
|
||||||
handleRequest: function (method, route, argument1, argument2) {
|
handleRequest: function (method, route, argument1, argument2) {
|
||||||
var newRoute = {}, options, handler;
|
var newRoute = {}, options, handler;
|
||||||
|
|
||||||
if (_.isUndefined(argument2)) {
|
if (_.isUndefined(argument2)) {
|
||||||
handler = argument1;
|
handler = argument1;
|
||||||
options = {};
|
options = {};
|
||||||
} else {
|
} else {
|
||||||
options = argument1;
|
options = argument1;
|
||||||
handler = argument2;
|
handler = argument2;
|
||||||
}
|
}
|
||||||
|
|
||||||
newRoute.url = internal.createUrlObject(route, options.constraint, method);
|
newRoute.url = internal.createUrlObject(route, options.constraint, method);
|
||||||
newRoute.handler = handler;
|
newRoute.handler = handler;
|
||||||
|
|
||||||
this.routingInfo.routes.push(newRoute);
|
this.routingInfo.routes.push(newRoute);
|
||||||
},
|
},
|
||||||
|
|
||||||
head: function (route, argument1, argument2) {
|
head: function (route, argument1, argument2) {
|
||||||
this.handleRequest("head", route, argument1, argument2);
|
this.handleRequest("head", route, argument1, argument2);
|
||||||
},
|
},
|
||||||
|
@ -74,14 +78,14 @@ _.extend(Frank.prototype, {
|
||||||
put: function (route, argument1, argument2) {
|
put: function (route, argument1, argument2) {
|
||||||
this.handleRequest("put", route, argument1, argument2);
|
this.handleRequest("put", route, argument1, argument2);
|
||||||
},
|
},
|
||||||
|
|
||||||
patch: function (route, argument1, argument2) {
|
patch: function (route, argument1, argument2) {
|
||||||
this.handleRequest("patch", route, argument1, argument2);
|
this.handleRequest("patch", route, argument1, argument2);
|
||||||
},
|
},
|
||||||
|
|
||||||
delete: function (route, argument1, argument2) {
|
delete: function (route, argument1, argument2) {
|
||||||
this.handleRequest("delete", route, argument1, argument2);
|
this.handleRequest("delete", route, argument1, argument2);
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -125,7 +129,11 @@ BaseMiddleware = function (templateCollection) {
|
||||||
throw "No template collection has been provided when creating a new Frank";
|
throw "No template collection has been provided when creating a new Frank";
|
||||||
}
|
}
|
||||||
|
|
||||||
template = templateCollection.firstExample({path: "simple/path"});
|
template = templateCollection.firstExample({path: templatePath });
|
||||||
|
|
||||||
|
if (_.isNull(template)) {
|
||||||
|
throw "Template '" + templatePath + "' does not exist";
|
||||||
|
}
|
||||||
|
|
||||||
if (template.templateLanguage !== "underscore") {
|
if (template.templateLanguage !== "underscore") {
|
||||||
throw "Unknown template language '" + template.templateLanguage + "'";
|
throw "Unknown template language '" + template.templateLanguage + "'";
|
||||||
|
@ -137,6 +145,8 @@ BaseMiddleware = function (templateCollection) {
|
||||||
};
|
};
|
||||||
|
|
||||||
response = _.extend(response, responseFunctions);
|
response = _.extend(response, responseFunctions);
|
||||||
|
|
||||||
|
next();
|
||||||
};
|
};
|
||||||
|
|
||||||
return middleware;
|
return middleware;
|
||||||
|
|
|
@ -77,7 +77,7 @@ function SetRoutesFrankSpec () {
|
||||||
assertEqual(routes.length, 1);
|
assertEqual(routes.length, 1);
|
||||||
assertEqual(routes[0].url.constraint, constraint);
|
assertEqual(routes[0].url.constraint, constraint);
|
||||||
},
|
},
|
||||||
|
|
||||||
testSetMethodToHead: function () {
|
testSetMethodToHead: function () {
|
||||||
var myFunc = function () {},
|
var myFunc = function () {},
|
||||||
routes = app.routingInfo.routes;
|
routes = app.routingInfo.routes;
|
||||||
|
@ -243,6 +243,18 @@ function BaseMiddlewareWithoutTemplateSpec () {
|
||||||
}
|
}
|
||||||
|
|
||||||
assertEqual(error, "No template collection has been provided when creating a new Frank");
|
assertEqual(error, "No template collection has been provided when creating a new Frank");
|
||||||
|
},
|
||||||
|
|
||||||
|
testMiddlewareCallsTheAction: function () {
|
||||||
|
var actionWasCalled = false;
|
||||||
|
|
||||||
|
next = function () {
|
||||||
|
actionWasCalled = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
baseMiddleware(request, response, options, next);
|
||||||
|
|
||||||
|
assertTrue(actionWasCalled);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -303,11 +315,28 @@ function BaseMiddlewareWithTemplateSpec () {
|
||||||
}
|
}
|
||||||
|
|
||||||
assertEqual(error, "Unknown template language 'pirateEngine'");
|
assertEqual(error, "Unknown template language 'pirateEngine'");
|
||||||
|
},
|
||||||
|
|
||||||
|
testRenderingATemplateWithAnNotExistingTemplate: function () {
|
||||||
|
var myCollection, error, middleware;
|
||||||
|
|
||||||
|
internal.db._drop("templateTest");
|
||||||
|
myCollection = internal.db._create("templateTest");
|
||||||
|
|
||||||
|
middleware = new BaseMiddleware(myCollection);
|
||||||
|
middleware(request, response, options, next);
|
||||||
|
|
||||||
|
try {
|
||||||
|
response.render("simple/path", { username: "moonglum" });
|
||||||
|
} catch(e) {
|
||||||
|
error = e;
|
||||||
|
}
|
||||||
|
|
||||||
|
assertEqual(error, "Template 'simple/path' does not exist");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
jsunity.run(CreateFrankSpec);
|
jsunity.run(CreateFrankSpec);
|
||||||
jsunity.run(SetRoutesFrankSpec);
|
jsunity.run(SetRoutesFrankSpec);
|
||||||
jsunity.run(BaseMiddlewareWithoutTemplateSpec);
|
jsunity.run(BaseMiddlewareWithoutTemplateSpec);
|
||||||
|
|
|
@ -102,7 +102,7 @@ static TRI_read_write_lock_t FileNamesLock;
|
||||||
|
|
||||||
static ssize_t LookupElementVectorString (TRI_vector_string_t * vector, char const * element) {
|
static ssize_t LookupElementVectorString (TRI_vector_string_t * vector, char const * element) {
|
||||||
int idx = -1;
|
int idx = -1;
|
||||||
size_t i;
|
int i;
|
||||||
|
|
||||||
TRI_ReadLockReadWriteLock(&FileNamesLock);
|
TRI_ReadLockReadWriteLock(&FileNamesLock);
|
||||||
|
|
||||||
|
@ -289,6 +289,12 @@ bool TRI_IsDirectory (char const* path) {
|
||||||
/// @brief checks if path is a symbolic link
|
/// @brief checks if path is a symbolic link
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
bool TRI_IsSymbolicLink (char const* path) {
|
||||||
|
// todo : check if a file is a symbolic link - without opening the file
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#else
|
||||||
bool TRI_IsSymbolicLink (char const* path) {
|
bool TRI_IsSymbolicLink (char const* path) {
|
||||||
struct stat stbuf;
|
struct stat stbuf;
|
||||||
int res;
|
int res;
|
||||||
|
@ -297,6 +303,7 @@ bool TRI_IsSymbolicLink (char const* path) {
|
||||||
|
|
||||||
return (res == 0) && ((stbuf.st_mode & S_IFMT) == S_IFLNK);
|
return (res == 0) && ((stbuf.st_mode & S_IFMT) == S_IFLNK);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief checks if file exists
|
/// @brief checks if file exists
|
||||||
|
@ -946,6 +953,14 @@ int TRI_VerifyLockFile (char const* filename) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fd = TRI_OPEN(filename, O_RDONLY);
|
fd = TRI_OPEN(filename, O_RDONLY);
|
||||||
|
if (fd < 0) {
|
||||||
|
// this method if checking whether or not the database is locked is not suitable with the manner
|
||||||
|
// in which it is coded.
|
||||||
|
// windows assigns ownership of the file to the process for exclusive use
|
||||||
|
// the file exists, yet we can not open it, so being here we can only assume that the
|
||||||
|
// database is locked.
|
||||||
|
return TRI_ERROR_NO_ERROR;
|
||||||
|
}
|
||||||
n = TRI_READ(fd, buffer, sizeof(buffer));
|
n = TRI_READ(fd, buffer, sizeof(buffer));
|
||||||
TRI_CLOSE(fd);
|
TRI_CLOSE(fd);
|
||||||
|
|
||||||
|
@ -1091,7 +1106,11 @@ int TRI_DestroyLockFile (char const* filename) {
|
||||||
|
|
||||||
|
|
||||||
fd = TRI_OPEN(filename, O_RDWR);
|
fd = TRI_OPEN(filename, O_RDWR);
|
||||||
|
|
||||||
|
if (fd < 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// ..........................................................................
|
// ..........................................................................
|
||||||
// TODO: Use windows LockFileEx to determine if file can be locked
|
// TODO: Use windows LockFileEx to determine if file can be locked
|
||||||
// ..........................................................................
|
// ..........................................................................
|
||||||
|
|
|
@ -535,6 +535,10 @@ typedef unsigned char bool;
|
||||||
|
|
||||||
typedef SOCKET socket_t;
|
typedef SOCKET socket_t;
|
||||||
|
|
||||||
|
#define STDIN_FILENO 0;
|
||||||
|
#define STDOUT_FILENO 1;
|
||||||
|
#define STDERR_FILENO 2;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -105,16 +105,22 @@ void TRI_usleep(unsigned long waitTime) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (GetLastError() == ERROR_ALREADY_EXISTS) {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
// Set timer to wait for indicated micro seconds.
|
// Set timer to wait for indicated micro seconds.
|
||||||
if (!SetWaitableTimer(hTimer, &wTime, 0, NULL, NULL, 0)) {
|
if (!SetWaitableTimer(hTimer, &wTime, 0, NULL, NULL, 0)) {
|
||||||
// no much we can do at this low level
|
// no much we can do at this low level
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait for the timer - but don't wait for ever.
|
// Wait for the timer
|
||||||
// TODO: Variable 'result' is assigned a value that is never used
|
result = WaitForSingleObject(hTimer, INFINITE);
|
||||||
result = WaitForSingleObject(hTimer, ((waitTime/1000) + 1)); // wait for a 1 millisecond at least
|
if (result != WAIT_OBJECT_0) {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
CloseHandle(hTimer);
|
||||||
// todo: go through what the result is e.g. WAIT_OBJECT_0
|
// todo: go through what the result is e.g. WAIT_OBJECT_0
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -153,7 +159,6 @@ static void InvalidParameterHandler(const wchar_t* expression, // expression sen
|
||||||
else {
|
else {
|
||||||
wprintf(L"win-utils.c:InvalidParameterHandler:FILE = NULL\n");
|
wprintf(L"win-utils.c:InvalidParameterHandler:FILE = NULL\n");
|
||||||
}
|
}
|
||||||
// TODO: printf format string has 2 parameters but only 1 are given
|
|
||||||
printf("oreste:%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%:win-utils.c:InvalidParameterHandler:LINE = %ud\n",line);
|
printf("oreste:%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%:win-utils.c:InvalidParameterHandler:LINE = %ud\n",line);
|
||||||
/* end oreste -debug */
|
/* end oreste -debug */
|
||||||
//abort();
|
//abort();
|
||||||
|
@ -173,7 +178,8 @@ static void InvalidParameterHandler(const wchar_t* expression, // expression sen
|
||||||
|
|
||||||
|
|
||||||
int finaliseWindows(const TRI_win_finalise_e finaliseWhat, const char* data) {
|
int finaliseWindows(const TRI_win_finalise_e finaliseWhat, const char* data) {
|
||||||
|
int result = 0;
|
||||||
|
|
||||||
// ............................................................................
|
// ............................................................................
|
||||||
// The data is used to transport information from the calling function to here
|
// The data is used to transport information from the calling function to here
|
||||||
// it may be NULL (and will be in most cases)
|
// it may be NULL (and will be in most cases)
|
||||||
|
@ -182,11 +188,10 @@ int finaliseWindows(const TRI_win_finalise_e finaliseWhat, const char* data) {
|
||||||
switch (finaliseWhat) {
|
switch (finaliseWhat) {
|
||||||
|
|
||||||
case TRI_WIN_FINAL_WSASTARTUP_FUNCTION_CALL: {
|
case TRI_WIN_FINAL_WSASTARTUP_FUNCTION_CALL: {
|
||||||
int errorCode;
|
result = WSACleanup(); // could this cause error on server termination?
|
||||||
errorCode = WSACleanup();
|
if (result != 0) {
|
||||||
if (errorCode != 0) {
|
|
||||||
// can not use LOG_ etc here since the logging may have terminated
|
// can not use LOG_ etc here since the logging may have terminated
|
||||||
printf("ERROR: Could not perform a valid Winsock2 cleanup. WSACleanup returned error %d.",errorCode);
|
printf("ERROR: Could not perform a valid Winsock2 cleanup. WSACleanup returned error %d.",result);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -254,8 +259,6 @@ int initialiseWindows(const TRI_win_initialise_e initialiseWhat, const char* dat
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,133 +1,132 @@
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief windows utilties
|
/// @brief windows utilties
|
||||||
///
|
///
|
||||||
/// @file
|
/// @file
|
||||||
///
|
///
|
||||||
/// DISCLAIMER
|
/// DISCLAIMER
|
||||||
///
|
///
|
||||||
/// Copyright 2004-2012 triagens GmbH, Cologne, Germany
|
/// Copyright 2004-2012 triagens GmbH, Cologne, Germany
|
||||||
///
|
///
|
||||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
/// you may not use this file except in compliance with the License.
|
/// you may not use this file except in compliance with the License.
|
||||||
/// You may obtain a copy of the License at
|
/// You may obtain a copy of the License at
|
||||||
///
|
///
|
||||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
///
|
///
|
||||||
/// Unless required by applicable law or agreed to in writing, software
|
/// Unless required by applicable law or agreed to in writing, software
|
||||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
/// See the License for the specific language governing permissions and
|
/// See the License for the specific language governing permissions and
|
||||||
/// limitations under the License.
|
/// limitations under the License.
|
||||||
///
|
///
|
||||||
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
||||||
///
|
///
|
||||||
/// @author Dr. O
|
/// @author Dr. O
|
||||||
/// @author Copyright 2011-2012, triAGENS GmbH, Cologne, Germany
|
/// @author Copyright 2011-2012, triAGENS GmbH, Cologne, Germany
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#ifndef TRIAGENS_BASICS_C_WIN_UTILS_H
|
#ifndef TRIAGENS_BASICS_C_WIN_UTILS_H
|
||||||
#define TRIAGENS_BASICS_C_WIN_UTILS_H 1
|
#define TRIAGENS_BASICS_C_WIN_UTILS_H 1
|
||||||
|
|
||||||
#include <WinSock2.h>
|
#include <WinSock2.h>
|
||||||
|
|
||||||
/* Constants rounded for 21 decimals.
|
/* Constants rounded for 21 decimals.
|
||||||
#define M_E 2.71828182845904523536
|
#define M_E 2.71828182845904523536
|
||||||
#define M_LOG2E 1.44269504088896340736
|
#define M_LOG2E 1.44269504088896340736
|
||||||
#define M_LOG10E 0.434294481903251827651
|
#define M_LOG10E 0.434294481903251827651
|
||||||
#define M_LN2 0.693147180559945309417
|
#define M_LN2 0.693147180559945309417
|
||||||
#define M_LN10 2.30258509299404568402
|
#define M_LN10 2.30258509299404568402
|
||||||
#define M_PI 3.14159265358979323846
|
#define M_PI 3.14159265358979323846
|
||||||
#define M_PI_2 1.57079632679489661923
|
#define M_PI_2 1.57079632679489661923
|
||||||
#define M_PI_4 0.785398163397448309616
|
#define M_PI_4 0.785398163397448309616
|
||||||
#define M_1_PI 0.318309886183790671538
|
#define M_1_PI 0.318309886183790671538
|
||||||
#define M_2_PI 0.636619772367581343076
|
#define M_2_PI 0.636619772367581343076
|
||||||
#define M_1_SQRTPI 0.564189583547756286948
|
#define M_1_SQRTPI 0.564189583547756286948
|
||||||
#define M_2_SQRTPI 1.12837916709551257390
|
#define M_2_SQRTPI 1.12837916709551257390
|
||||||
#define M_SQRT2 1.41421356237309504880
|
#define M_SQRT2 1.41421356237309504880
|
||||||
#define M_SQRT_2 0.707106781186547524401
|
#define M_SQRT_2 0.707106781186547524401
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @addtogroup Windows_Utilties
|
/// @addtogroup Windows_Utilties
|
||||||
/// @{
|
/// @{
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// .............................................................................
|
// .............................................................................
|
||||||
// Called before anything else starts - initialises whatever is required to be
|
// Called before anything else starts - initialises whatever is required to be
|
||||||
// initalised.
|
// initalised.
|
||||||
// .............................................................................
|
// .............................................................................
|
||||||
typedef enum {
|
typedef enum {
|
||||||
TRI_WIN_FINAL_SET_INVALID_HANLE_HANDLER,
|
TRI_WIN_FINAL_SET_INVALID_HANLE_HANDLER,
|
||||||
TRI_WIN_FINAL_WSASTARTUP_FUNCTION_CALL
|
TRI_WIN_FINAL_WSASTARTUP_FUNCTION_CALL
|
||||||
}
|
}
|
||||||
TRI_win_finalise_e;
|
TRI_win_finalise_e;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
TRI_WIN_INITIAL_SET_DEBUG_FLAG,
|
TRI_WIN_INITIAL_SET_DEBUG_FLAG,
|
||||||
TRI_WIN_INITIAL_SET_INVALID_HANLE_HANDLER,
|
TRI_WIN_INITIAL_SET_INVALID_HANLE_HANDLER,
|
||||||
TRI_WIN_INITIAL_WSASTARTUP_FUNCTION_CALL
|
TRI_WIN_INITIAL_WSASTARTUP_FUNCTION_CALL
|
||||||
}
|
}
|
||||||
TRI_win_initialise_e;
|
TRI_win_initialise_e;
|
||||||
|
|
||||||
int finaliseWindows (const TRI_win_finalise_e, const char*);
|
int finaliseWindows (const TRI_win_finalise_e, const char*);
|
||||||
int initialiseWindows (const TRI_win_initialise_e, const char*);
|
int initialiseWindows (const TRI_win_initialise_e, const char*);
|
||||||
|
|
||||||
// .............................................................................
|
// .............................................................................
|
||||||
// windows equivalent of ftruncate (the truncation of an open file) is
|
// windows equivalent of ftruncate (the truncation of an open file) is
|
||||||
// _chsize
|
// _chsize
|
||||||
// .............................................................................
|
// .............................................................................
|
||||||
|
|
||||||
int ftruncate (int, long);
|
int ftruncate (int, long);
|
||||||
|
|
||||||
|
|
||||||
// .............................................................................
|
// .............................................................................
|
||||||
// windows does not have a function called getpagesize -- create one here
|
// windows does not have a function called getpagesize -- create one here
|
||||||
// .............................................................................
|
// .............................................................................
|
||||||
|
|
||||||
int getpagesize (void);
|
int getpagesize (void);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int TRI_WIN_closesocket (SOCKET);
|
int TRI_WIN_closesocket (SOCKET);
|
||||||
|
|
||||||
// .............................................................................
|
// .............................................................................
|
||||||
// This function uses the CreateFile windows method rather than _open which
|
// This function uses the CreateFile windows method rather than _open which
|
||||||
// then will allow the application to rename files on the fly.
|
// then will allow the application to rename files on the fly.
|
||||||
// .............................................................................
|
// .............................................................................
|
||||||
|
|
||||||
int TRI_createFile (const char* filename, int openFlags, int modeFlags);
|
int TRI_createFile (const char* filename, int openFlags, int modeFlags);
|
||||||
|
|
||||||
int TRI_openFile (const char* filename, int openFlags);
|
int TRI_openFile (const char* filename, int openFlags);
|
||||||
|
|
||||||
// .............................................................................
|
// .............................................................................
|
||||||
// the sleep function in windows is for milliseconds, on linux it is for seconds
|
// the sleep function in windows is for milliseconds, on linux it is for seconds
|
||||||
// this provides a translation
|
// this provides a translation
|
||||||
// .............................................................................
|
// .............................................................................
|
||||||
|
|
||||||
void TRI_sleep(unsigned long);
|
void TRI_sleep(unsigned long);
|
||||||
|
|
||||||
|
|
||||||
// .............................................................................
|
// .............................................................................
|
||||||
// there is no usleep (micro sleep) in windows, so we create one here
|
// there is no usleep (micro sleep) in windows, so we create one here
|
||||||
// .............................................................................
|
// .............................................................................
|
||||||
|
|
||||||
void TRI_usleep(unsigned long);
|
void TRI_usleep(unsigned long);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @}
|
/// @}
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Local Variables:
|
// Local Variables:
|
||||||
// mode: outline-minor
|
// mode: outline-minor
|
||||||
// outline-regexp: "^\\(/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|// --SECTION--\\|/// @\\}\\)"
|
// outline-regexp: "^\\(/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|// --SECTION--\\|/// @\\}\\)"
|
||||||
// End:
|
// End:
|
||||||
|
|
|
@ -210,6 +210,75 @@ socket_t EndpointIp::connectSocket (const struct addrinfo* aip, double connectTi
|
||||||
/// @brief connect the endpoint
|
/// @brief connect the endpoint
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
|
||||||
|
socket_t EndpointIp::connect (double connectTimeout, double requestTimeout) {
|
||||||
|
struct addrinfo* result = 0;
|
||||||
|
struct addrinfo* aip;
|
||||||
|
struct addrinfo hints;
|
||||||
|
int error;
|
||||||
|
|
||||||
|
LOGGER_DEBUG << "connecting to ip endpoint " << _specification;
|
||||||
|
|
||||||
|
assert(_socket == 0);
|
||||||
|
assert(!_connected);
|
||||||
|
|
||||||
|
memset(&hints, 0, sizeof (struct addrinfo));
|
||||||
|
hints.ai_family = getDomain(); // Allow IPv4 or IPv6
|
||||||
|
hints.ai_flags = AI_PASSIVE | AI_NUMERICSERV | AI_ALL;
|
||||||
|
hints.ai_socktype = SOCK_STREAM;
|
||||||
|
|
||||||
|
string portString = StringUtils::itoa(_port);
|
||||||
|
|
||||||
|
error = getaddrinfo(_host.c_str(), portString.c_str(), &hints, &result);
|
||||||
|
|
||||||
|
if (error != 0) {
|
||||||
|
int lastError = WSAGetLastError();
|
||||||
|
|
||||||
|
if (error == WSANOTINITIALISED) {
|
||||||
|
// can not call WSAGetLastError - since the socket layer hasn't been initialised yet!
|
||||||
|
lastError = error;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
lastError = WSAGetLastError();
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (lastError) {
|
||||||
|
case WSANOTINITIALISED: {
|
||||||
|
LOGGER_ERROR << "getaddrinfo for host: " << _host.c_str() << " => WSAStartup was not called or not called successfully.";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
LOGGER_ERROR << "getaddrinfo for host: " << _host.c_str() << " => " << gai_strerror(error);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result != 0) {
|
||||||
|
freeaddrinfo(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
socket_t listenSocket = 0;
|
||||||
|
|
||||||
|
// Try all returned addresses until one works
|
||||||
|
for (aip = result; aip != NULL; aip = aip->ai_next) {
|
||||||
|
// try to bind the address info pointer
|
||||||
|
listenSocket = connectSocket(aip, connectTimeout, requestTimeout);
|
||||||
|
if (listenSocket != 0) {
|
||||||
|
// OK
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
freeaddrinfo(result);
|
||||||
|
|
||||||
|
return listenSocket;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
socket_t EndpointIp::connect (double connectTimeout, double requestTimeout) {
|
socket_t EndpointIp::connect (double connectTimeout, double requestTimeout) {
|
||||||
struct addrinfo* result = 0;
|
struct addrinfo* result = 0;
|
||||||
struct addrinfo* aip;
|
struct addrinfo* aip;
|
||||||
|
@ -256,6 +325,7 @@ socket_t EndpointIp::connect (double connectTimeout, double requestTimeout) {
|
||||||
|
|
||||||
return listenSocket;
|
return listenSocket;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief destroys an IPv4 socket endpoint
|
/// @brief destroys an IPv4 socket endpoint
|
||||||
|
|
|
@ -272,7 +272,7 @@ void Scheduler::unregisterTask (Task* task) {
|
||||||
map<Task*, SchedulerThread*>::iterator i = task2thread.find(task);
|
map<Task*, SchedulerThread*>::iterator i = task2thread.find(task);
|
||||||
|
|
||||||
if (i == task2thread.end()) {
|
if (i == task2thread.end()) {
|
||||||
LOGGER_WARNING << "unregisterTask called for a unknown task " << task << " (" << task->getName() << ")";
|
LOGGER_WARNING << "unregisterTask called for an unknown task " << task << " (" << task->getName() << ")";
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -306,7 +306,7 @@ void Scheduler::destroyTask (Task* task) {
|
||||||
map<Task*, SchedulerThread*>::iterator i = task2thread.find(task);
|
map<Task*, SchedulerThread*>::iterator i = task2thread.find(task);
|
||||||
|
|
||||||
if (i == task2thread.end()) {
|
if (i == task2thread.end()) {
|
||||||
LOGGER_WARNING << "destroyTask called for a unknown task " << task << " (" << task->getName() << ")";
|
LOGGER_WARNING << "destroyTask called for an unknown task " << task << " (" << task->getName() << ")";
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -323,7 +323,7 @@ void Scheduler::destroyTask (Task* task) {
|
||||||
task2thread.erase(i);
|
task2thread.erase(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
thread->destroyTask(task);
|
thread->destroyTask(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -186,7 +186,7 @@ bool ClientConnection::prepare (const double timeout, const bool isWrite) const
|
||||||
/// @brief write data to the connection
|
/// @brief write data to the connection
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
bool ClientConnection::write (void* buffer, size_t length, size_t* bytesWritten) {
|
bool ClientConnection::writeClientConnection (void* buffer, size_t length, size_t* bytesWritten) {
|
||||||
if (!checkSocket()) {
|
if (!checkSocket()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -196,7 +196,7 @@ bool ClientConnection::write (void* buffer, size_t length, size_t* bytesWritten)
|
||||||
int status = ::send(_socket, buffer, length, 0);
|
int status = ::send(_socket, buffer, length, 0);
|
||||||
#elif defined(_WIN32)
|
#elif defined(_WIN32)
|
||||||
// MSG_NOSIGNAL not supported on windows platform
|
// MSG_NOSIGNAL not supported on windows platform
|
||||||
int status = ::send(_socket, (const char*)(buffer), (int)(length), 0);
|
int status = TRI_WRITE_SOCKET(_socket, (const char*)(buffer), (int)(length), 0);
|
||||||
#else
|
#else
|
||||||
int status = ::send(_socket, buffer, length, MSG_NOSIGNAL);
|
int status = ::send(_socket, buffer, length, MSG_NOSIGNAL);
|
||||||
#endif
|
#endif
|
||||||
|
@ -211,7 +211,7 @@ bool ClientConnection::write (void* buffer, size_t length, size_t* bytesWritten)
|
||||||
/// @brief read data from the connection
|
/// @brief read data from the connection
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
bool ClientConnection::read (StringBuffer& stringBuffer) {
|
bool ClientConnection::readClientConnection (StringBuffer& stringBuffer) {
|
||||||
if (!checkSocket()) {
|
if (!checkSocket()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -221,7 +221,7 @@ bool ClientConnection::read (StringBuffer& stringBuffer) {
|
||||||
do {
|
do {
|
||||||
char buffer[READBUFFER_SIZE];
|
char buffer[READBUFFER_SIZE];
|
||||||
|
|
||||||
int lenRead = ::read(_socket, buffer, READBUFFER_SIZE - 1);
|
int lenRead = TRI_READ_SOCKET(_socket, buffer, READBUFFER_SIZE - 1,0);
|
||||||
|
|
||||||
if (lenRead == -1) {
|
if (lenRead == -1) {
|
||||||
// error occurred
|
// error occurred
|
||||||
|
|
|
@ -130,13 +130,13 @@ namespace triagens {
|
||||||
/// @brief write data to the connection
|
/// @brief write data to the connection
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
bool write (void*, size_t, size_t*);
|
bool writeClientConnection (void*, size_t, size_t*);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief read data from the connection
|
/// @brief read data from the connection
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
bool read (triagens::basics::StringBuffer&);
|
bool readClientConnection (triagens::basics::StringBuffer&);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief return whether the connection is readable
|
/// @brief return whether the connection is readable
|
||||||
|
|
|
@ -144,7 +144,7 @@ bool GeneralClientConnection::handleWrite (const double timeout, void* buffer, s
|
||||||
*bytesWritten = 0;
|
*bytesWritten = 0;
|
||||||
|
|
||||||
if (prepare(timeout, true)) {
|
if (prepare(timeout, true)) {
|
||||||
return this->write(buffer, length, bytesWritten);
|
return this->writeClientConnection(buffer, length, bytesWritten);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -156,7 +156,7 @@ bool GeneralClientConnection::handleWrite (const double timeout, void* buffer, s
|
||||||
|
|
||||||
bool GeneralClientConnection::handleRead (double timeout, StringBuffer& buffer) {
|
bool GeneralClientConnection::handleRead (double timeout, StringBuffer& buffer) {
|
||||||
if (prepare(timeout, false)) {
|
if (prepare(timeout, false)) {
|
||||||
return this->read(buffer);
|
return this->readClientConnection(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -212,13 +212,13 @@ namespace triagens {
|
||||||
/// @brief write data to the connection
|
/// @brief write data to the connection
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
virtual bool write (void*, size_t, size_t*) = 0;
|
virtual bool writeClientConnection (void*, size_t, size_t*) = 0;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief read data from the connection
|
/// @brief read data from the connection
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
virtual bool read (triagens::basics::StringBuffer&) = 0;
|
virtual bool readClientConnection (triagens::basics::StringBuffer&) = 0;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief return whether the connection is readable
|
/// @brief return whether the connection is readable
|
||||||
|
|
|
@ -200,7 +200,7 @@ bool SslClientConnection::prepare (const double timeout, const bool isWrite) con
|
||||||
/// @brief write data to the connection
|
/// @brief write data to the connection
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
bool SslClientConnection::write (void* buffer, size_t length, size_t* bytesWritten) {
|
bool SslClientConnection::writeClientConnection (void* buffer, size_t length, size_t* bytesWritten) {
|
||||||
*bytesWritten = 0;
|
*bytesWritten = 0;
|
||||||
|
|
||||||
if (_ssl == 0) {
|
if (_ssl == 0) {
|
||||||
|
@ -234,7 +234,7 @@ bool SslClientConnection::write (void* buffer, size_t length, size_t* bytesWritt
|
||||||
/// @brief read data from the connection
|
/// @brief read data from the connection
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
bool SslClientConnection::read (StringBuffer& stringBuffer) {
|
bool SslClientConnection::readClientConnection (StringBuffer& stringBuffer) {
|
||||||
if (_ssl == 0) {
|
if (_ssl == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,13 +115,13 @@ namespace triagens {
|
||||||
/// @brief write data to the connection
|
/// @brief write data to the connection
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
bool write (void*, size_t, size_t*);
|
bool writeClientConnection (void*, size_t, size_t*);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief read data from the connection
|
/// @brief read data from the connection
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
bool read (triagens::basics::StringBuffer&);
|
bool readClientConnection (triagens::basics::StringBuffer&);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief return whether the connection is readable
|
/// @brief return whether the connection is readable
|
||||||
|
|
Loading…
Reference in New Issue