mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 10:19:23 +02:00
GP-2441 corrected concurrent modification error when cleaning-up stale
block stream registrations on Ghidra Server
This commit is contained in:
parent
6198c350af
commit
3a3dcacefc
1 changed files with 8 additions and 5 deletions
|
@ -17,8 +17,7 @@ package ghidra.server.stream;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.*;
|
import java.net.*;
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
@ -167,10 +166,11 @@ public class BlockStreamServer extends Thread {
|
||||||
*/
|
*/
|
||||||
private void cleanupStaleRequests(boolean cleanupAll) {
|
private void cleanupStaleRequests(boolean cleanupAll) {
|
||||||
synchronized (blockStreamMap) {
|
synchronized (blockStreamMap) {
|
||||||
|
List<Long> staleStreamIds = new ArrayList<>();
|
||||||
for (BlockStreamRegistration registration : blockStreamMap.values()) {
|
for (BlockStreamRegistration registration : blockStreamMap.values()) {
|
||||||
long age = System.currentTimeMillis() - registration.timestamp;
|
long age = System.currentTimeMillis() - registration.timestamp;
|
||||||
if (age > MAX_AGE_MS) {
|
if (age > MAX_AGE_MS) {
|
||||||
blockStreamMap.remove(registration.streamHandle.getStreamID());
|
staleStreamIds.add(registration.streamHandle.getStreamID());
|
||||||
try {
|
try {
|
||||||
registration.blockStream.close();
|
registration.blockStream.close();
|
||||||
}
|
}
|
||||||
|
@ -179,6 +179,9 @@ public class BlockStreamServer extends Thread {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (long id : staleStreamIds) {
|
||||||
|
blockStreamMap.remove(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,7 +190,7 @@ public class BlockStreamServer extends Thread {
|
||||||
* this method will return immediately.
|
* this method will return immediately.
|
||||||
* @param s server socket to be used for accepting connections
|
* @param s server socket to be used for accepting connections
|
||||||
* @param host remote access hostname to be used by clients
|
* @param host remote access hostname to be used by clients
|
||||||
* @throws IOException
|
* @throws IOException if an IO error occurs
|
||||||
*/
|
*/
|
||||||
public synchronized void startServer(ServerSocket s, String host) throws IOException {
|
public synchronized void startServer(ServerSocket s, String host) throws IOException {
|
||||||
|
|
||||||
|
@ -348,7 +351,7 @@ public class BlockStreamServer extends Thread {
|
||||||
* Read the stream request header which must be the first input
|
* Read the stream request header which must be the first input
|
||||||
* received from the client.
|
* received from the client.
|
||||||
* @return StreamRequest data presented by client
|
* @return StreamRequest data presented by client
|
||||||
* @throws IOException
|
* @throws IOException if an IO error occurs
|
||||||
*/
|
*/
|
||||||
private StreamRequest readStreamRequest() throws IOException {
|
private StreamRequest readStreamRequest() throws IOException {
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue