commit 7d56ec4f381e8b1aedfda360594e35a5731b5337 Author: David Fifield david@bamsoftware.com Date: Tue Mar 20 23:14:16 2018 -0700
Exit immediately after SIGTERM even if no handlers are running.
The loop logic assumed that there was at least one handler running when a signal was received; if there were none, it would wait forever for a handler event to happen.
Cf. https://bugs.torproject.org/24875 --- examples/dummy-client/dummy-client.go | 7 ++----- examples/dummy-server/dummy-server.go | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-)
diff --git a/examples/dummy-client/dummy-client.go b/examples/dummy-client/dummy-client.go index de7f367..4812a9b 100644 --- a/examples/dummy-client/dummy-client.go +++ b/examples/dummy-client/dummy-client.go @@ -140,10 +140,7 @@ func main() { for _, ln := range listeners { ln.Close() } - for n := range handlerChan { - numHandlers += n - if numHandlers == 0 { - break - } + for numHandlers > 0 { + numHandlers += <-handlerChan } } diff --git a/examples/dummy-server/dummy-server.go b/examples/dummy-server/dummy-server.go index aea4df4..db24fab 100644 --- a/examples/dummy-server/dummy-server.go +++ b/examples/dummy-server/dummy-server.go @@ -132,10 +132,7 @@ func main() { for _, ln := range listeners { ln.Close() } - for n := range handlerChan { - numHandlers += n - if numHandlers == 0 { - break - } + for numHandlers > 0 { + numHandlers += <-handlerChan } }
tor-commits@lists.torproject.org