Mercurial > hg > orthanc
comparison OrthancServer/ServerIndex.cpp @ 513:935e8c7e0b18
fix
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 16 Aug 2013 17:11:45 +0200 |
parents | 3b735fdf320b |
children | 2c739f76d0bb |
comparison
equal
deleted
inserted
replaced
511:3b735fdf320b | 513:935e8c7e0b18 |
---|---|
1414 { | 1414 { |
1415 // Check for stable resources each second | 1415 // Check for stable resources each second |
1416 boost::this_thread::sleep(boost::posix_time::seconds(1)); | 1416 boost::this_thread::sleep(boost::posix_time::seconds(1)); |
1417 | 1417 |
1418 boost::mutex::scoped_lock lock(that->mutex_); | 1418 boost::mutex::scoped_lock lock(that->mutex_); |
1419 | |
1419 while (!that->unstableResources_.IsEmpty() && | 1420 while (!that->unstableResources_.IsEmpty() && |
1420 that->unstableResources_.GetOldestPayload().GetAge() > static_cast<unsigned int>(stableAge)) | 1421 that->unstableResources_.GetOldestPayload().GetAge() > static_cast<unsigned int>(stableAge)) |
1421 { | 1422 { |
1422 // This DICOM resource has not received any new instance for | 1423 // This DICOM resource has not received any new instance for |
1423 // some time. It can be considered as stable. | 1424 // some time. It can be considered as stable. |
1424 | 1425 |
1425 UnstableResourcePayload payload; | 1426 UnstableResourcePayload payload; |
1426 int64_t id = that->unstableResources_.RemoveOldest(payload); | 1427 int64_t id = that->unstableResources_.RemoveOldest(payload); |
1427 | 1428 |
1428 switch (payload.type_) | 1429 // Ensure that the resource is still existing before logging the change |
1430 if (that->db_->IsExistingResource(id)) | |
1429 { | 1431 { |
1430 case Orthanc::ResourceType_Patient: | 1432 switch (payload.type_) |
1431 that->db_->LogChange(ChangeType_StablePatient, id, ResourceType_Patient); | 1433 { |
1432 break; | 1434 case Orthanc::ResourceType_Patient: |
1433 | 1435 that->db_->LogChange(ChangeType_StablePatient, id, ResourceType_Patient); |
1434 case Orthanc::ResourceType_Study: | 1436 break; |
1435 that->db_->LogChange(ChangeType_StableStudy, id, ResourceType_Study); | 1437 |
1436 break; | 1438 case Orthanc::ResourceType_Study: |
1437 | 1439 that->db_->LogChange(ChangeType_StableStudy, id, ResourceType_Study); |
1438 case Orthanc::ResourceType_Series: | 1440 break; |
1439 that->db_->LogChange(ChangeType_StableSeries, id, ResourceType_Series); | 1441 |
1440 break; | 1442 case Orthanc::ResourceType_Series: |
1441 | 1443 that->db_->LogChange(ChangeType_StableSeries, id, ResourceType_Series); |
1442 default: | 1444 break; |
1443 throw OrthancException(ErrorCode_InternalError); | 1445 |
1446 default: | |
1447 throw OrthancException(ErrorCode_InternalError); | |
1448 } | |
1449 | |
1450 //LOG(INFO) << "Stable resource: " << EnumerationToString(payload.type_) << " " << id; | |
1444 } | 1451 } |
1445 | |
1446 //LOG(INFO) << "Stable resource: " << EnumerationToString(payload.type_) << " " << id; | |
1447 } | 1452 } |
1448 } | 1453 } |
1449 | 1454 |
1450 LOG(INFO) << "Closing the monitor thread for stable resources"; | 1455 LOG(INFO) << "Closing the monitor thread for stable resources"; |
1451 } | 1456 } |