# HG changeset patch # User Sebastien Jodogne # Date 1413816400 -7200 # Node ID e95e7f9eba9614070758e44c1d6686caebe1f939 # Parent 2036c38659907d76b603c90730e38b8fb5bc808a fix crash when stopping Orthanc during a DICOM connection diff -r 2036c3865990 -r e95e7f9eba96 OrthancServer/DicomProtocol/DicomServer.cpp --- a/OrthancServer/DicomProtocol/DicomServer.cpp Thu Oct 16 11:24:03 2014 +0200 +++ b/OrthancServer/DicomProtocol/DicomServer.cpp Mon Oct 20 16:46:40 2014 +0200 @@ -190,6 +190,11 @@ LOG(INFO) << "DICOM server stopping"; + if (server->isThreaded_) + { + server->bagOfDispatchers_.StopAll(); + } + /* drop the network, i.e. free memory of T_ASC_Network* structure. This call */ /* is the counterpart of ASC_initializeNetwork(...) which was called above. */ cond = ASC_dropNetwork(&net); @@ -403,8 +408,6 @@ { pimpl_->thread_.join(); } - - bagOfDispatchers_.StopAll(); } bool DicomServer::IsMyAETitle(const std::string& aet) const diff -r 2036c3865990 -r e95e7f9eba96 OrthancServer/main.cpp --- a/OrthancServer/main.cpp Thu Oct 16 11:24:03 2014 +0200 +++ b/OrthancServer/main.cpp Mon Oct 20 16:46:40 2014 +0200 @@ -56,6 +56,8 @@ using namespace Orthanc; +#define ENABLE_PLUGINS 1 + class OrthancStoreRequestHandler : public IStoreRequestHandler { @@ -509,20 +511,22 @@ FilesystemHttpHandler staticResources("/app", ORTHANC_PATH "/OrthancExplorer"); #endif +#if ENABLE_PLUGINS == 1 OrthancPlugins orthancPlugins(context); orthancPlugins.SetOrthancRestApi(restApi); PluginsManager pluginsManager; pluginsManager.RegisterServiceProvider(orthancPlugins); LoadPlugins(pluginsManager); + httpServer.RegisterHandler(orthancPlugins); + context.SetOrthancPlugins(orthancPlugins); +#endif - httpServer.RegisterHandler(orthancPlugins); httpServer.RegisterHandler(staticResources); httpServer.RegisterHandler(restApi); - orthancPlugins.SetOrthancRestApi(restApi); - context.SetOrthancPlugins(orthancPlugins); +#if ENABLE_PLUGINS == 1 // Prepare the storage area if (orthancPlugins.HasStorageArea()) { @@ -530,6 +534,7 @@ storage.reset(orthancPlugins.GetStorageArea()); } else +#endif { boost::filesystem::path storageDirectory = Configuration::InterpretStringParameterAsPath(storageDirectoryStr); LOG(WARNING) << "Storage directory: " << storageDirectory; @@ -579,6 +584,9 @@ // We're done LOG(WARNING) << "Orthanc is stopping"; + + dicomServer.Stop(); + httpServer.Stop(); } serverFactory.Done();