comparison OrthancServer/DicomProtocol/DicomServer.cpp @ 1453:c0bdc47165ef

code to warn about possible threading problems
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 02 Jul 2015 12:26:44 +0200
parents 6e7e5ed91c2d
children 9de4fa64e29c
comparison
equal deleted inserted replaced
1452:b737acb13da5 1453:c0bdc47165ef
221 started_ = false; 221 started_ = false;
222 } 222 }
223 223
224 DicomServer::~DicomServer() 224 DicomServer::~DicomServer()
225 { 225 {
226 Stop(); 226 if (continue_)
227 {
228 LOG(ERROR) << "INTERNAL ERROR: DicomServer::Stop() should be invoked manually to avoid mess in the destruction order!";
229 Stop();
230 }
227 } 231 }
228 232
229 void DicomServer::SetPortNumber(uint16_t port) 233 void DicomServer::SetPortNumber(uint16_t port)
230 { 234 {
231 Stop(); 235 Stop();
407 { 411 {
408 Toolbox::USleep(50000); // Wait 50ms 412 Toolbox::USleep(50000); // Wait 50ms
409 } 413 }
410 } 414 }
411 415
416
412 void DicomServer::Stop() 417 void DicomServer::Stop()
413 { 418 {
414 continue_ = false; 419 if (continue_)
415 420 {
416 if (pimpl_->thread_.joinable()) 421 continue_ = false;
417 { 422
418 pimpl_->thread_.join(); 423 if (pimpl_->thread_.joinable())
419 } 424 {
420 } 425 pimpl_->thread_.join();
426 }
427 }
428 }
429
421 430
422 bool DicomServer::IsMyAETitle(const std::string& aet) const 431 bool DicomServer::IsMyAETitle(const std::string& aet) const
423 { 432 {
424 if (!HasCalledApplicationEntityTitleCheck()) 433 if (!HasCalledApplicationEntityTitleCheck())
425 { 434 {