Mercurial > hg > orthanc
changeset 2063:ed383e7a6753
cont
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 04 Jul 2016 15:50:11 +0200 |
parents | 40ffd0e8676a |
children | e92280e63d8d |
files | Core/MultiThreading/Semaphore.cpp Core/Toolbox.cpp Core/Toolbox.h OrthancServer/Scheduler/ServerScheduler.cpp Resources/CMake/BoostConfiguration.cmake |
diffstat | 5 files changed, 59 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/Core/MultiThreading/Semaphore.cpp Sat Jul 02 15:09:03 2016 +0200 +++ b/Core/MultiThreading/Semaphore.cpp Mon Jul 04 15:50:11 2016 +0200 @@ -40,10 +40,6 @@ { Semaphore::Semaphore(unsigned int count) : count_(count) { - if (count == 0) - { - throw OrthancException(ErrorCode_ParameterOutOfRange); - } } void Semaphore::Release()
--- a/Core/Toolbox.cpp Sat Jul 02 15:09:03 2016 +0200 +++ b/Core/Toolbox.cpp Mon Jul 04 15:50:11 2016 +0200 @@ -230,6 +230,7 @@ } +#if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1 void Toolbox::ReadFile(std::string& content, const std::string& path) { @@ -255,8 +256,10 @@ f.close(); } +#endif +#if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1 bool Toolbox::ReadHeader(std::string& header, const std::string& path, size_t headerSize) @@ -300,8 +303,10 @@ return full; } +#endif +#if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1 void Toolbox::WriteFile(const void* content, size_t size, const std::string& path) @@ -320,16 +325,20 @@ f.close(); } +#endif +#if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1 void Toolbox::WriteFile(const std::string& content, const std::string& path) { WriteFile(content.size() > 0 ? content.c_str() : NULL, content.size(), path); } +#endif +#if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1 void Toolbox::RemoveFile(const std::string& path) { if (boost::filesystem::exists(path)) @@ -344,7 +353,7 @@ } } } - +#endif void Toolbox::SplitUriComponents(UriComponents& components, @@ -515,6 +524,7 @@ +#if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1 uint64_t Toolbox::GetFileSize(const std::string& path) { try @@ -526,6 +536,7 @@ throw OrthancException(ErrorCode_InexistentFile); } } +#endif #if !defined(ORTHANC_ENABLE_MD5) || ORTHANC_ENABLE_MD5 == 1 @@ -1144,6 +1155,7 @@ } +#if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1 void Toolbox::MakeDirectory(const std::string& path) { if (boost::filesystem::exists(path)) @@ -1161,12 +1173,15 @@ } } } +#endif +#if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1 bool Toolbox::IsExistingFile(const std::string& path) { return boost::filesystem::exists(path); } +#endif #if ORTHANC_PUGIXML_ENABLED == 1 @@ -1468,6 +1483,7 @@ } +#if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1 bool Toolbox::IsRegularFile(const std::string& path) { namespace fs = boost::filesystem; @@ -1487,6 +1503,7 @@ return false; } +#endif FILE* Toolbox::OpenFile(const std::string& path,
--- a/Core/Toolbox.h Sat Jul 02 15:09:03 2016 +0200 +++ b/Core/Toolbox.h Mon Jul 04 15:50:11 2016 +0200 @@ -65,25 +65,35 @@ void ToLowerCase(std::string& result, const std::string& source); +#if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1 void ReadFile(std::string& content, const std::string& path); +#endif +#if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1 bool ReadHeader(std::string& header, const std::string& path, size_t headerSize); +#endif +#if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1 void WriteFile(const std::string& content, const std::string& path); +#endif +#if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1 void WriteFile(const void* content, size_t size, const std::string& path); +#endif #if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1 void USleep(uint64_t microSeconds); #endif +#if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1 void RemoveFile(const std::string& path); +#endif void SplitUriComponents(UriComponents& components, const std::string& uri); @@ -100,7 +110,9 @@ std::string FlattenUri(const UriComponents& components, size_t fromLevel = 0); +#if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1 uint64_t GetFileSize(const std::string& path); +#endif #if !defined(ORTHANC_ENABLE_MD5) || ORTHANC_ENABLE_MD5 == 1 void ComputeMD5(std::string& result, @@ -177,9 +189,13 @@ const std::string& source, char separator); +#if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1 void MakeDirectory(const std::string& path); +#endif +#if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1 bool IsExistingFile(const std::string& path); +#endif #if ORTHANC_PUGIXML_ENABLED == 1 void JsonToXml(std::string& target, @@ -201,7 +217,9 @@ int GetProcessId(); +#if !defined(ORTHANC_SANDBOXED) || ORTHANC_SANDBOXED != 1 bool IsRegularFile(const std::string& path); +#endif FILE* OpenFile(const std::string& path, FileMode mode);
--- a/OrthancServer/Scheduler/ServerScheduler.cpp Sat Jul 02 15:09:03 2016 +0200 +++ b/OrthancServer/Scheduler/ServerScheduler.cpp Mon Jul 04 15:50:11 2016 +0200 @@ -192,6 +192,11 @@ ServerScheduler::ServerScheduler(unsigned int maxJobs) : availableJob_(maxJobs) { + if (maxJobs == 0) + { + throw OrthancException(ErrorCode_ParameterOutOfRange); + } + finish_ = false; worker_ = boost::thread(Worker, this); }
--- a/Resources/CMake/BoostConfiguration.cmake Sat Jul 02 15:09:03 2016 +0200 +++ b/Resources/CMake/BoostConfiguration.cmake Mon Jul 04 15:50:11 2016 +0200 @@ -57,6 +57,7 @@ ${CMAKE_SYSTEM_NAME} STREQUAL "kFreeBSD" OR ${CMAKE_SYSTEM_NAME} STREQUAL "PNaCl") list(APPEND BOOST_SOURCES + ${BOOST_SOURCES_DIR}/libs/atomic/src/lockpool.cpp ${BOOST_SOURCES_DIR}/libs/thread/src/pthread/once.cpp ${BOOST_SOURCES_DIR}/libs/thread/src/pthread/thread.cpp ) @@ -109,14 +110,27 @@ list(APPEND BOOST_SOURCES ${BOOST_REGEX_SOURCES} ${BOOST_SOURCES_DIR}/libs/date_time/src/gregorian/greg_month.cpp - ${BOOST_FILESYSTEM_SOURCES_DIR}/codecvt_error_category.cpp - ${BOOST_FILESYSTEM_SOURCES_DIR}/operations.cpp - ${BOOST_FILESYSTEM_SOURCES_DIR}/path.cpp - ${BOOST_FILESYSTEM_SOURCES_DIR}/path_traits.cpp ${BOOST_SOURCES_DIR}/libs/locale/src/encoding/codepage.cpp ${BOOST_SOURCES_DIR}/libs/system/src/error_code.cpp ) + if (${CMAKE_SYSTEM_NAME} STREQUAL "PNaCl") + # boost::filesystem is not available on PNaCl + add_definitions( + -DBOOST_HAS_FILESYSTEM_V3=0 + -D__INTEGRITY=1 + -DORTHANC_SANDBOXED=1 + ) + else() + add_definitions(-DBOOST_HAS_FILESYSTEM_V3=1) + list(APPEND BOOST_SOURCES + ${BOOST_FILESYSTEM_SOURCES_DIR}/codecvt_error_category.cpp + ${BOOST_FILESYSTEM_SOURCES_DIR}/operations.cpp + ${BOOST_FILESYSTEM_SOURCES_DIR}/path.cpp + ${BOOST_FILESYSTEM_SOURCES_DIR}/path_traits.cpp + ) + endif() + if (USE_BOOST_LOCALE_BACKENDS) if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" OR @@ -178,7 +192,6 @@ -DBOOST_SYSTEM_NO_LIB -DBOOST_LOCALE_NO_LIB -DBOOST_HAS_LOCALE=1 - -DBOOST_HAS_FILESYSTEM_V3=1 ) if (CMAKE_COMPILER_IS_GNUCXX)