comparison OrthancServer/main.cpp @ 1193:e95e7f9eba96

fix crash when stopping Orthanc during a DICOM connection
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 20 Oct 2014 16:46:40 +0200
parents fd3128b2cf45
children a843ee8bb903
comparison
equal deleted inserted replaced
1192:2036c3865990 1193:e95e7f9eba96
54 #include "../Plugins/Engine/OrthancPlugins.h" 54 #include "../Plugins/Engine/OrthancPlugins.h"
55 55
56 using namespace Orthanc; 56 using namespace Orthanc;
57 57
58 58
59 #define ENABLE_PLUGINS 1
60
59 61
60 class OrthancStoreRequestHandler : public IStoreRequestHandler 62 class OrthancStoreRequestHandler : public IStoreRequestHandler
61 { 63 {
62 private: 64 private:
63 ServerContext& server_; 65 ServerContext& server_;
507 EmbeddedResourceHttpHandler staticResources("/app", EmbeddedResources::ORTHANC_EXPLORER); 509 EmbeddedResourceHttpHandler staticResources("/app", EmbeddedResources::ORTHANC_EXPLORER);
508 #else 510 #else
509 FilesystemHttpHandler staticResources("/app", ORTHANC_PATH "/OrthancExplorer"); 511 FilesystemHttpHandler staticResources("/app", ORTHANC_PATH "/OrthancExplorer");
510 #endif 512 #endif
511 513
514 #if ENABLE_PLUGINS == 1
512 OrthancPlugins orthancPlugins(context); 515 OrthancPlugins orthancPlugins(context);
513 orthancPlugins.SetOrthancRestApi(restApi); 516 orthancPlugins.SetOrthancRestApi(restApi);
514 517
515 PluginsManager pluginsManager; 518 PluginsManager pluginsManager;
516 pluginsManager.RegisterServiceProvider(orthancPlugins); 519 pluginsManager.RegisterServiceProvider(orthancPlugins);
517 LoadPlugins(pluginsManager); 520 LoadPlugins(pluginsManager);
518
519 httpServer.RegisterHandler(orthancPlugins); 521 httpServer.RegisterHandler(orthancPlugins);
522 context.SetOrthancPlugins(orthancPlugins);
523 #endif
524
520 httpServer.RegisterHandler(staticResources); 525 httpServer.RegisterHandler(staticResources);
521 httpServer.RegisterHandler(restApi); 526 httpServer.RegisterHandler(restApi);
522 orthancPlugins.SetOrthancRestApi(restApi); 527
523 context.SetOrthancPlugins(orthancPlugins); 528
524 529 #if ENABLE_PLUGINS == 1
525
526 // Prepare the storage area 530 // Prepare the storage area
527 if (orthancPlugins.HasStorageArea()) 531 if (orthancPlugins.HasStorageArea())
528 { 532 {
529 LOG(WARNING) << "Using a custom storage area from plugins"; 533 LOG(WARNING) << "Using a custom storage area from plugins";
530 storage.reset(orthancPlugins.GetStorageArea()); 534 storage.reset(orthancPlugins.GetStorageArea());
531 } 535 }
532 else 536 else
537 #endif
533 { 538 {
534 boost::filesystem::path storageDirectory = Configuration::InterpretStringParameterAsPath(storageDirectoryStr); 539 boost::filesystem::path storageDirectory = Configuration::InterpretStringParameterAsPath(storageDirectoryStr);
535 LOG(WARNING) << "Storage directory: " << storageDirectory; 540 LOG(WARNING) << "Storage directory: " << storageDirectory;
536 if (Configuration::GetGlobalBoolParameter("StoreDicom", true)) 541 if (Configuration::GetGlobalBoolParameter("StoreDicom", true))
537 { 542 {
577 LOG(WARNING) << "Reset request received, restarting Orthanc"; 582 LOG(WARNING) << "Reset request received, restarting Orthanc";
578 } 583 }
579 584
580 // We're done 585 // We're done
581 LOG(WARNING) << "Orthanc is stopping"; 586 LOG(WARNING) << "Orthanc is stopping";
587
588 dicomServer.Stop();
589 httpServer.Stop();
582 } 590 }
583 591
584 serverFactory.Done(); 592 serverFactory.Done();
585 593
586 return isReset; 594 return isReset;