public inbox for nncp-devel@lists.cypherpunks.ru
Atom feed
* [PATCH] Check before closing potentially nil channel
@ 2022-10-28 15:05 Emery Hemingway
  2022-10-30 15:31 ` Sergey Matveev
  0 siblings, 1 reply; 2+ messages in thread
From: Emery Hemingway @ 2022-10-28 15:05 UTC (permalink / raw)
  To: nncp-devel; +Cc: Emery Hemingway

I had a problem here when the nncp-daemon starts up with while being
spammed by new connection requests.

---
 src/cmd/nncp-daemon/main.go | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/cmd/nncp-daemon/main.go b/src/cmd/nncp-daemon/main.go
index 710b687..39b25c4 100644
--- a/src/cmd/nncp-daemon/main.go
+++ b/src/cmd/nncp-daemon/main.go
@@ -310,7 +310,9 @@ func main() {
                        }
                        <-nodeIdC // call completion
                        if *autoToss {
-                               close(autoTossFinish)
+                               if autoTossFinish != nil {
+                                       close(autoTossFinish)
+                               }
                                <-autoTossBadCode
                        }
                        conn.Close()
-- 
2.37.3

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Check before closing potentially nil channel
  2022-10-28 15:05 [PATCH] Check before closing potentially nil channel Emery Hemingway
@ 2022-10-30 15:31 ` Sergey Matveev
  0 siblings, 0 replies; 2+ messages in thread
From: Sergey Matveev @ 2022-10-30 15:31 UTC (permalink / raw)
  To: nncp-devel

[-- Attachment #1: Type: text/plain, Size: 514 bytes --]

Greetings!

*** Emery Hemingway [2022-10-28 15:05]:
>I had a problem here when the nncp-daemon starts up with while being
>spammed by new connection requests.

Thank you for noticing that bug! Fixed in 8.8.1 release.
Thanks for the patch, but it should also fail (however I did not check)
because of similarly closed autoTossBadCode channel. I just reused the
same condition (nodeId != nil).

-- 
Sergey Matveev (http://www.stargrave.org/)
OpenPGP: 12AD 3268 9C66 0D42 6967  FD75 CB82 0563 2107 AD8A

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-10-30 15:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-28 15:05 [PATCH] Check before closing potentially nil channel Emery Hemingway
2022-10-30 15:31 ` Sergey Matveev