comparison OrthancServer/OrthancRestApi/OrthancRestResources.cpp @ 959:bd5659f2a50a

fix possible race condition
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 25 Jun 2014 21:53:50 +0200
parents 1fbe89dc18b5
children abac5c83134f
comparison
equal deleted inserted replaced
958:1fbe89dc18b5 959:bd5659f2a50a
597 std::string publicId = call.GetUriComponent("id", ""); 597 std::string publicId = call.GetUriComponent("id", "");
598 598
599 // Retrieve all the instances of this patient/study/series 599 // Retrieve all the instances of this patient/study/series
600 typedef std::list<std::string> Instances; 600 typedef std::list<std::string> Instances;
601 Instances instances; 601 Instances instances;
602 context.GetIndex().GetChildInstances(instances, publicId); 602 context.GetIndex().GetChildInstances(instances, publicId); // (*)
603 603
604 // Loop over the instances 604 // Loop over the instances
605 bool isFirst = true; 605 bool isFirst = true;
606 Json::Value shared = Json::objectValue; 606 Json::Value shared = Json::objectValue;
607 607
608 for (Instances::const_iterator it = instances.begin(); 608 for (Instances::const_iterator it = instances.begin();
609 it != instances.end(); it++) 609 it != instances.end(); it++)
610 { 610 {
611 // Get the tags of the current instance, in the simplified format 611 // Get the tags of the current instance, in the simplified format
612 Json::Value full, simplified; 612 Json::Value full, simplified;
613 context.ReadJson(full, *it); 613
614 try
615 {
616 context.ReadJson(full, *it);
617 }
618 catch (OrthancException&)
619 {
620 // Race condition: This instance has been removed since
621 // (*). Ignore this instance.
622 continue;
623 }
624
614 SimplifyTags(simplified, full); 625 SimplifyTags(simplified, full);
615 626
616 if (simplified.type() != Json::objectValue) 627 if (simplified.type() != Json::objectValue)
617 { 628 {
618 return; // Error 629 return; // Error