java.lang.Object
net.i2p.util.SimpleTimer2.TimedEvent
net.i2p.client.streaming.impl.Connection.ResendPacketEvent
All Implemented Interfaces:
Runnable
Enclosing class:
Connection

class Connection.ResendPacketEventextends SimpleTimer2.TimedEvent
Timer event that resends a single outbound packet when it fires and then offers itself back to _resendEventPool for reuse.
  • Field Details

    • _packet

      private PacketLocal _packet
      The packet to retransmit.
  • Constructor Details

    • ResendPacketEvent

      public ResendPacketEvent(PacketLocal packet)
      Bind the event to a packet and the router's shared timer.
      Parameters:
      packet - the packet to retransmit when the event fires
  • Method Details

    • timeReached

      public void timeReached()
      Retransmit the packet when the timer fires, then return this event to the pool for reuse.
      Specified by:
      timeReached in class SimpleTimer2.TimedEvent
    • fastRetransmit

      void fastRetransmit()
      Fire an immediate retransmit instead of waiting out the current RTO.
    • retransmit

      private boolean retransmit()
      Retransmit the packet if we need to.

      ackImmediately() above calls directly in here, so we have to use forceReschedule() instead of schedule() below, to prevent duplicates in the timer queue.

      Don't synchronize this, deadlock with ackPackets->ackReceived->SimpleTimer2.cancel

      Historical note on the lock warning: SimpleTimer2 now invokes TimedEvent.timeReached()/run() outside any SimpleTimer2 monitor (only checkAndPrepareRun/updateStateAfterRun are brief synchronized scopes), so the called-from-across-the-wire locks taken in ackPackets() and here cannot form a monitor cycle with this thread. A short synchronized (_outboundPacketsLock) in the reset path below is therefore deadlock-safe; ackPackets() holds the same lock only for mapping + ack bookkeeping, never while calling SimpleTimer2.

      Returns:
      true if the packet was sent, false if it was not