Skip to content

Commit 63d74d0

Browse files
authored
Apply TotalTimeoutHandler only if duration seconds > 0 (#415)
1 parent 25dd797 commit 63d74d0

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -318,15 +318,19 @@ public void onMessage(@NotNull Stream stream, Circuit.HopMessage msg) {
318318
if (resv.maxBytes > 0) {
319319
fromRequestor.pushHandler(new InboundTrafficLimitHandler(resv.maxBytes));
320320
}
321-
fromRequestor.pushHandler(
322-
new TotalTimeoutHandler(
323-
Duration.of(resv.durationSeconds, ChronoUnit.SECONDS)));
321+
if (resv.durationSeconds > 0) {
322+
fromRequestor.pushHandler(
323+
new TotalTimeoutHandler(
324+
Duration.of(resv.durationSeconds, ChronoUnit.SECONDS)));
325+
}
324326
if (resv.maxBytes > 0) {
325327
toTarget.pushHandler(new InboundTrafficLimitHandler(resv.maxBytes));
326328
}
327-
toTarget.pushHandler(
328-
new TotalTimeoutHandler(
329-
Duration.of(resv.durationSeconds, ChronoUnit.SECONDS)));
329+
if (resv.durationSeconds > 0) {
330+
toTarget.pushHandler(
331+
new TotalTimeoutHandler(
332+
Duration.of(resv.durationSeconds, ChronoUnit.SECONDS)));
333+
}
330334
fromRequestor.pushHandler(new ProxyHandler(toTarget));
331335
toTarget.pushHandler(new ProxyHandler(fromRequestor));
332336
} else {

0 commit comments

Comments
 (0)