Mercurial > hg > orthanc
comparison OrthancServer/Internals/CommandDispatcher.cpp @ 2134:ddc75c6c712d
Avoid hard crash if not enough memory
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 09 Nov 2016 12:04:09 +0100 |
parents | 879f3be759ef |
children | a3a65de1840f |
comparison
equal
deleted
inserted
replaced
2133:15ae532af70e | 2134:ddc75c6c712d |
---|---|
379 | 379 |
380 | 380 |
381 | 381 |
382 OFCondition AssociationCleanup(T_ASC_Association *assoc) | 382 OFCondition AssociationCleanup(T_ASC_Association *assoc) |
383 { | 383 { |
384 OFString temp_str; | |
385 OFCondition cond = ASC_dropSCPAssociation(assoc); | 384 OFCondition cond = ASC_dropSCPAssociation(assoc); |
386 if (cond.bad()) | 385 if (cond.bad()) |
387 { | 386 { |
388 LOG(FATAL) << cond.text(); | 387 LOG(FATAL) << cond.text(); |
389 return cond; | 388 return cond; |
693 | 692 |
694 IApplicationEntityFilter* filter = server.HasApplicationEntityFilter() ? &server.GetApplicationEntityFilter() : NULL; | 693 IApplicationEntityFilter* filter = server.HasApplicationEntityFilter() ? &server.GetApplicationEntityFilter() : NULL; |
695 return new CommandDispatcher(server, assoc, remoteIp, remoteAet, calledAet, filter); | 694 return new CommandDispatcher(server, assoc, remoteIp, remoteAet, calledAet, filter); |
696 } | 695 } |
697 | 696 |
697 | |
698 CommandDispatcher::CommandDispatcher(const DicomServer& server, | |
699 T_ASC_Association* assoc, | |
700 const std::string& remoteIp, | |
701 const std::string& remoteAet, | |
702 const std::string& calledAet, | |
703 IApplicationEntityFilter* filter) : | |
704 server_(server), | |
705 assoc_(assoc), | |
706 remoteIp_(remoteIp), | |
707 remoteAet_(remoteAet), | |
708 calledAet_(calledAet), | |
709 filter_(filter) | |
710 { | |
711 associationTimeout_ = server.GetAssociationTimeout(); | |
712 elapsedTimeSinceLastCommand_ = 0; | |
713 } | |
714 | |
715 | |
716 CommandDispatcher::~CommandDispatcher() | |
717 { | |
718 try | |
719 { | |
720 AssociationCleanup(assoc_); | |
721 } | |
722 catch (...) | |
723 { | |
724 LOG(ERROR) << "Some association was not cleanly aborted"; | |
725 } | |
726 } | |
727 | |
728 | |
698 bool CommandDispatcher::Step() | 729 bool CommandDispatcher::Step() |
699 /* | 730 /* |
700 * This function receives DIMSE commmands over the network connection | 731 * This function receives DIMSE commmands over the network connection |
701 * and handles these commands correspondingly. Note that in case of | 732 * and handles these commands correspondingly. Note that in case of |
702 * storscp only C-ECHO-RQ and C-STORE-RQ commands can be processed. | 733 * storscp only C-ECHO-RQ and C-STORE-RQ commands can be processed. |