Archiviert
13
0

Fix the packet sending procedure.

Dieser Commit ist enthalten in:
Kristian S. Stangeland 2012-11-21 02:18:56 +01:00
Ursprung 858f9ee02d
Commit 524ef2e6c9

Datei anzeigen

@ -174,10 +174,17 @@ abstract class PacketSendingQueue {
// Recompute // Recompute
marker = current.getAsyncMarker(); marker = current.getAsyncMarker();
hasExpired = marker.hasExpired(); hasExpired = marker.hasExpired();
// Could happen due to the timeout listeners
if (!marker.isProcessed()) {
return false;
}
} }
// Abort if we're not on the main thread // Is it okay to send the packet?
if (notThreadSafe && !hasExpired) { if (!current.isCancelled() && !hasExpired) {
// Make sure we're on the main thread
if (notThreadSafe) {
try { try {
boolean wantAsync = marker.isMinecraftAsync(current); boolean wantAsync = marker.isMinecraftAsync(current);
boolean wantSync = !wantAsync; boolean wantSync = !wantAsync;
@ -187,7 +194,7 @@ abstract class PacketSendingQueue {
return false; return false;
} }
// Let's give it what it wants, then // Let's give it what it wants
if (onMainThread && wantAsync) { if (onMainThread && wantAsync) {
asynchronousSender.execute(new Runnable() { asynchronousSender.execute(new Runnable() {
@Override @Override
@ -197,31 +204,31 @@ abstract class PacketSendingQueue {
} }
}); });
// The executor will take it from here // Scheduler will do the rest
return true; return true;
} }
} catch (FieldAccessException e) { } catch (FieldAccessException e) {
e.printStackTrace(); e.printStackTrace();
// Skip this packet
// Just drop the packet
return true; return true;
} }
} }
if (marker.isProcessed() && !current.isCancelled() && !hasExpired) {
// Silently skip players that have logged out // Silently skip players that have logged out
if (isOnline(current.getPlayer())) { if (isOnline(current.getPlayer())) {
sendPacket(current); sendPacket(current);
} }
} }
// Drop the packet
return true; return true;
}
} else {
// Add it back and stop sending // Add it back and stop sending
return false; return false;
} }
}
/** /**
* Invoked when a packet has timed out. * Invoked when a packet has timed out.