diff options
| author | Bitflash <btf01@proton.me> | 2026-08-01 13:10:23 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-08-01 13:10:23 -0300 |
| commit | 21c8bb63cb85f3001ddee9237b1d7e689675d293 (patch) | |
| tree | 9668f6bf39635424a6180c7a7edb6c7931ea7545 /src/nostr.cpp | |
| parent | 7131c30c33c980f0ba1d37dfc6a3fbe8c319813e (diff) | |
diag: count sockets by where they were created, and whether the close took (#86)
A node was found holding 1502 sockets in Windows bound state, one ephemeral port
each, 9% of the machine range in nineteen hours. Reading the code did not find
it: every connect() failure path here closes its socket.
So count. Every socket is tagged at creation and untagged at close, across all
ten sites, with a counter for closes that fail. Already rules out three
explanations: nothing is created or closed behind the counter (untagged closes
are zero), no close is failing, and the leaked sockets are not in the live set --
tracked live matches what the OS reports as established, while the bound pile is
something the program already closed successfully.
Diffstat (limited to 'src/nostr.cpp')
| -rw-r--r-- | src/nostr.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/nostr.cpp b/src/nostr.cpp index 17139ad..dc96be2 100644 --- a/src/nostr.cpp +++ b/src/nostr.cpp | |||
| @@ -462,7 +462,7 @@ public: | |||
| 462 | { | 462 | { |
| 463 | if (ssl) { SSL_shutdown(ssl); SSL_free(ssl); ssl = NULL; } | 463 | if (ssl) { SSL_shutdown(ssl); SSL_free(ssl); ssl = NULL; } |
| 464 | if (sslctx) { SSL_CTX_free(sslctx); sslctx = NULL; } | 464 | if (sslctx) { SSL_CTX_free(sslctx); sslctx = NULL; } |
| 465 | if (hSocket != INVALID_SOCKET) { closesocket(hSocket); hSocket = INVALID_SOCKET; } | 465 | if (hSocket != INVALID_SOCKET) { BtfCloseSocket(hSocket); hSocket = INVALID_SOCKET; } |
| 466 | } | 466 | } |
| 467 | 467 | ||
| 468 | int RawRead(char* buf, int len) | 468 | int RawRead(char* buf, int len) |
| @@ -518,7 +518,7 @@ public: | |||
| 518 | bool fConnected = false; | 518 | bool fConnected = false; |
| 519 | for (rp = res; rp != NULL; rp = rp->ai_next) | 519 | for (rp = res; rp != NULL; rp = rp->ai_next) |
| 520 | { | 520 | { |
| 521 | hSocket = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol); | 521 | hSocket = BtfSocketTag(socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol), SOCK_NOSTR); |
| 522 | if (hSocket == INVALID_SOCKET) | 522 | if (hSocket == INVALID_SOCKET) |
| 523 | continue; | 523 | continue; |
| 524 | 524 | ||
| @@ -542,7 +542,7 @@ public: | |||
| 542 | break; | 542 | break; |
| 543 | } | 543 | } |
| 544 | 544 | ||
| 545 | closesocket(hSocket); | 545 | BtfCloseSocket(hSocket); |
| 546 | hSocket = INVALID_SOCKET; | 546 | hSocket = INVALID_SOCKET; |
| 547 | } | 547 | } |
| 548 | freeaddrinfo(res); | 548 | freeaddrinfo(res); |