[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [snowflake/master] Exit immediately after SIGTERM is there are no signals running.



commit bdc1798adb83a34b5f0362c67dc5d997ed4840bd
Author: David Fifield <david@xxxxxxxxxxxxxxx>
Date:   Wed Mar 21 00:51:04 2018 -0700

    Exit immediately after SIGTERM is there are no signals running.
    
    Cf. https://bugs.torproject.org/24875
---
 client/snowflake.go | 7 ++-----
 server/server.go    | 7 ++-----
 2 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/client/snowflake.go b/client/snowflake.go
index 105fd30..e0f9746 100644
--- a/client/snowflake.go
+++ b/client/snowflake.go
@@ -241,11 +241,8 @@ func main() {
 		ln.Close()
 	}
 	snowflakes.End()
-	for n := range handlerChan {
-		numHandlers += n
-		if numHandlers == 0 {
-			break
-		}
+	for numHandlers > 0 {
+		numHandlers += <-handlerChan
 	}
 	log.Println("snowflake is done.")
 }
diff --git a/server/server.go b/server/server.go
index 0136fc0..7c5a205 100644
--- a/server/server.go
+++ b/server/server.go
@@ -393,10 +393,7 @@ func main() {
 	for _, server := range servers {
 		server.Close()
 	}
-	for n := range handlerChan {
-		numHandlers += n
-		if numHandlers == 0 {
-			break
-		}
+	for numHandlers > 0 {
+		numHandlers += <-handlerChan
 	}
 }



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits