Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

server mainloop: use LinkedBlockingQueue instead of ConcurrentLinkedQueue #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions instrumentor/src/main/java/edu/cmu/sv/kelinci/Kelinci.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
import java.net.Socket;
import java.net.SocketException;
import java.util.Arrays;
import java.util.Queue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

Expand All @@ -31,7 +31,7 @@
class Kelinci {

private static final int maxQueue = 10;
private static Queue<FuzzRequest> requestQueue = new ConcurrentLinkedQueue<>();
private static BlockingQueue<FuzzRequest> requestQueue = new LinkedBlockingQueue<>();

public static final byte STATUS_SUCCESS = 0;
public static final byte STATUS_TIMEOUT = 1;
Expand Down Expand Up @@ -184,7 +184,7 @@ private static void doFuzzerRuns() {

while (true) {
try {
FuzzRequest request = requestQueue.poll();
FuzzRequest request = requestQueue.poll(1000, TimeUnit.MILLISECONDS);
if (request != null) {
if (verbosity > 1)
System.out.println("Handling request 1 of " + (requestQueue.size()+1));
Expand Down Expand Up @@ -327,9 +327,6 @@ private static void doFuzzerRuns() {
if (verbosity > 1)
System.out.println("Connection closed.");

} else {
// if no request, close your eyes for a bit
Thread.sleep(100);
}
} catch (SocketException se) {
// Connection was reset, most probably means AFL process was killed.
Expand Down