From fdad9cfd00c31e1c50cb747fcef6fd54e9548384 Mon Sep 17 00:00:00 2001 From: Kim De Mey Date: Tue, 4 Apr 2023 17:36:57 +0200 Subject: [PATCH] Move content offered log after socket close wait (#1530) To be clear that the socket also got closed before this. Also explain that on socket close, the actual socket still waits for an ACK. --- fluffy/network/wire/portal_protocol.nim | 2 +- fluffy/network/wire/portal_stream.nim | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/fluffy/network/wire/portal_protocol.nim b/fluffy/network/wire/portal_protocol.nim index 8a206acac..27c34ef81 100644 --- a/fluffy/network/wire/portal_protocol.nim +++ b/fluffy/network/wire/portal_protocol.nim @@ -834,9 +834,9 @@ proc offer(p: PortalProtocol, o: OfferRequest): socket.close() return err("Error writing requested data") + await socket.closeWait() debug "Content successfully offered" - await socket.closeWait() return ok(m.contentKeys) else: warn "Offer failed due to accept request failure ", diff --git a/fluffy/network/wire/portal_stream.nim b/fluffy/network/wire/portal_stream.nim index 3795f8957..fdabf6584 100644 --- a/fluffy/network/wire/portal_stream.nim +++ b/fluffy/network/wire/portal_stream.nim @@ -257,7 +257,9 @@ proc readContentOffer( else: # This means FIN didn't arrive yet, perhaps it got dropped but it might also # be still in flight. Closing the socket (= sending FIN) ourselves. - # Not waiting here for its ACK however, so no `closeWait` + # Not waiting here for its ACK however, so no `closeWait`. Underneath the + # socket will still wait for the FIN-ACK (or timeout) before it destroys the + # socket. socket.close() # TODO: This could currently create a backlog of content items to be validated