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.net.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
@ -167,10 +166,11 @@ public class BlockStreamServer extends Thread {
|
|||
*/
|
||||
private void cleanupStaleRequests(boolean cleanupAll) {
|
||||
synchronized (blockStreamMap) {
|
||||
List<Long> staleStreamIds = new ArrayList<>();
|
||||
for (BlockStreamRegistration registration : blockStreamMap.values()) {
|
||||
long age = System.currentTimeMillis() - registration.timestamp;
|
||||
if (age > MAX_AGE_MS) {
|
||||
blockStreamMap.remove(registration.streamHandle.getStreamID());
|
||||
staleStreamIds.add(registration.streamHandle.getStreamID());
|
||||
try {
|
||||
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.
|
||||
* @param s server socket to be used for accepting connections
|
||||
* @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 {
|
||||
|
||||
|
@ -348,7 +351,7 @@ public class BlockStreamServer extends Thread {
|
|||
* Read the stream request header which must be the first input
|
||||
* received from the client.
|
||||
* @return StreamRequest data presented by client
|
||||
* @throws IOException
|
||||
* @throws IOException if an IO error occurs
|
||||
*/
|
||||
private StreamRequest readStreamRequest() throws IOException {
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue