forked from Qortal/qortal
Synchronize arbitrary data list removals, as it seems that SynchronizedList and SynchronizedMap aren't overriding removeIf() with a thread-safe version.
This commit is contained in:
parent
0d0ccfd0ac
commit
e5f88fe2f4
@ -75,8 +75,12 @@ public class ArbitraryDataBuildManager extends Thread {
|
||||
if (now == null) {
|
||||
return;
|
||||
}
|
||||
arbitraryDataBuildQueue.entrySet().removeIf(entry -> entry.getValue().hasReachedBuildTimeout(now));
|
||||
arbitraryDataFailedBuilds.entrySet().removeIf(entry -> entry.getValue().hasReachedFailureTimeout(now));
|
||||
synchronized (arbitraryDataBuildQueue) {
|
||||
arbitraryDataBuildQueue.entrySet().removeIf(entry -> entry.getValue().hasReachedBuildTimeout(now));
|
||||
}
|
||||
synchronized (arbitraryDataFailedBuilds) {
|
||||
arbitraryDataFailedBuilds.entrySet().removeIf(entry -> entry.getValue().hasReachedFailureTimeout(now));
|
||||
}
|
||||
}
|
||||
|
||||
// Build queue
|
||||
|
@ -84,7 +84,9 @@ public class ArbitraryDataFileListManager {
|
||||
return;
|
||||
}
|
||||
final long requestMinimumTimestamp = now - ArbitraryDataManager.ARBITRARY_REQUEST_TIMEOUT;
|
||||
arbitraryDataFileListRequests.entrySet().removeIf(entry -> entry.getValue().getC() == null || entry.getValue().getC() < requestMinimumTimestamp);
|
||||
synchronized (arbitraryDataFileListRequests) {
|
||||
arbitraryDataFileListRequests.entrySet().removeIf(entry -> entry.getValue().getC() == null || entry.getValue().getC() < requestMinimumTimestamp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -101,14 +101,22 @@ public class ArbitraryDataFileManager extends Thread {
|
||||
return;
|
||||
}
|
||||
final long requestMinimumTimestamp = now - ArbitraryDataManager.getInstance().ARBITRARY_REQUEST_TIMEOUT;
|
||||
arbitraryDataFileRequests.entrySet().removeIf(entry -> entry.getValue() == null || entry.getValue() < requestMinimumTimestamp);
|
||||
synchronized (arbitraryDataFileRequests) {
|
||||
arbitraryDataFileRequests.entrySet().removeIf(entry -> entry.getValue() == null || entry.getValue() < requestMinimumTimestamp);
|
||||
}
|
||||
|
||||
final long relayMinimumTimestamp = now - ArbitraryDataManager.getInstance().ARBITRARY_RELAY_TIMEOUT;
|
||||
arbitraryRelayMap.removeIf(entry -> entry == null || entry.getTimestamp() == null || entry.getTimestamp() < relayMinimumTimestamp);
|
||||
arbitraryDataFileHashResponses.removeIf(entry -> entry.getTimestamp() < relayMinimumTimestamp);
|
||||
synchronized (arbitraryRelayMap) {
|
||||
arbitraryRelayMap.removeIf(entry -> entry == null || entry.getTimestamp() == null || entry.getTimestamp() < relayMinimumTimestamp);
|
||||
}
|
||||
synchronized (arbitraryDataFileHashResponses) {
|
||||
arbitraryDataFileHashResponses.removeIf(entry -> entry.getTimestamp() < relayMinimumTimestamp);
|
||||
}
|
||||
|
||||
final long directConnectionInfoMinimumTimestamp = now - ArbitraryDataManager.getInstance().ARBITRARY_DIRECT_CONNECTION_INFO_TIMEOUT;
|
||||
directConnectionInfo.removeIf(entry -> entry.getTimestamp() < directConnectionInfoMinimumTimestamp);
|
||||
synchronized (directConnectionInfo) {
|
||||
directConnectionInfo.removeIf(entry -> entry.getTimestamp() < directConnectionInfoMinimumTimestamp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -484,7 +492,9 @@ public class ArbitraryDataFileManager extends Thread {
|
||||
}
|
||||
|
||||
private void removeFromRelayMap(ArbitraryRelayInfo entry) {
|
||||
arbitraryRelayMap.removeIf(relayInfo -> relayInfo.equals(entry));
|
||||
synchronized (arbitraryRelayMap) {
|
||||
arbitraryRelayMap.removeIf(relayInfo -> relayInfo.equals(entry));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -56,7 +56,9 @@ public class ArbitraryDataRenderManager extends Thread {
|
||||
return;
|
||||
}
|
||||
final long minimumTimestamp = now - AUTHORIZATION_TIMEOUT;
|
||||
this.authorizedResources.entrySet().removeIf(entry -> entry.getValue() == null || entry.getValue() < minimumTimestamp);
|
||||
synchronized (this.authorizedResources) {
|
||||
this.authorizedResources.entrySet().removeIf(entry -> entry.getValue() == null || entry.getValue() < minimumTimestamp);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isAuthorized(ArbitraryDataResource resource) {
|
||||
|
@ -73,7 +73,9 @@ public class ArbitraryMetadataManager {
|
||||
return;
|
||||
}
|
||||
final long requestMinimumTimestamp = now - ArbitraryDataManager.ARBITRARY_REQUEST_TIMEOUT;
|
||||
arbitraryMetadataRequests.entrySet().removeIf(entry -> entry.getValue().getC() == null || entry.getValue().getC() < requestMinimumTimestamp);
|
||||
synchronized (arbitraryMetadataRequests) {
|
||||
arbitraryMetadataRequests.entrySet().removeIf(entry -> entry.getValue().getC() == null || entry.getValue().getC() < requestMinimumTimestamp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user