From 82d187438f8342ed08653f95db60d2a130752a84 Mon Sep 17 00:00:00 2001 From: zzz Date: Fri, 1 Mar 2019 18:00:54 +0000 Subject: [PATCH] Streaming: Fix sending messages with expired times (ticket #2451) --- .../src/net/i2p/client/streaming/impl/PacketQueue.java | 10 ++++++++-- history.txt | 8 ++++++++ router/java/src/net/i2p/router/RouterVersion.java | 2 +- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/apps/streaming/java/src/net/i2p/client/streaming/impl/PacketQueue.java b/apps/streaming/java/src/net/i2p/client/streaming/impl/PacketQueue.java index 99cdedb267..fb0e46395d 100644 --- a/apps/streaming/java/src/net/i2p/client/streaming/impl/PacketQueue.java +++ b/apps/streaming/java/src/net/i2p/client/streaming/impl/PacketQueue.java @@ -44,6 +44,7 @@ class PacketQueue implements SendMessageStatusListener, Closeable { private static final int FINAL_TAG_THRESHOLD = 2; private static final long REMOVE_EXPIRED_TIME = 67*1000; private static final boolean ENABLE_STATUS_LISTEN = true; + private static final long I2CP_EXPIRATION_ADJUST = Math.min(25, Connection.MIN_RESEND_DELAY / 4); public PacketQueue(I2PAppContext context, SimpleTimer2 timer) { _context = context; @@ -117,10 +118,15 @@ class PacketQueue implements SendMessageStatusListener, Closeable { begin = _context.clock().now(); long expires = 0; Connection.ResendPacketEvent rpe = (Connection.ResendPacketEvent) packet.getResendEvent(); - if (rpe != null) + if (rpe != null) { // we want the router to expire it a little before we do, // so if we retransmit it will use a new tunnel/lease combo - expires = rpe.getNextSendTime() - 500; + // If we are really close to the timeout already, + // give this packet a chance to be sent, + // but it's likely to be dropped on the router side if we're + // running this far behind. + expires = Math.max(rpe.getNextSendTime() - I2CP_EXPIRATION_ADJUST, begin + 25); + } SendMessageOptions options = new SendMessageOptions(); if (expires > 0) options.setDate(expires); diff --git a/history.txt b/history.txt index 95285592e5..3163990373 100644 --- a/history.txt +++ b/history.txt @@ -1,3 +1,11 @@ +2019-03-01 zzz + * Streaming: Fix sending messages with expired times (ticket #2451) + +2019-02-28 zzz + * Console: + - Fix router logs not shown if first msg is a dup + - Change fallback client names to use b32 + 2019-02-26 zzz * SSU: - Fix scheduling of peer test at startup (ticket #2441) diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index 5a58b19bc2..e36cd3b143 100644 --- a/router/java/src/net/i2p/router/RouterVersion.java +++ b/router/java/src/net/i2p/router/RouterVersion.java @@ -18,7 +18,7 @@ public class RouterVersion { /** deprecated */ public final static String ID = "Monotone"; public final static String VERSION = CoreVersion.VERSION; - public final static long BUILD = 11; + public final static long BUILD = 12; /** for example "-test" */ public final static String EXTRA = "";