comparison OrthancFramework/Sources/DicomNetworking/DicomServer.cpp @ 4451:f4dbdb2dcba6

new configuration option "MaximumPduLength" to tune the maximum PDU length
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 18 Jan 2021 14:51:52 +0100
parents 5209a9ff6e38
children fe7c2be5bce2
comparison
equal deleted inserted replaced
4450:9bf2f9e0af47 4451:f4dbdb2dcba6
26 #include "../Logging.h" 26 #include "../Logging.h"
27 #include "../MultiThreading/RunnableWorkersPool.h" 27 #include "../MultiThreading/RunnableWorkersPool.h"
28 #include "../OrthancException.h" 28 #include "../OrthancException.h"
29 #include "../SystemToolbox.h" 29 #include "../SystemToolbox.h"
30 #include "../Toolbox.h" 30 #include "../Toolbox.h"
31 #include "DicomAssociationParameters.h"
31 #include "Internals/CommandDispatcher.h" 32 #include "Internals/CommandDispatcher.h"
32 33
33 #include <boost/thread.hpp> 34 #include <boost/thread.hpp>
34 35
35 #if ORTHANC_ENABLE_SSL == 1 36 #if ORTHANC_ENABLE_SSL == 1
54 #endif 55 #endif
55 }; 56 };
56 57
57 58
58 void DicomServer::ServerThread(DicomServer* server, 59 void DicomServer::ServerThread(DicomServer* server,
60 unsigned int maximumPduLength,
59 bool useDicomTls) 61 bool useDicomTls)
60 { 62 {
61 CLOG(INFO, DICOM) << "DICOM server started"; 63 CLOG(INFO, DICOM) << "DICOM server started";
62 64
63 while (server->continue_) 65 while (server->continue_)
64 { 66 {
65 /* receive an association and acknowledge or reject it. If the association was */ 67 /* receive an association and acknowledge or reject it. If the association was */
66 /* acknowledged, offer corresponding services and invoke one or more if required. */ 68 /* acknowledged, offer corresponding services and invoke one or more if required. */
67 std::unique_ptr<Internals::CommandDispatcher> dispatcher( 69 std::unique_ptr<Internals::CommandDispatcher> dispatcher(
68 Internals::AcceptAssociation(*server, server->pimpl_->network_, useDicomTls)); 70 Internals::AcceptAssociation(*server, server->pimpl_->network_, maximumPduLength, useDicomTls));
69 71
70 try 72 try
71 { 73 {
72 if (dispatcher.get() != NULL) 74 if (dispatcher.get() != NULL)
73 { 75 {
84 } 86 }
85 87
86 88
87 DicomServer::DicomServer() : 89 DicomServer::DicomServer() :
88 pimpl_(new PImpl), 90 pimpl_(new PImpl),
91 checkCalledAet_(true),
89 aet_("ANY-SCP"), 92 aet_("ANY-SCP"),
90 useDicomTls_(false) 93 port_(104),
91 { 94 continue_(false),
92 port_ = 104; 95 associationTimeout_(30),
93 modalities_ = NULL; 96 modalities_(NULL),
94 findRequestHandlerFactory_ = NULL; 97 findRequestHandlerFactory_(NULL),
95 moveRequestHandlerFactory_ = NULL; 98 moveRequestHandlerFactory_(NULL),
96 getRequestHandlerFactory_ = NULL; 99 getRequestHandlerFactory_(NULL),
97 storeRequestHandlerFactory_ = NULL; 100 storeRequestHandlerFactory_(NULL),
98 worklistRequestHandlerFactory_ = NULL; 101 worklistRequestHandlerFactory_(NULL),
99 storageCommitmentFactory_ = NULL; 102 storageCommitmentFactory_(NULL),
100 applicationEntityFilter_ = NULL; 103 applicationEntityFilter_(NULL),
101 checkCalledAet_ = true; 104 useDicomTls_(false),
102 associationTimeout_ = 30; 105 maximumPduLength_(ASC_DEFAULTMAXPDU)
103 continue_ = false; 106 {
104 } 107 }
105 108
106 DicomServer::~DicomServer() 109 DicomServer::~DicomServer()
107 { 110 {
108 if (continue_) 111 if (continue_)
418 CLOG(INFO, DICOM) << "Orthanc SCP will *not* use DICOM TLS"; 421 CLOG(INFO, DICOM) << "Orthanc SCP will *not* use DICOM TLS";
419 #endif 422 #endif
420 423
421 continue_ = true; 424 continue_ = true;
422 pimpl_->workers_.reset(new RunnableWorkersPool(4)); // Use 4 workers - TODO as a parameter? 425 pimpl_->workers_.reset(new RunnableWorkersPool(4)); // Use 4 workers - TODO as a parameter?
423 pimpl_->thread_ = boost::thread(ServerThread, this, useDicomTls_); 426 pimpl_->thread_ = boost::thread(ServerThread, this, maximumPduLength_, useDicomTls_);
424 } 427 }
425 428
426 429
427 void DicomServer::Stop() 430 void DicomServer::Stop()
428 { 431 {
557 560
558 const std::string& DicomServer::GetTrustedCertificatesPath() const 561 const std::string& DicomServer::GetTrustedCertificatesPath() const
559 { 562 {
560 return trustedCertificatesPath_; 563 return trustedCertificatesPath_;
561 } 564 }
565
566 unsigned int DicomServer::GetMaximumPduLength() const
567 {
568 return maximumPduLength_;
569 }
570
571 void DicomServer::SetMaximumPduLength(unsigned int pdu)
572 {
573 DicomAssociationParameters::CheckMaximumPduLength(pdu);
574
575 Stop();
576 maximumPduLength_ = pdu;
577 }
562 } 578 }