upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/net.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/net.h')
-rw-r--r--src/net.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/net.h b/src/net.h
index 440550c..0317676 100644
--- a/src/net.h
+++ b/src/net.h
@@ -146,6 +146,16 @@ static const int64 BTF_NO_PEER_HEIGHT_MAX_SECS = 20 * 60;
146// minutes is far beyond that, and well inside BTF_RECV_TIMEOUT_SECS. 146// minutes is far beyond that, and well inside BTF_RECV_TIMEOUT_SECS.
147static const int64 BTF_MSG_WAIT_MAX_SECS = 2 * 60; 147static const int64 BTF_MSG_WAIT_MAX_SECS = 2 * 60;
148 148
149// Largest payload a peer may announce in a message header: MAX_PROTOCOL_MESSAGE_SIZE
150// is defined further up this file. This tree reached the same cap by the same
151// reasoning as upstream #109 -- a 256 MB allowance is eight times what the
152// deserializer will accept (serialize.h throws above MAX_SIZE), so the header
153// check admitted an allocation the parser would only reject later, after
154// BTF_MSG_WAIT_MAX_SECS of a stalled peer slot -- so only the note survives.
155//
156// Both definitions were textually clean and 59 lines apart, so the replay onto
157// upstream merged them without a conflict and only the compiler objected.
158
149// Send a ping after this long with nothing to say, so a peer running the 159// Send a ping after this long with nothing to say, so a peer running the
150// inactivity check above does not mistake a quiet node for a dead one. Must 160// inactivity check above does not mistake a quiet node for a dead one. Must
151// stay well under BTF_RECV_TIMEOUT_SECS. 161// stay well under BTF_RECV_TIMEOUT_SECS.
@@ -741,6 +751,11 @@ public:
741 { 751 {
742 if (hSocket != INVALID_SOCKET) 752 if (hSocket != INVALID_SOCKET)
743 { 753 {
754 // Route through BtfCloseSocket so the accounting sees this close.
755 // A raw closesocket() here was invisible to sockcount, which is
756 // why the leak numbers never added up, and leaving the descriptor
757 // set afterwards is how a number that now belongs to somebody else
758 // gets closed a second time. (#103)
744 BtfCloseSocket(hSocket); 759 BtfCloseSocket(hSocket);
745 hSocket = INVALID_SOCKET; 760 hSocket = INVALID_SOCKET;
746 } 761 }