From 810209db033edeaac26487c833116f51cad2d5fd Mon Sep 17 00:00:00 2001 From: jsteemann Date: Fri, 6 Jan 2017 10:54:48 +0100 Subject: [PATCH 1/6] remove unreferenced variable --- arangod/VocBase/vocbase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arangod/VocBase/vocbase.cpp b/arangod/VocBase/vocbase.cpp index 389c2c5819..ca5da763ca 100644 --- a/arangod/VocBase/vocbase.cpp +++ b/arangod/VocBase/vocbase.cpp @@ -505,7 +505,7 @@ int TRI_vocbase_t::dropCollectionWorker(arangodb::LogicalCollection* collection, collection->setDeleted(false); events::DropCollection(colName, ex.code()); return ex.code(); - } catch (std::exception const& ex) { + } catch (std::exception const&) { collection->setDeleted(false); events::DropCollection(colName, TRI_ERROR_INTERNAL); return TRI_ERROR_INTERNAL; From 3690f3c92ef1530e79db887502edbcbf8708c1b0 Mon Sep 17 00:00:00 2001 From: jsteemann Date: Fri, 6 Jan 2017 11:01:16 +0100 Subject: [PATCH 2/6] some more optimizations for arithmetic calculations --- arangod/Aql/Expression.cpp | 65 ++++++++++++++++++-------------------- arangod/Aql/Expression.h | 13 +++++--- 2 files changed, 40 insertions(+), 38 deletions(-) diff --git a/arangod/Aql/Expression.cpp b/arangod/Aql/Expression.cpp index a54a0bbaf8..3b31eb92a6 100644 --- a/arangod/Aql/Expression.cpp +++ b/arangod/Aql/Expression.cpp @@ -467,8 +467,9 @@ AqlValue Expression::executeSimpleExpression( case NODE_TYPE_OPERATOR_UNARY_MINUS: return executeSimpleExpressionMinus(node, trx, mustDestroy); case NODE_TYPE_OPERATOR_BINARY_AND: + return executeSimpleExpressionAnd(node, trx, mustDestroy); case NODE_TYPE_OPERATOR_BINARY_OR: - return executeSimpleExpressionAndOr(node, trx, mustDestroy); + return executeSimpleExpressionOr(node, trx, mustDestroy); case NODE_TYPE_OPERATOR_BINARY_EQ: case NODE_TYPE_OPERATOR_BINARY_NE: case NODE_TYPE_OPERATOR_BINARY_LT: @@ -996,34 +997,38 @@ AqlValue Expression::executeSimpleExpressionMinus(AstNode const* node, return AqlValue(-value); } -/// @brief execute an expression of type SIMPLE with AND or OR -AqlValue Expression::executeSimpleExpressionAndOr( +/// @brief execute an expression of type SIMPLE with AND +AqlValue Expression::executeSimpleExpressionAnd( AstNode const* node, arangodb::Transaction* trx, bool& mustDestroy) { AqlValue left = - executeSimpleExpression(node->getMember(0), trx, mustDestroy, true); + executeSimpleExpression(node->getMemberUnchecked(0), trx, mustDestroy, true); - if (node->type == NODE_TYPE_OPERATOR_BINARY_AND) { - // AND - if (left.toBoolean()) { - // left is true => return right - if (mustDestroy) { left.destroy(); } - return executeSimpleExpression(node->getMember(1), trx, mustDestroy, true); - } + if (left.toBoolean()) { + // left is true => return right + if (mustDestroy) { left.destroy(); } + return executeSimpleExpression(node->getMemberUnchecked(1), trx, mustDestroy, true); + } + + // left is false, return left + return left; +} + +/// @brief execute an expression of type SIMPLE with OR +AqlValue Expression::executeSimpleExpressionOr( + AstNode const* node, arangodb::Transaction* trx, bool& mustDestroy) { + + AqlValue left = + executeSimpleExpression(node->getMemberUnchecked(0), trx, mustDestroy, true); - // left is false, return left - return left; - } - - // OR if (left.toBoolean()) { // left is true => return left return left; } // left is false => return right - left.destroy(); - return executeSimpleExpression(node->getMember(1), trx, mustDestroy, true); + if (mustDestroy) { left.destroy(); } + return executeSimpleExpression(node->getMemberUnchecked(1), trx, mustDestroy, true); } /// @brief execute an expression of type SIMPLE with AND or OR @@ -1076,11 +1081,11 @@ AqlValue Expression::executeSimpleExpressionComparison( AstNode const* node, arangodb::Transaction* trx, bool& mustDestroy) { AqlValue left = - executeSimpleExpression(node->getMember(0), trx, mustDestroy, false); + executeSimpleExpression(node->getMemberUnchecked(0), trx, mustDestroy, false); AqlValueGuard guardLeft(left, mustDestroy); AqlValue right = - executeSimpleExpression(node->getMember(1), trx, mustDestroy, false); + executeSimpleExpression(node->getMemberUnchecked(1), trx, mustDestroy, false); AqlValueGuard guardRight(right, mustDestroy); mustDestroy = false; // we're returning a boolean only @@ -1486,10 +1491,10 @@ AqlValue Expression::executeSimpleExpressionIterator( AqlValue Expression::executeSimpleExpressionArithmetic( AstNode const* node, arangodb::Transaction* trx, bool& mustDestroy) { - AqlValue lhs = executeSimpleExpression(node->getMember(0), trx, mustDestroy, true); + AqlValue lhs = executeSimpleExpression(node->getMemberUnchecked(0), trx, mustDestroy, true); AqlValueGuard guardLhs(lhs, mustDestroy); - AqlValue rhs = executeSimpleExpression(node->getMember(1), trx, mustDestroy, true); + AqlValue rhs = executeSimpleExpression(node->getMemberUnchecked(1), trx, mustDestroy, true); AqlValueGuard guardRhs(rhs, mustDestroy); mustDestroy = false; @@ -1523,6 +1528,7 @@ AqlValue Expression::executeSimpleExpressionArithmetic( } } + mustDestroy = false; double result; switch (node->type) { @@ -1542,18 +1548,9 @@ AqlValue Expression::executeSimpleExpressionArithmetic( result = fmod(l, r); break; default: - mustDestroy = false; return AqlValue(VelocyPackHelper::ZeroValue()); } - - if (std::isnan(result) || !std::isfinite(result) || result == HUGE_VAL || result == -HUGE_VAL) { - // convert NaN, +inf & -inf to null - mustDestroy = false; - return AqlValue(VelocyPackHelper::NullValue()); - } - - TransactionBuilderLeaser builder(trx); - mustDestroy = true; // builder = dynamic data - builder->add(VPackValue(result)); - return AqlValue(*builder.get()); + + // this will convert NaN, +inf & -inf to null + return AqlValue(result); } diff --git a/arangod/Aql/Expression.h b/arangod/Aql/Expression.h index 55bf0d8165..9053a0438e 100644 --- a/arangod/Aql/Expression.h +++ b/arangod/Aql/Expression.h @@ -280,10 +280,15 @@ class Expression { AqlValue executeSimpleExpressionMinus(AstNode const*, arangodb::Transaction*, bool& mustDestroy); - /// @brief execute an expression of type SIMPLE with AND or OR - AqlValue executeSimpleExpressionAndOr(AstNode const*, - arangodb::Transaction*, - bool& mustDestroy); + /// @brief execute an expression of type SIMPLE with AND + AqlValue executeSimpleExpressionAnd(AstNode const*, + arangodb::Transaction*, + bool& mustDestroy); + + /// @brief execute an expression of type SIMPLE with OR + AqlValue executeSimpleExpressionOr(AstNode const*, + arangodb::Transaction*, + bool& mustDestroy); /// @brief execute an expression of type SIMPLE with NARY AND or OR AqlValue executeSimpleExpressionNaryAndOr(AstNode const*, From 779dab21651b823b8212d4523d7984f474105b19 Mon Sep 17 00:00:00 2001 From: Wilfried Goesgens Date: Fri, 6 Jan 2017 11:22:01 +0100 Subject: [PATCH 3/6] fix style so emacs asm-mode nicely displays the nsis files --- .../Windows/Templates/NSIS.template.in | 40 +++++++++---------- .../Windows/client/Templates/NSIS.template.in | 32 +++++++-------- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/Installation/Windows/Templates/NSIS.template.in b/Installation/Windows/Templates/NSIS.template.in index 2a9e0ef936..12df66079f 100755 --- a/Installation/Windows/Templates/NSIS.template.in +++ b/Installation/Windows/Templates/NSIS.template.in @@ -69,11 +69,11 @@ Function openLinkNewWindow Exch ReadRegStr $0 HKCR "http\shell\open\command" "" -# Get browser path +; Get browser path DetailPrint $0 - StrCpy $2 '"' + StrCpy $2 '"' ;" StrCpy $1 $0 1 - StrCmp $1 $2 +2 # if path is not enclosed in " look for space as final char + StrCmp $1 $2 +2 # if path is not enclosed in "" look for space as final char StrCpy $2 ' ' StrCpy $3 1 loop: @@ -87,7 +87,7 @@ Function openLinkNewWindow found: StrCpy $1 $0 $3 StrCmp $2 " " +2 - StrCpy $1 '$1"' + StrCpy $1 '$1"' ;" Pop $0 Exec '$1 $0' @@ -350,7 +350,7 @@ Function AddToPath Push $2 Push $3 - # don't add if the path doesn't exist + ; don't add if the path doesn't exist IfFileExists "$0\*.*" "" AddToPath_done ReadEnvStr $1 PATH @@ -425,7 +425,7 @@ Function un.RemoveFromPath Push $5 Push $6 - IntFmt $6 "%c" 26 # DOS EOF + IntFmt $6 "%c" 26 ; DOS EOF StrCmp $ADD_TO_PATH_ALL_USERS "1" unReadAllKey ReadRegStr $1 ${NT_current_env} "PATH" @@ -433,26 +433,26 @@ Function un.RemoveFromPath unReadAllKey: ReadRegStr $1 ${NT_all_env} "PATH" unDoTrim: - StrCpy $5 $1 1 -1 # copy last char - StrCmp $5 ";" +2 # if last char != ; - StrCpy $1 "$1;" # append ; + StrCpy $5 $1 1 -1 ; copy last char + StrCmp $5 ";" +2 ; if last char != ; + StrCpy $1 "$1;" ; append ; Push $1 Push "$0;" Call un.StrStr ; Find `$0;` in $1 Pop $2 ; pos of our dir StrCmp $2 "" unRemoveFromPath_done ; else, it is in path - # $0 - path to add - # $1 - path var + ; $0 - path to add + ; $1 - path var StrLen $3 "$0;" StrLen $4 $2 - StrCpy $5 $1 -$4 # $5 is now the part before the path to remove - StrCpy $6 $2 "" $3 # $6 is now the part after the path to remove + StrCpy $5 $1 -$4 ; $5 is now the part before the path to remove + StrCpy $6 $2 "" $3 ; $6 is now the part after the path to remove StrCpy $3 $5$6 - StrCpy $5 $3 1 -1 # copy last char - StrCmp $5 ";" 0 +2 # if last char == ; - StrCpy $3 $3 -1 # remove last char + StrCpy $5 $3 1 -1 ; copy last char + StrCmp $5 ";" 0 +2 ; if last char == ; + StrCpy $3 $3 -1 ; remove last char StrCmp $ADD_TO_PATH_ALL_USERS "1" unWriteAllKey WriteRegExpandStr ${NT_current_env} "PATH" $3 @@ -476,9 +476,9 @@ FunctionEnd ; Uninstall sutff ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -########################################### -# Utility Functions # -########################################### +;########################################### +;# Utility Functions # +;########################################### ; StrStr ; input, top of stack = string to search for @@ -1353,7 +1353,7 @@ Function .onInit uninst: ClearErrors StrLen $2 "\Uninstall.exe" - StrCpy $3 $0 -$2 # remove "\Uninstall.exe" from UninstallString to get path + StrCpy $3 $0 -$2 ; remove "\Uninstall.exe" from UninstallString to get path ExecWait '$0 _?=$3' ;Do not copy the uninstaller to a temp file IfErrors uninst_failed inst diff --git a/Installation/Windows/client/Templates/NSIS.template.in b/Installation/Windows/client/Templates/NSIS.template.in index bb76397504..1736039c4e 100755 --- a/Installation/Windows/client/Templates/NSIS.template.in +++ b/Installation/Windows/client/Templates/NSIS.template.in @@ -237,7 +237,7 @@ Function AddToPath Push $2 Push $3 - # don't add if the path doesn't exist + ; don't add if the path doesn't exist IfFileExists "$0\*.*" "" AddToPath_done ReadEnvStr $1 PATH @@ -312,7 +312,7 @@ Function un.RemoveFromPath Push $5 Push $6 - IntFmt $6 "%c" 26 # DOS EOF + IntFmt $6 "%c" 26 ; DOS EOF StrCmp $ADD_TO_PATH_ALL_USERS "1" unReadAllKey ReadRegStr $1 ${NT_current_env} "PATH" @@ -320,26 +320,26 @@ Function un.RemoveFromPath unReadAllKey: ReadRegStr $1 ${NT_all_env} "PATH" unDoTrim: - StrCpy $5 $1 1 -1 # copy last char - StrCmp $5 ";" +2 # if last char != ; - StrCpy $1 "$1;" # append ; + StrCpy $5 $1 1 -1 ; copy last char + StrCmp $5 ";" +2 ; if last char != ; + StrCpy $1 "$1;" ; append ; Push $1 Push "$0;" Call un.StrStr ; Find `$0;` in $1 Pop $2 ; pos of our dir StrCmp $2 "" unRemoveFromPath_done ; else, it is in path - # $0 - path to add - # $1 - path var + ; $0 - path to add + ; $1 - path var StrLen $3 "$0;" StrLen $4 $2 - StrCpy $5 $1 -$4 # $5 is now the part before the path to remove - StrCpy $6 $2 "" $3 # $6 is now the part after the path to remove + StrCpy $5 $1 -$4 ; $5 is now the part before the path to remove + StrCpy $6 $2 "" $3 ; $6 is now the part after the path to remove StrCpy $3 $5$6 - StrCpy $5 $3 1 -1 # copy last char - StrCmp $5 ";" 0 +2 # if last char == ; - StrCpy $3 $3 -1 # remove last char + StrCpy $5 $3 1 -1 ; copy last char + StrCmp $5 ";" 0 +2 ; if last char == ; + StrCpy $3 $3 -1 ; remove last char StrCmp $ADD_TO_PATH_ALL_USERS "1" unWriteAllKey WriteRegExpandStr ${NT_current_env} "PATH" $3 @@ -363,9 +363,9 @@ FunctionEnd ; Uninstall sutff ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -########################################### -# Utility Functions # -########################################### +;########################################### +;# Utility Functions # +;########################################### ; StrStr ; input, top of stack = string to search for @@ -1013,7 +1013,7 @@ Function .onInit uninst: ClearErrors StrLen $2 "\Uninstall.exe" - StrCpy $3 $0 -$2 # remove "\Uninstall.exe" from UninstallString to get path + StrCpy $3 $0 -$2 ; remove "\Uninstall.exe" from UninstallString to get path ExecWait '$0 _?=$3' ;Do not copy the uninstaller to a temp file IfErrors uninst_failed inst From ce1ceb8eb14c29cf497efd7e99cbdf3844b9c125 Mon Sep 17 00:00:00 2001 From: Wilfried Goesgens Date: Fri, 6 Jan 2017 11:53:42 +0100 Subject: [PATCH 4/6] add code to store things to our symbol server. --- cmake/packages/nsis.cmake | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cmake/packages/nsis.cmake b/cmake/packages/nsis.cmake index ba50e8f75f..d7f60e3d13 100644 --- a/cmake/packages/nsis.cmake +++ b/cmake/packages/nsis.cmake @@ -111,3 +111,10 @@ add_custom_target(remove_packages list(APPEND CLEAN_PACKAGES_LIST remove_packages) +if (NOT ${ENV{SYMSRV}} STREQUAL "") + message("Storing symbols:") + add_custom_command(TARGET ${BIN_ARANGOD} POST_BUILD + WORKING_DIRECTORY ${PROJECT_BINARY_DIR} + COMMAND "find -name \*pdb |grep -v Release |grep -v Debug |grep -v 3rdParty |grep -v vc120.pdb > pdbfiles_list.txt" + COMMAND "symstore.exe add /f '@${PROJECT_BINARY_DIR}/pdbfiles_list.txt' /s '${ENV{SYMSRV}}' /t ArangoDB /compress") +endif() From c817254214853ceb25244e1784f57a1da6eed820 Mon Sep 17 00:00:00 2001 From: Wilfried Goesgens Date: Fri, 6 Jan 2017 11:54:01 +0100 Subject: [PATCH 5/6] add commandline parsing for silent installation --- .../Windows/Templates/NSIS.template.in | 36 ++++++++++++++----- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/Installation/Windows/Templates/NSIS.template.in b/Installation/Windows/Templates/NSIS.template.in index 12df66079f..a793a79ba6 100755 --- a/Installation/Windows/Templates/NSIS.template.in +++ b/Installation/Windows/Templates/NSIS.template.in @@ -12,6 +12,11 @@ !include nsDialogs.nsh !include WinMessages.nsh +;-------------------------------- +; get commandline parameters +!include FileFunc.nsh +!insertmacro GetParameters +!insertmacro GetOptions ;-------------------------------- ; You must define these values @@ -28,23 +33,27 @@ @CPACK_ARANGODB_NSIS_DEFINES@ ;-------------------------------- -;Variables +;Variables x -> from userinput !define EMPTY "" var retryCount Var MUI_TEMP Var STARTMENU_FOLDER Var SV_ALLUSERS Var START_MENU - Var DO_NOT_ADD_TO_PATH - Var ADD_TO_PATH_ALL_USERS - Var ADD_TO_PATH_CURRENT_USER - Var INSTALL_DESKTOP + + Var DO_NOT_ADD_TO_PATH ; x bool + Var ADD_TO_PATH_ALL_USERS ; x bool + Var ADD_TO_PATH_CURRENT_USER ; x bool + + Var INSTALL_DESKTOP ; x bool: add desktop icon Var IS_DEFAULT_INSTALLDIR - Var PASSWORD - Var PASSWORD_AGAIN + + Var PASSWORD ; x string + Var PASSWORD_AGAIN ; x string / only for comparison + ; Variables for definition of instdir ; posible values: SingleUser | AllUsers | Service - VAR TRI_INSTALL_TYPE + VAR TRI_INSTALL_TYPE ; x !define TEMP1 $R0 ;Temp variable ;-------------------------------- @@ -73,7 +82,7 @@ Function openLinkNewWindow DetailPrint $0 StrCpy $2 '"' ;" StrCpy $1 $0 1 - StrCmp $1 $2 +2 # if path is not enclosed in "" look for space as final char + StrCmp $1 $2 +2 ; if path is not enclosed in " look for space as final char StrCpy $2 ' ' StrCpy $3 1 loop: @@ -1136,6 +1145,15 @@ Function un.onInit SetShellVarContext current ${EndIf} + ${GetParameters} $R0 + ClearErrors + ${GetOptions} $PASSWORD /PASSWORD= $0 + ${GetOptions} $INSTALL_DESKTOP /DESKTOPICON $0 + ${GetOptions} $DO_NOT_ADD_TO_PATH /NOPATH $0 + ${GetOptions} $ADD_TO_PATH_ALL_USERS /ALLPATH $0 + ${GetOptions} $ADD_TO_PATH_CURRENT_USER /CURPATH $0 + ${GetOptions} $TRI_INSTALL_TYPE /INSTALLTYPE= $0 + ${GetOptions} $INSTDIR /INSTDIR= $0 FunctionEnd ;--- Add/Remove callback functions: --- From 15fab0b7cec222fe6e1634ca9da757825b391606 Mon Sep 17 00:00:00 2001 From: Andreas Streichardt Date: Fri, 6 Jan 2017 11:57:57 +0100 Subject: [PATCH 6/6] Do not initialize clustercomm twice in debug mode --- arangod/Cluster/ClusterFeature.cpp | 17 ++++++++++++----- arangod/Cluster/ClusterMethods.cpp | 4 +++- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/arangod/Cluster/ClusterFeature.cpp b/arangod/Cluster/ClusterFeature.cpp index 739dddada5..f8f638a750 100644 --- a/arangod/Cluster/ClusterFeature.cpp +++ b/arangod/Cluster/ClusterFeature.cpp @@ -193,9 +193,14 @@ void ClusterFeature::prepare() { auto agency = application_features::ApplicationServer::getFeature("Agency"); +#ifdef DEBUG_SYNC_REPLICATION + bool startClusterComm = true; +#else + bool startClusterComm = false; +#endif + if (agency->isEnabled() || _enableCluster) { - // initialize ClusterComm library, must call initialize only once - ClusterComm::initialize(); + startClusterComm = true; auto authenticationFeature = application_features::ApplicationServer::getFeature( "Authentication"); @@ -207,11 +212,13 @@ void ClusterFeature::prepare() { } } + if (startClusterComm) { + // initialize ClusterComm library, must call initialize only once + ClusterComm::initialize(); + } + // return if cluster is disabled if (!_enableCluster) { -#ifdef DEBUG_SYNC_REPLICATION - ClusterComm::initialize(); -#endif return; } diff --git a/arangod/Cluster/ClusterMethods.cpp b/arangod/Cluster/ClusterMethods.cpp index 1c7fe2fb73..0b169ad145 100644 --- a/arangod/Cluster/ClusterMethods.cpp +++ b/arangod/Cluster/ClusterMethods.cpp @@ -503,7 +503,9 @@ bool shardKeysChanged(std::string const& dbname, std::string const& collname, return true; } #ifdef DEBUG_SYNC_REPLICATION - return false; + if (dbname == "sync-replication-test") { + return false; + } #endif ClusterInfo* ci = ClusterInfo::instance();