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.h18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/net.h b/src/net.h
index 314c709..1c0c24e 100644
--- a/src/net.h
+++ b/src/net.h
@@ -638,10 +638,26 @@ public:
638 PushMessage("version", VERSION, nLocalServices, nTime, addr, nBestHeight); 638 PushMessage("version", VERSION, nLocalServices, nTime, addr, nBestHeight);
639 } 639 }
640 640
641 // Disconnect() closes the socket and sets this to INVALID_SOCKET, so by the
642 // time a node is deleted there is normally nothing left to do here. It used
643 // not to: Disconnect() closed the handle and left the number in place, and
644 // this destructor closed that same number a second time -- with a raw
645 // closesocket() that the socket accounting never saw, so neither the double
646 // close nor the stale claim showed up in any report.
647 //
648 // A double close is not a harmless no-op. Between the two, the operating
649 // system is free to hand that number to a new socket -- this node opens
650 // hundreds a minute -- and the second close then takes down a connection
651 // that belongs to somebody else, which the log can only report as a peer
652 // vanishing for no reason. `dropping node: its socket is no longer valid`
653 // is what that looks like from the outside.
641 ~CNode() 654 ~CNode()
642 { 655 {
643 if (hSocket != INVALID_SOCKET) 656 if (hSocket != INVALID_SOCKET)
644 closesocket(hSocket); 657 {
658 BtfCloseSocket(hSocket);
659 hSocket = INVALID_SOCKET;
660 }
645 } 661 }
646 662
647private: 663private: