ultralight icon indicating copy to clipboard operation
ultralight copied to clipboard

uTP calls `returnContent` twice

Open acolytec3 opened this issue 2 years ago • 1 comments

When a uTP content stream wraps up, it appears that we call returnContent twice, either because the sending node is sending 2 FIN packets or the FIN packet handler is being called more than once.

7c20:Portal:uTP:RECEIVED:ST_STATE || seqNr: 2164     || +0ms
  f7c20:Portal:uTP:RECEIVED:ST_STATE || ackNr: 2162     || +0ms
  f7c20:Portal:uTP:writeSocket:17440 AckNr's received (50/51): 2113...2160,2161,2162 +2ms
  f7c20:Portal:uTP:writeSocket:17440 AckNr's needed (1/51): 2163
  f7c20:Portal:uTP:writeSocket:17440          +0ms
  f7c20:Portal:uTP:writeSocket:17440:WRITING Sending ST_FIN packet. +2ms
  f7c20:Portal:uTP:writeSocket:17440:SEND:ST_FIN || pktId: 17440 +0ms
  f7c20:Portal:uTP:writeSocket:17440:SEND:ST_FIN || seqNr: 2163 +0ms
  f7c20:Portal:uTP:writeSocket:17440:SEND:ST_FIN || ackNr: 2113 +0ms
  8a470:Portal:uTP:RECEIVED:ST_FIN || pktId: 17440     || +0ms
  8a470:Portal:uTP:RECEIVED:ST_FIN || seqNr: 2163     || +0ms
  8a470:Portal:uTP:RECEIVED:ST_FIN || ackNr: 2113     || +0ms
  8a470:Portal:uTP:readSocket:17441 Connection State: GotFin: 2163 +1ms
  8a470:Portal:uTP:readSocket:17441 all data packets received. +0ms
  8a470:Portal:uTP:readSocket:17441 Packet payloads compiled into 25619 bytes.  Sending FIN-ACK +1ms
  8a470:Portal:uTP:readSocket:17441:SEND:ST_STATE || pktId: 17441 +0ms
  8a470:Portal:uTP:readSocket:17441:SEND:ST_STATE || seqNr: 2165 +0ms
  8a470:Portal:uTP:readSocket:17441:SEND:ST_STATE || ackNr: 2163 +0ms
  8a470:Portal:uTP Decompressing stream into 1 pieces of content +76ms
  8a470:Portal:uTP:FINISHED 1/1 -- (25619 bytes) sending BlockHeader to database +0ms
  8a470:Portal:uTP:RECEIVED:ST_FIN || pktId: 17440     || +0ms
  8a470:Portal:uTP:RECEIVED:ST_FIN || seqNr: 2163     || +0ms
  8a470:Portal:uTP:RECEIVED:ST_FIN || ackNr: 2113     || +0ms
  8a470:Portal:uTP:readSocket:17441 Connection State: GotFin: 2163 +5ms
  8a470:Portal:uTP Decompressing stream into 1 pieces of content +5s
  8a470:Portal:uTP:FINISHED 1/1 -- (0 bytes) sending BlockHeader to database +0ms
  8a470:Portal:uTP:FINISHED Missing content... +0ms

We should investigate and ensure this duplicate action doesn't occur.

acolytec3 avatar Aug 15 '23 01:08 acolytec3

This is still happening and the logging is weird.

We need something in the handleFinPacket method that closes the socket so if we get a dup FIN packet we don't call returnContent a second time. Seems like both Trin and Fluffy do funny things with sending FIN packets and it clutters up the logs with nonsensical stuff like above.

acolytec3 avatar Oct 26 '23 02:10 acolytec3

I dunno if this is still an issue or not. @ScottyPoi has made plenty of progress on uTP improvements so I'm guessing this is no longer an issue.

acolytec3 avatar Jul 05 '24 20:07 acolytec3