Improve async packet processing logic (#2503)

* fix: enqueue async packet event after processing delay is zero
* fix: async packet processing
This commit is contained in:
Maurice Eisenblätter 2023-08-27 17:11:37 +02:00 committed by GitHub
parent 2686c9fec0
commit f0401acd2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 15 deletions

View File

@ -413,6 +413,23 @@ public class AsyncFilterManager implements AsynchronousManager {
// Only send if the packet is ready
if (marker.decrementProcessingDelay() == 0) {
// Now, get the next non-cancelled listener
if (!marker.hasExpired()) {
for (; marker.getListenerTraversal().hasNext(); ) {
AsyncListenerHandler handler = marker.getListenerTraversal().next().getListener();
if (!handler.isCancelled()) {
marker.incrementProcessingDelay();
handler.enqueuePacket(packet);
return;
}
}
}
// There are no more listeners - queue the packet for transmission
signalFreeProcessingSlot(packet);
PacketSendingQueue queue = getSendingQueue(packet, false);
// No need to create a new queue if the player has logged out

View File

@ -632,21 +632,6 @@ public class AsyncListenerHandler {
filterManager.getErrorReporter().reportMinimal(listener.getPlugin(), methodName, e);
}
// Now, get the next non-cancelled listener
if (!marker.hasExpired()) {
for (; marker.getListenerTraversal().hasNext(); ) {
AsyncListenerHandler handler = marker.getListenerTraversal().next().getListener();
if (!handler.isCancelled()) {
handler.enqueuePacket(packet);
return;
}
}
}
// There are no more listeners - queue the packet for transmission
filterManager.signalFreeProcessingSlot(packet);
// Note that listeners can opt to delay the packet transmission
filterManager.signalPacketTransmission(packet);
}