I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit dd181a90 authored by zab2's avatar zab2
Browse files

Fix NPE when cancelling PacketLocal's

parent a02cc258
No related branches found
No related tags found
No related merge requests found
......@@ -32,7 +32,7 @@ class PacketLocal extends Packet implements MessageOutputStream.WriteStatus {
private long _cancelledOn;
private final AtomicInteger _nackCount = new AtomicInteger(0);
private volatile boolean _retransmitted;
private SimpleTimer2.TimedEvent _resendEvent;
private volatile SimpleTimer2.TimedEvent _resendEvent;
/** not bound to a connection */
public PacketLocal(I2PAppContext ctx, Destination to) {
......@@ -112,6 +112,13 @@ class PacketLocal extends Packet implements MessageOutputStream.WriteStatus {
_numSends++;
_lastSend = _context.clock().now();
}
private void cancelResend() {
SimpleTimer2.TimedEvent ev = _resendEvent;
if (ev != null)
ev.cancel();
}
public void ackReceived() {
final long now = _context.clock().now();
synchronized (this) {
......@@ -120,15 +127,16 @@ class PacketLocal extends Packet implements MessageOutputStream.WriteStatus {
releasePayload();
notifyAll();
}
_resendEvent.cancel();
cancelResend();
}
public void cancelled() {
synchronized (this) {
_cancelledOn = _context.clock().now();
releasePayload();
notifyAll();
}
_resendEvent.cancel();
cancelResend();
if (_log.shouldLog(Log.DEBUG))
_log.debug("Cancelled! " + toString(), new Exception("cancelled"));
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment