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,53 +174,60 @@ abstract class PacketSendingQueue {
// Recompute // Recompute
marker = current.getAsyncMarker(); marker = current.getAsyncMarker();
hasExpired = marker.hasExpired(); hasExpired = marker.hasExpired();
}
// Abort if we're not on the main thread // Could happen due to the timeout listeners
if (notThreadSafe && !hasExpired) { if (!marker.isProcessed()) {
try { return false;
boolean wantAsync = marker.isMinecraftAsync(current);
boolean wantSync = !wantAsync;
// Wait for the next main thread heartbeat if we haven't fulfilled our promise
if (!onMainThread && wantSync) {
return false;
}
// Let's give it what it wants, then
if (onMainThread && wantAsync) {
asynchronousSender.execute(new Runnable() {
@Override
public void run() {
// We know this isn't on the main thread
processPacketHolder(false, holder);
}
});
// The executor will take it from here
return true;
}
} catch (FieldAccessException e) {
e.printStackTrace();
// Skip this packet
return true;
} }
} }
if (marker.isProcessed() && !current.isCancelled() && !hasExpired) { // Is it okay to send the packet?
if (!current.isCancelled() && !hasExpired) {
// Make sure we're on the main thread
if (notThreadSafe) {
try {
boolean wantAsync = marker.isMinecraftAsync(current);
boolean wantSync = !wantAsync;
// Wait for the next main thread heartbeat if we haven't fulfilled our promise
if (!onMainThread && wantSync) {
return false;
}
// Let's give it what it wants
if (onMainThread && wantAsync) {
asynchronousSender.execute(new Runnable() {
@Override
public void run() {
// We know this isn't on the main thread
processPacketHolder(false, holder);
}
});
// Scheduler will do the rest
return true;
}
} catch (FieldAccessException e) {
e.printStackTrace();
// Just drop the packet
return true;
}
}
// 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
return false;
} }
// Add it back and stop sending
return false;
} }
/** /**