diff --git a/src/file_sharing/dir_hierarchy.cc b/src/file_sharing/dir_hierarchy.cc index 3a72bdcf9..eaeb1201a 100644 --- a/src/file_sharing/dir_hierarchy.cc +++ b/src/file_sharing/dir_hierarchy.cc @@ -299,8 +299,7 @@ bool InternalFileHierarchyStorage::updateSubFilesList(const DirectoryStorage::En std::cerr << "[directory storage] removing non existing file " << f.file_name << " at index " << d.subfiles[i] << std::endl; #endif - delete mNodes[d.subfiles[i]] ; - mNodes[d.subfiles[i]] = NULL ; + deleteNode(d.subfiles[i]) ; d.subfiles[i] = d.subfiles[d.subfiles.size()-1] ; d.subfiles.pop_back(); @@ -374,23 +373,29 @@ bool InternalFileHierarchyStorage::updateFile(const DirectoryStorage::EntryIndex return true; } +void InternalFileHierarchyStorage::deleteNode(uint32_t index) +{ + if(mNodes[index] != NULL) + { + delete mNodes[index] ; + mFreeNodes.push_back(index) ; + mNodes[index] = NULL ; + } +} + DirectoryStorage::EntryIndex InternalFileHierarchyStorage::allocateNewIndex() { - int found = -1; - for(uint32_t j=0;j& subdirs_hash,const std::vector& subfiles_array) @@ -534,8 +539,7 @@ bool InternalFileHierarchyStorage::updateDirEntry(const DirectoryStorage::EntryI std::cerr << "(EE) Cannot delete node of index " << it->second << " because it is not a file. Inconsistency error!" << std::endl; continue ; } - delete mNodes[it->second] ; - mNodes[it->second] = NULL ; + deleteNode(it->second) ; } // now update row and parent index for all subnodes @@ -740,6 +744,8 @@ bool InternalFileHierarchyStorage::check(std::string& error_string) // checks co std::vector hits(mNodes.size(),0) ; // count hits of children. Should be 1 for all in the end. Otherwise there's an error. hits[0] = 1 ; // because 0 is never the child of anyone + mFreeNodes.clear(); + for(uint32_t i=0;itype() == FileStorageNode::TYPE_DIR) { @@ -787,13 +793,15 @@ bool InternalFileHierarchyStorage::check(std::string& error_string) // checks co } } } + else if(mNodes[i] == NULL) + mFreeNodes.push_back(i) ; for(uint32_t i=0;i mFreeNodes ; // keeps a list of free nodes in order to make insert effcieint std::vector mNodes;// uses pointers to keep information about valid/invalid objects. void compress() ; // use empty space in the vector, mostly due to deleted entries. This is a complicated operation, mostly due to @@ -159,6 +160,10 @@ private: DirectoryStorage::EntryIndex allocateNewIndex(); + // Deletes an existing entry in mNodes, and keeps record of the indices that get freed. + + void deleteNode(DirectoryStorage::EntryIndex); + // Removes the given subdirectory from the parent node and all its pendign subdirs. Files are kept, and will go during the cleaning // phase. That allows to keep file information when moving them around. diff --git a/src/file_sharing/p3filelists.cc b/src/file_sharing/p3filelists.cc index c14c6df35..42d906781 100644 --- a/src/file_sharing/p3filelists.cc +++ b/src/file_sharing/p3filelists.cc @@ -542,7 +542,7 @@ uint32_t p3FileDatabase::locked_getFriendIndex(const RsPeerId& pid) mUpdateFlags |= P3FILELISTS_UPDATE_FLAG_REMOTE_MAP_CHANGED ; #ifdef DEBUG_P3FILELISTS - P3FILELISTS_DEBUG() << " adding missing remote dir entry for friend " << *it << ", with index " << friend_index << std::endl; + P3FILELISTS_DEBUG() << " adding missing remote dir entry for friend " << pid << ", with index " << it->second << std::endl; #endif } @@ -569,7 +569,7 @@ uint32_t p3FileDatabase::locked_getFriendIndex(const RsPeerId& pid) mUpdateFlags |= P3FILELISTS_UPDATE_FLAG_REMOTE_MAP_CHANGED ; #ifdef DEBUG_P3FILELISTS - P3FILELISTS_DEBUG() << " adding missing remote dir entry for friend " << *it << ", with index " << friend_index << std::endl; + P3FILELISTS_DEBUG() << " adding missing remote dir entry for friend " << pid << ", with index " << it->second << std::endl; #endif } diff --git a/src/libretroshare.pro b/src/libretroshare.pro index 1e18835b1..4f7449bf4 100644 --- a/src/libretroshare.pro +++ b/src/libretroshare.pro @@ -295,7 +295,7 @@ mac { OBJECTS_DIR = temp/obj MOC_DIR = temp/moc #DEFINES = WINDOWS_SYS WIN32 STATICLIB MINGW - DEFINES *= MINIUPNPC_VERSION=13 + #DEFINES *= MINIUPNPC_VERSION=13 CONFIG += upnp_miniupnpc CONFIG += c++11 @@ -305,7 +305,7 @@ mac { #CONFIG += zcnatassist # Beautiful Hack to fix 64bit file access. - QMAKE_CXXFLAGS *= -Dfseeko64=fseeko -Dftello64=ftello -Dfopen64=fopen -Dvstatfs64=vstatfs + QMAKE_CXXFLAGS *= -Dfseeko64=fseeko -Dftello64=ftello -Dfopen64=fopen -Dvstatfs64=vstatfs #GPG_ERROR_DIR = ../../../../libgpg-error-1.7 #GPGME_DIR = ../../../../gpgme-1.1.8 @@ -315,6 +315,7 @@ mac { DEPENDPATH += . $$INC_DIR INCLUDEPATH += . $$INC_DIR + INCLUDEPATH += ../../../. # We need a explicit path here, to force using the home version of sqlite3 that really encrypts the database. LIBS += /usr/local/lib/libsqlcipher.a diff --git a/src/util/rsthreads.cc b/src/util/rsthreads.cc index bf2f34042..fcf4483be 100644 --- a/src/util/rsthreads.cc +++ b/src/util/rsthreads.cc @@ -30,7 +30,17 @@ #include #include +#ifdef __APPLE__ +int __attribute__((weak)) pthread_setname_np(const char *__buf) ; +int RS_pthread_setname_np(pthread_t /*__target_thread*/, const char *__buf) { + return pthread_setname_np(__buf); +} +#else int __attribute__((weak)) pthread_setname_np(pthread_t __target_thread, const char *__buf) ; +int RS_pthread_setname_np(pthread_t __target_thread, const char *__buf) { + return pthread_setname_np(__target_thread, __buf); +} +#endif #ifdef RSMUTEX_DEBUG #include @@ -167,19 +177,21 @@ void RsThread::start(const std::string &threadName) // set name if(pthread_setname_np) - if(!threadName.empty()) - { - // thread names are restricted to 16 characters including the terminating null byte - if(threadName.length() > 15) - { + { + if(!threadName.empty()) + { + // thread names are restricted to 16 characters including the terminating null byte + if(threadName.length() > 15) + { #ifdef DEBUG_THREADS - THREAD_DEBUG << "RsThread::start called with to long name '" << name << "' truncating..." << std::endl; + THREAD_DEBUG << "RsThread::start called with to long name '" << name << "' truncating..." << std::endl; #endif - pthread_setname_np(mTid, threadName.substr(0, 15).c_str()); - } else { - pthread_setname_np(mTid, threadName.c_str()); - } - } + RS_pthread_setname_np(mTid, threadName.substr(0, 15).c_str()); + } else { + RS_pthread_setname_np(mTid, threadName.c_str()); + } + } + } } else { diff --git a/tests/librssimulator/librssimulator.pro b/tests/librssimulator/librssimulator.pro index 9ef336b57..94c942f53 100644 --- a/tests/librssimulator/librssimulator.pro +++ b/tests/librssimulator/librssimulator.pro @@ -182,33 +182,40 @@ win32 { ################################# MacOSX ########################################## mac { - QMAKE_CC = $${QMAKE_CXX} - OBJECTS_DIR = temp/obj - MOC_DIR = temp/moc - #DEFINES = WINDOWS_SYS WIN32 STATICLIB MINGW - #DEFINES *= MINIUPNPC_VERSION=13 - DESTDIR = lib + QMAKE_CC = $${QMAKE_CXX} + OBJECTS_DIR = temp/obj + MOC_DIR = temp/moc + #DEFINES = WINDOWS_SYS WIN32 STATICLIB MINGW + #DEFINES *= MINIUPNPC_VERSION=13 + DESTDIR = lib - CONFIG += upnp_miniupnpc + CONFIG += upnp_miniupnpc - # zeroconf disabled at the end of libretroshare.pro (but need the code) - CONFIG += zeroconf - CONFIG += zcnatassist + # zeroconf disabled at the end of libretroshare.pro (but need the code) + #CONFIG += zeroconf + #CONFIG += zcnatassist - # Beautiful Hack to fix 64bit file access. - QMAKE_CXXFLAGS *= -Dfseeko64=fseeko -Dftello64=ftello -Dfopen64=fopen -Dvstatfs64=vstatfs + # Beautiful Hack to fix 64bit file access. + QMAKE_CXXFLAGS *= -Dfseeko64=fseeko -Dftello64=ftello -Dfopen64=fopen -Dvstatfs64=vstatfs - UPNPC_DIR = ../../../miniupnpc-1.0 - #GPG_ERROR_DIR = ../../../../libgpg-error-1.7 - #GPGME_DIR = ../../../../gpgme-1.1.8 + #UPNPC_DIR = ../../../miniupnpc-1.0 + #GPG_ERROR_DIR = ../../../../libgpg-error-1.7 + #GPGME_DIR = ../../../../gpgme-1.1.8 + #OPENPGPSDK_DIR = ../../openpgpsdk/src + #INCLUDEPATH += . $${UPNPC_DIR} + #INCLUDEPATH += $${OPENPGPSDK_DIR} - OPENPGPSDK_DIR = ../../openpgpsdk/src + #for(lib, LIB_DIR):exists($$lib/libminiupnpc.a){ LIBS += $$lib/libminiupnpc.a} + for(lib, LIB_DIR):LIBS += -L"$$lib" + for(bin, BIN_DIR):LIBS += -L"$$bin" - INCLUDEPATH += . $${UPNPC_DIR} - INCLUDEPATH += $${OPENPGPSDK_DIR} + DEPENDPATH += . $$INC_DIR + INCLUDEPATH += . $$INC_DIR + INCLUDEPATH += ../../../. - #../openpgpsdk - #INCLUDEPATH += . $${UPNPC_DIR} $${GPGME_DIR}/src $${GPG_ERROR_DIR}/src + # We need a explicit path here, to force using the home version of sqlite3 that really encrypts the database. + LIBS += /usr/local/lib/libsqlcipher.a + #LIBS += -lsqlite3 } ################################# FreeBSD ########################################## diff --git a/tests/unittests/unittests.pro b/tests/unittests/unittests.pro index db4a881d7..46331e159 100644 --- a/tests/unittests/unittests.pro +++ b/tests/unittests/unittests.pro @@ -171,34 +171,35 @@ win32 { ##################################### MacOS ###################################### macx { - # ENABLE THIS OPTION FOR Univeral Binary BUILD. - CONFIG += ppc x86 - QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.4 + # ENABLE THIS OPTION FOR Univeral Binary BUILD. + #CONFIG += ppc x86 + #QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.4 CONFIG += version_detail_bash_script LIBS += ../../libretroshare/src/lib/libretroshare.a LIBS += ../librssimulator/lib/librssimulator.a LIBS += ../../openpgpsdk/src/lib/libops.a -lbz2 - LIBS += -lssl -lcrypto -lz - #LIBS += -lssl -lcrypto -lz -lgpgme -lgpg-error -lassuan - LIBS += ../../../miniupnpc-1.0/libminiupnpc.a + LIBS += -lssl -lcrypto -lz + #LIBS += -lssl -lcrypto -lz -lgpgme -lgpg-error -lassuan + for(lib, LIB_DIR):exists($$lib/libminiupnpc.a){ LIBS += $$lib/libminiupnpc.a} LIBS += -framework CoreFoundation LIBS += -framework Security - gxs { - LIBS += ../../supportlibs/pegmarkdown/lib/libpegmarkdown.a - LIBS += ../../../lib/libsqlcipher.a - #LIBS += -lsqlite3 + for(lib, LIB_DIR):LIBS += -L"$$lib" + for(bin, BIN_DIR):LIBS += -L"$$bin" - } + DEPENDPATH += . $$INC_DIR + INCLUDEPATH += . $$INC_DIR + #LIBS += ../../supportlibs/pegmarkdown/lib/libpegmarkdown.a + + # We need a explicit path here, to force using the home version of sqlite3 that really encrypts the database. + LIBS += /usr/local/lib/libsqlcipher.a + #LIBS += -lsqlite3 - INCLUDEPATH += . #DEFINES* = MAC_IDLE # for idle feature CONFIG -= uitools - - } ##################################### FreeBSD ######################################