Fix possible deadlock in async packet processing (#2545)

fix: start processing further packets if a packet is done
This commit is contained in:
Maurice Eisenblätter 2024-05-06 11:27:16 +02:00 committed by GitHub
parent f9d3266777
commit a2f02652e9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -428,7 +428,7 @@ public class AsyncFilterManager implements AsynchronousManager {
}
// There are no more listeners - queue the packet for transmission
signalFreeProcessingSlot(packet);
signalFreeProcessingSlot(packet, onMainThread);
PacketSendingQueue queue = getSendingQueue(packet, false);
@ -467,11 +467,18 @@ public class AsyncFilterManager implements AsynchronousManager {
}
/**
* Signal that a packet has finished processing.
* Signal that a packet has finished processing. Tries to process further packets
* if a processing slot is still free.
* @param packet - packet to signal.
* @param onMainThread whether or not this method was run by the main thread.
*/
public void signalFreeProcessingSlot(PacketEvent packet) {
getProcessingQueue(packet).signalProcessingDone();
public void signalFreeProcessingSlot(PacketEvent packet, boolean onMainThread) {
PacketProcessingQueue queue = getProcessingQueue(packet);
// mark slot as done
queue.signalProcessingDone();
// start processing next slot if possible
queue.signalBeginProcessing(onMainThread);
}
/**