[lxc-devel] [lxd/master] proxy: unconditionally kill proxy

brauner on Github lxc-bot at linuxcontainers.org
Thu Jun 14 08:56:42 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 513 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180614/5e69995d/attachment.bin>
-------------- next part --------------
From cea9ee664b31e918390e0636b89fac6afb0d952f Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Thu, 14 Jun 2018 10:54:39 +0200
Subject: [PATCH] proxy: unconditionally kill proxy

Keeping the proxy around might to lead to weird issues. For example, ceph
considers an rbd image to be still in use if the proxy is still alive.

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 lxd/main_forkproxy.go | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/lxd/main_forkproxy.go b/lxd/main_forkproxy.go
index 074bb8c72..7a71ae706 100644
--- a/lxd/main_forkproxy.go
+++ b/lxd/main_forkproxy.go
@@ -349,25 +349,21 @@ func (c *cmdForkproxy) Run(cmd *cobra.Command, args []string) error {
 	}
 
 	// Handle SIGTERM which is sent when the proxy is to be removed
-	terminate := false
 	sigs := make(chan os.Signal, 1)
 	signal.Notify(sigs, syscall.SIGTERM)
 
 	// Wait for SIGTERM and close the listener in order to exit the loop below
-	killOnUDP := syscall.Getpid()
-	go func() {
+	go func(self int) {
 		<-sigs
-		terminate = true
+
 		file.Close()
 		if lAddr.connType == "udp" {
 			srcConn.Close()
-			// Kill ourselves since we will otherwise block on UDP
-			// connect() or poll().
-			syscall.Kill(killOnUDP, syscall.SIGKILL)
 		} else {
 			listener.Close()
 		}
-	}()
+		syscall.Kill(self, syscall.SIGKILL)
+	}(syscall.Getpid())
 
 	connectAddr := args[3]
 	cAddr := parseAddr(connectAddr)
@@ -420,10 +416,6 @@ func (c *cmdForkproxy) Run(cmd *cobra.Command, args []string) error {
 			// Accept a new client
 			srcConn, err = listener.Accept()
 			if err != nil {
-				if terminate {
-					break
-				}
-
 				fmt.Printf("error: Failed to accept new connection: %v\n", err)
 				continue
 			}


More information about the lxc-devel mailing list