Skip to content

Commit

Permalink
Fixed deadlock for bulk change certificate as well; #297
Browse files Browse the repository at this point in the history
  • Loading branch information
phax committed Oct 17, 2024
1 parent d1e3d1a commit 2a4a2f4
Showing 1 changed file with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
import com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager;
import com.helger.phoss.smp.domain.serviceinfo.ISMPEndpoint;
import com.helger.phoss.smp.domain.serviceinfo.ISMPProcess;
import com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformation;
import com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformationManager;
import com.helger.phoss.smp.domain.serviceinfo.SMPEndpoint;
import com.helger.phoss.smp.ui.AbstractSMPWebPage;
Expand Down Expand Up @@ -123,7 +124,7 @@ public LongRunningJobResult createLongRunningJobResult ()
// Modify all endpoints
final MutableInt aChangedEndpoints = new MutableInt (0);
final MutableInt aSaveErrors = new MutableInt (0);
final ICommonsSortedSet <String> aChangedServiceGroup = new CommonsTreeSet <> ();
final ICommonsList <ISMPServiceInformation> aChangedSIs = new CommonsArrayList <> ();
aServiceInfoMgr.forEachSMPServiceInformation (aSI -> {
boolean bChanged = false;
for (final ISMPProcess aProcess : aSI.getAllProcesses ())
Expand All @@ -136,12 +137,20 @@ public LongRunningJobResult createLongRunningJobResult ()
}
if (bChanged)
{
if (aServiceInfoMgr.mergeSMPServiceInformation (aSI).isFailure ())
aSaveErrors.inc ();
aChangedServiceGroup.add (aSI.getServiceGroupID ());
// Remember and do not merge here to avoid deadlock
aChangedSIs.add (aSI);
}
});

// Write out of read-lock
final ICommonsSortedSet <String> aChangedServiceGroup = new CommonsTreeSet <> ();
for (final var aSI : aChangedSIs)
{
if (aServiceInfoMgr.mergeSMPServiceInformation (aSI).isFailure ())
aSaveErrors.inc ();
aChangedServiceGroup.add (aSI.getServiceGroupID ());
}

final IHCNode aRes;
if (aChangedEndpoints.isGT0 ())
{
Expand Down

0 comments on commit 2a4a2f4

Please sign in to comment.