diff --git a/Installation/Windows/Templates/arango-packer-template.nsi b/Installation/Windows/Templates/arango-packer-template.nsi index ba12ff4feb..6ce531a94a 100644 --- a/Installation/Windows/Templates/arango-packer-template.nsi +++ b/Installation/Windows/Templates/arango-packer-template.nsi @@ -12,14 +12,14 @@ ; !include "Library.nsh" ; The name of the installer -Name ""@INSTALLERNAME@" +Name "@INSTALLERNAME@" ; The file to write OutFile "@INSTALLERNAME@.exe" ; The default installation directory !define APPNAME "Unpacker" -!define COMPANYNAME "Triagens" +!define COMPANYNAME "ArangoDB" InstallDir $TEMP\${COMPANYNAME}\${APPNAME} @@ -55,7 +55,7 @@ Section "" ;No components page, name is not important SetOutPath $INSTDIR ; Put file there ; !insertmacro InstallLib DLL SHARED NOREBOOT_PROTECTED "exdll.dll" $INSTDIR $TEMP - file "..\Installation\Windows\Plugins\SharedMemory\Plugins\@BITS@\msvcr120.dll" + file "@SRCDIR@\Installation\Windows\Plugins\SharedMemory\Plugins\@BITS@\msvcr120.dll" file "@INSTALLERNAME@-internal.exe" Rename "$INSTDIR\Installation\Windows\Plugins\SharedMemory\Plugins\@BITS@\msvcr120.dll" "$INSTDIR\msvcr120.dll" Rename "$INSTDIR\Build@BITS@\@INSTALLERNAME@-internal.exe" "$INSTDIR\@INSTALLERNAME@-internal.exe" diff --git a/Installation/Windows/installer-generator.sh b/Installation/Windows/installer-generator.sh index 71d2561b04..d90104f525 100755 --- a/Installation/Windows/installer-generator.sh +++ b/Installation/Windows/installer-generator.sh @@ -4,13 +4,22 @@ NSIS_PATH="/cygdrive/c/Program Files (x86)/NSIS" #shell parameter: #1 the bits (64 or 32) #2 the parent directory which contains the Build64 or Build32 directory -cd $2 +BUILD=$2 bits=$1 -INSTALLERNAME=`grep CPACK_PACKAGE_FILE_NAME Build$bits/CPackConfig.cmake | grep -o '".*"' | awk -F\" '{print $2}'` -if [ ! -f Build$bits/$INSTALLERNAME-internal.exe ]; then - cp Build$bits/$INSTALLERNAME.exe Build$bits/$INSTALLERNAME-internal.exe + +# Yo windows we like year backslash paths. +WD=`pwd` +SRCPATH=`cygpath -w ${WD}|sed "s;\\\\\;\\\\\\\\\\\\\;g"` + +INSTALLERNAME=`grep CPACK_PACKAGE_FILE_NAME ${BUILD}/CPackConfig.cmake | grep -o '".*"' | awk -F\" '{print $2}'` + +if [ ! -f ${BUILD}/$INSTALLERNAME-internal.exe ]; then + cp ${BUILD}/$INSTALLERNAME.exe ${BUILD}/$INSTALLERNAME-internal.exe fi -cat Installation/Windows/Templates/arango-packer-template.nsi | sed -e "s/@BITS@/$bits/g" | sed -e "s/@INSTALLERNAME@/${INSTALLERNAME}/g" > Build$bits/$INSTALLERNAME.nsi +cat Installation/Windows/Templates/arango-packer-template.nsi | \ + sed -e "s;@BITS@;$bits;g" \ + -e "s;@INSTALLERNAME@;${INSTALLERNAME};" \ + -e "s;@SRCDIR@;${SRCPATH};g" > ${BUILD}/$INSTALLERNAME.nsi -"$NSIS_PATH"/makensis.exe Build$bits/$INSTALLERNAME.nsi +"$NSIS_PATH"/makensis.exe ${BUILD}\\$INSTALLERNAME.nsi diff --git a/arangod/VocBase/replication-dump.cpp b/arangod/VocBase/replication-dump.cpp index 5434bd627a..7bae873e40 100644 --- a/arangod/VocBase/replication-dump.cpp +++ b/arangod/VocBase/replication-dump.cpp @@ -439,9 +439,9 @@ static int DumpCollection(TRI_replication_dump_t* dump, // we are reading from a journal that might be modified in parallel // so we must read-lock it - if (e._isJournal) { - TRI_READ_LOCK_DOCUMENTS_INDEXES_PRIMARY_COLLECTION(document); - } else { + CONDITIONAL_READ_LOCKER(readLocker, document->_filesLock, e._isJournal); + + if (!e._isJournal) { TRI_ASSERT(datafile->_isSealed); } @@ -530,11 +530,6 @@ static int DumpCollection(TRI_replication_dump_t* dump, } NEXT_DF: - if (e._isJournal) { - // read-unlock the journal - TRI_READ_UNLOCK_DOCUMENTS_INDEXES_PRIMARY_COLLECTION(document); - } - if (res != TRI_ERROR_NO_ERROR || !hasMore || bufferFull) { break; } diff --git a/lib/Basics/ReadLocker.h b/lib/Basics/ReadLocker.h index 054e6a84be..3310c25d1c 100644 --- a/lib/Basics/ReadLocker.h +++ b/lib/Basics/ReadLocker.h @@ -58,6 +58,8 @@ #define TRY_READ_LOCKER(obj, lock) arangodb::basics::TryReadLocker obj(&lock) +#define CONDITIONAL_READ_LOCKER(obj, lock, condition) arangodb::basics::ConditionalReadLocker obj(&lock, (condition)) + namespace arangodb { namespace basics { @@ -74,7 +76,7 @@ class ReadLocker { public: //////////////////////////////////////////////////////////////////////////////// -/// @brief aquires a read-lock +/// @brief acquires a read-lock /// /// The constructors read-locks the lock, the destructors unlocks the lock. //////////////////////////////////////////////////////////////////////////////// @@ -98,7 +100,7 @@ class ReadLocker { #endif //////////////////////////////////////////////////////////////////////////////// -/// @brief aquires a read-lock, with periodic sleeps while not acquired +/// @brief acquires a read-lock, with periodic sleeps while not acquired /// sleep time is specified in nanoseconds //////////////////////////////////////////////////////////////////////////////// @@ -183,9 +185,9 @@ class TryReadLocker { public: //////////////////////////////////////////////////////////////////////////////// - /// @brief tries to aquire a read-lock + /// @brief tries to acquire a read-lock /// - /// The constructors tries to read-lock the lock, the destructors unlocks the + /// The constructor tries to read-lock the lock, the destructors unlocks the /// lock if it was acquired in the constructor //////////////////////////////////////////////////////////////////////////////// @@ -236,6 +238,69 @@ class TryReadLocker { bool _isLocked; }; + +class ConditionalReadLocker { + ConditionalReadLocker(ConditionalReadLocker const&) = delete; + ConditionalReadLocker& operator=(ConditionalReadLocker const&) = delete; + + public: + //////////////////////////////////////////////////////////////////////////////// + /// @brief acquire a read-lock + /// + /// The constructor tries to read-lock the lock, the destructors unlocks the + /// lock if it was acquired in the constructor + //////////////////////////////////////////////////////////////////////////////// + + ConditionalReadLocker(ReadWriteLock* readWriteLock, bool condition) + : _readWriteLock(readWriteLock), _isLocked(false) { + if (condition) { + _readWriteLock->readLock(); + _isLocked = true; + } + } + + ////////////////////////////////////////////////////////////////////////////// + /// @brief releases the read-lock + ////////////////////////////////////////////////////////////////////////////// + + ~ConditionalReadLocker() { + if (_isLocked) { + _readWriteLock->unlock(); + } + } + + ////////////////////////////////////////////////////////////////////////////// + /// @brief whether or not we acquired the lock + ////////////////////////////////////////////////////////////////////////////// + + bool isLocked() const { return _isLocked; } + + ////////////////////////////////////////////////////////////////////////////// + /// @brief unlocks the read-write lock + ////////////////////////////////////////////////////////////////////////////// + + bool unlock() { + if (_isLocked) { + _readWriteLock->unlock(); + _isLocked = false; + return true; + } + return false; + } + + private: + ////////////////////////////////////////////////////////////////////////////// + /// @brief the read-write lock + ////////////////////////////////////////////////////////////////////////////// + + ReadWriteLock* _readWriteLock; + + ////////////////////////////////////////////////////////////////////////////// + /// @brief whether or not we acquired the lock + ////////////////////////////////////////////////////////////////////////////// + + bool _isLocked; +}; } }