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

Skip to content
Snippets Groups Projects
Commit 32dddac7 authored by zzz's avatar zzz
Browse files

* Streaming:

      - Fix infinite loop through the SYN queue caused by race,
        resulting in high CPU, OOMs, etc.
parent 90648282
No related branches found
No related tags found
No related merge requests found
......@@ -171,7 +171,9 @@ class ConnectionHandler {
// Send it through the packet handler again
if (_log.shouldLog(Log.WARN))
_log.warn("Found con for queued non-syn packet: " + packet);
_manager.getPacketHandler().receivePacket(packet);
// false -> don't requeue, fixes a race where a SYN gets dropped
// between here and PacketHandler, causing the packet to loop forever....
_manager.getPacketHandler().receivePacketDirect(packet, false);
} else {
// goodbye
if (_log.shouldLog(Log.WARN))
......
......@@ -90,10 +90,10 @@ public class PacketHandler {
void receivePacket(Packet packet) {
//boolean ok = choke(packet);
//if (ok)
receivePacketDirect(packet);
receivePacketDirect(packet, true);
}
private void receivePacketDirect(Packet packet) {
void receivePacketDirect(Packet packet, boolean queueIfNoConn) {
//if (_log.shouldLog(Log.DEBUG))
// _log.debug("packet received: " + packet);
......@@ -105,7 +105,7 @@ public class PacketHandler {
if (_log.shouldLog(Log.INFO))
displayPacket(packet, "RECV", "wsize " + con.getOptions().getWindowSize() + " rto " + con.getOptions().getRTO());
} else {
receiveUnknownCon(packet, sendId);
receiveUnknownCon(packet, sendId, queueIfNoConn);
displayPacket(packet, "UNKN", null);
}
}
......@@ -228,7 +228,7 @@ public class PacketHandler {
_manager.getPacketQueue().enqueue(reply);
}
private void receiveUnknownCon(Packet packet, long sendId) {
private void receiveUnknownCon(Packet packet, long sendId, boolean queueIfNoConn) {
if (packet.isFlagSet(Packet.FLAG_ECHO)) {
if (packet.getSendStreamId() > 0) {
receivePing(packet);
......@@ -262,7 +262,7 @@ public class PacketHandler {
if (packet.isFlagSet(Packet.FLAG_SYNCHRONIZE)) {
_manager.getConnectionHandler().receiveNewSyn(packet);
} else {
} else if (queueIfNoConn) {
// We can get here on the 2nd+ packet if the 1st (SYN) packet
// is still on the _synQueue in the ConnectionHandler, and
// ConnectionManager.receiveConnection() hasn't run yet to put
......@@ -287,6 +287,10 @@ public class PacketHandler {
}
//packet.releasePayload();
_manager.getConnectionHandler().receiveNewSyn(packet);
} else {
// don't queue again (infinite loop!)
sendReset(packet);
packet.releasePayload();
}
}
}
......
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