Skip to content

Commit 88ac104

Browse files
committed
Issue #6254 - Total timeout not enforced for queued requests.
Updates after review. Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
1 parent da50e06 commit 88ac104

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

jetty-client/src/main/java/org/eclipse/jetty/client/HttpDestination.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -567,14 +567,15 @@ public void onTimeoutExpired()
567567
LOG.debug("{} timeouts check", this);
568568

569569
long now = System.nanoTime();
570-
570+
long earliest = Long.MAX_VALUE;
571571
// Reset the earliest timeout so we can expire again.
572572
// A concurrent call to schedule(long) may lose an earliest
573573
// value, but the corresponding exchange is already enqueued
574574
// and will be seen by scanning the exchange queue below.
575-
earliestTimeout.set(Long.MAX_VALUE);
575+
earliestTimeout.set(earliest);
576576

577-
long earliest = Long.MAX_VALUE;
577+
// Scan the message queue to abort expired exchanges
578+
// and to find the exchange that expire the earliest.
578579
for (HttpExchange exchange : exchanges)
579580
{
580581
HttpRequest request = exchange.getRequest();
@@ -596,8 +597,8 @@ private void schedule(long expiresAt)
596597
// Schedule a timeout for the earliest exchange that may expire.
597598
// When the timeout expires, scan the exchange queue for the next
598599
// earliest exchange that may expire, and reschedule a new timeout.
599-
long earliest = earliestTimeout.getAndUpdate(t -> Math.min(t, expiresAt));
600-
if (expiresAt < earliest)
600+
long prevEarliest = earliestTimeout.getAndUpdate(t -> Math.min(t, expiresAt));
601+
if (expiresAt < prevEarliest)
601602
{
602603
// A new request expires earlier than previous requests, schedule it.
603604
long delay = Math.max(0, expiresAt - System.nanoTime());

jetty-io/src/main/java/org/eclipse/jetty/io/CyclicTimeout.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,12 @@ public boolean schedule(long delay, TimeUnit units)
119119
if (_timeout.compareAndSet(timeout, new Timeout(newTimeoutAt, wakeup)))
120120
{
121121
if (LOG.isDebugEnabled())
122+
{
122123
LOG.debug("Installed timeout in {} ms, {} wake up in {} ms",
123124
units.toMillis(delay),
124125
newWakeup != null ? "new" : "existing",
125126
TimeUnit.NANOSECONDS.toMillis(wakeup._at - now));
127+
}
126128
break;
127129
}
128130
}

0 commit comments

Comments
 (0)