java.lang.Object
net.i2p.util.SimpleTimer2.TimedEvent
net.i2p.client.streaming.impl.ConnectionHandler.SynReaper
- All Implemented Interfaces:
Runnable
- Enclosing class:
ConnectionHandler
Periodic reaper that removes SYN packets from the accept queue after their accept timeout has elapsed, sending a reset if it was a SYN.
Replaces two per-SYN TimedEvents (one at enqueue in ConnectionHandler.receiveNewSyn(Packet), one at dequeue in the accept worker) with a single self-rescheduling event that scans the enqueue table every ConnectionHandler.SYN_SWEEP_INTERVAL. Under a SYN flood the old model posted O(n) timer events per second. This is O(1) posts per second regardless of load. The time-between-sweeps bound means a SYN may persist at most one interval past its timeout — negligible against 10s+ accept timeouts.
The two-argument removal on the concurrent map is atomic against the worker's refresh, so a packet that was re-quoted after this sweep read its entry is left alone for the next sweep.
Field Summary
Fields inherited from class SimpleTimer2.TimedEvent
_state, DEFAULT_FUZZModifier and TypeFieldDescriptionprotected SimpleTimer2.TimedEventStateState of the current event.protected static final intDefault fuzz threshold in milliseconds.Constructor Summary
ConstructorsMethod Summary
All MethodsMethods inherited from class SimpleTimer2.TimedEvent
cancel, forceReschedule, reschedule, reschedule, run, schedule, setFuzz, setPool, toStringModifier and TypeMethodDescriptionbooleancancel()Cancel the timed event.voidforceReschedule(long timeoutMs) Always use the new time - ignores fuzz.voidreschedule(long timeoutMs) Use the earliest of the new time and the old time May be called from within timeReached(), but schedule() is better there.voidreschedule(long timeoutMs, boolean useEarliestTime) May be called from within timeReached(), but schedule() is better there.voidrun()voidschedule(long timeoutMs) Schedule this event.voidsetFuzz(int fuzz) Reschedule threshold in ms.voidsetPool(SimpleTimer2 pool) Timer pool for this event.toString()Timer summary for log messages.
Constructor Details
SynReaper
SynReaper()Builds the half open connection reaper.
Method Details
timeReached
public void timeReached()Description copied from class:SimpleTimer2.TimedEventCalled when this event's scheduled time arrives. Must NOT block. For periodic events, call schedule(period) at the end to self-reschedule.- Specified by:
timeReachedin classSimpleTimer2.TimedEvent