Fix chunk sending when the computed time overflows (#8833)

This commit is contained in:
Martijn 2023-02-09 18:27:24 +01:00
parent 62048076ef
commit 90cdec2283

View file

@ -1404,7 +1404,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+
+ final int priorityCompare = Double.compare(holder1 == null ? Double.MAX_VALUE : holder1.priority, holder2 == null ? Double.MAX_VALUE : holder2.priority);
+
+ final int lastLoadTimeCompare = Long.compare(p1.lastChunkLoad, p2.lastChunkLoad);
+ final int lastLoadTimeCompare = Long.compare(p1.lastChunkLoad - p2.lastChunkLoad, 0);
+
+ if ((holder1 == null || holder2 == null || lastLoadTimeCompare == 0 || holder1.priority < 0.0 || holder2.priority < 0.0) && priorityCompare != 0) {
+ return priorityCompare;
@ -1429,7 +1429,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return 0;
+ }
+
+ final int timeCompare = Long.compare(p1.nextChunkSendTarget, p2.nextChunkSendTarget);
+ final int timeCompare = Long.compare(p1.nextChunkSendTarget - p2.nextChunkSendTarget, 0);
+ if (timeCompare != 0) {
+ return timeCompare;
+ }
@ -1835,14 +1835,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ private static long nextChunkSend;
+ private void trySendChunks() {
+ final long time = System.nanoTime();
+ if (time < nextChunkSend) {
+ if (nextChunkSend - time > 0) {
+ return;
+ }
+ // drain entries from wait queue
+ while (!this.chunkSendWaitQueue.isEmpty()) {
+ final PlayerLoaderData data = this.chunkSendWaitQueue.first();
+
+ if (data.nextChunkSendTarget > time) {
+ if (data.nextChunkSendTarget - time > 0) {
+ break;
+ }
+
@ -1914,7 +1914,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ });
+
+ nextChunkSend = this.getMaxSendAddend() + time;
+ if (time < nextChunkSend) {
+ if (nextChunkSend - time > 0) {
+ break;
+ }
+ }