Skip to content

Commit d20c7d4

Browse files
committed
Apply TotalTimeoutHandler only if duration seconds > 0
1 parent 8b62e1f commit d20c7d4

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

libp2p/src/main/java/io/libp2p/protocol/circuit/CircuitHopProtocol.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -316,13 +316,18 @@ public void onMessage(@NotNull Stream stream, Circuit.HopMessage msg) {
316316

317317
// connect these streams with time + bytes enforcement
318318
fromRequestor.pushHandler(new InboundTrafficLimitHandler(resv.maxBytes));
319-
fromRequestor.pushHandler(
320-
new TotalTimeoutHandler(
321-
Duration.of(resv.durationSeconds, ChronoUnit.SECONDS)));
319+
if(resv.durationSeconds > 0){
320+
fromRequestor.pushHandler(
321+
new TotalTimeoutHandler(
322+
Duration.of(resv.durationSeconds, ChronoUnit.SECONDS)));
323+
}
324+
322325
toTarget.pushHandler(new InboundTrafficLimitHandler(resv.maxBytes));
323-
toTarget.pushHandler(
324-
new TotalTimeoutHandler(
325-
Duration.of(resv.durationSeconds, ChronoUnit.SECONDS)));
326+
if(resv.durationSeconds > 0){
327+
toTarget.pushHandler(
328+
new TotalTimeoutHandler(
329+
Duration.of(resv.durationSeconds, ChronoUnit.SECONDS)));
330+
}
326331
fromRequestor.pushHandler(new ProxyHandler(toTarget));
327332
toTarget.pushHandler(new ProxyHandler(fromRequestor));
328333
} else {

0 commit comments

Comments
 (0)