diff options
Diffstat (limited to 'src/net.h')
| -rw-r--r-- | src/net.h | 18 |
1 files changed, 17 insertions, 1 deletions
| @@ -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 | ||
| 647 | private: | 663 | private: |