[lxc-devel] [lxd/master] dnsmasq: Adds 100ms sleep to successful Kill() to allow sockets to be released by OS

tomponline on Github lxc-bot at linuxcontainers.org
Fri Oct 9 16:21:54 UTC 2020


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 453 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20201009/7a4ebec5/attachment.bin>
-------------- next part --------------
From 23694b750d164369ece64c402f36a76358d2d957 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Fri, 9 Oct 2020 17:19:44 +0100
Subject: [PATCH] lxd/dnsmasq: Adds 100ms sleep to successful Kill() to allow
 sockets to be released by OS

Otherwise trying to immediately start dnsmasq again can result in socket binding errors.

Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
 lxd/dnsmasq/dnsmasq.go | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lxd/dnsmasq/dnsmasq.go b/lxd/dnsmasq/dnsmasq.go
index 90c222ae66..d8491c2572 100644
--- a/lxd/dnsmasq/dnsmasq.go
+++ b/lxd/dnsmasq/dnsmasq.go
@@ -8,6 +8,7 @@ import (
 	"os"
 	"strings"
 	"sync"
+	"time"
 
 	"github.com/lxc/lxd/lxd/project"
 	"github.com/lxc/lxd/shared"
@@ -95,7 +96,8 @@ func Kill(name string, reload bool) error {
 		return fmt.Errorf("Unable to kill dnsmasq: %s", err)
 	}
 
-	// Cleanup
+	time.Sleep(100 * time.Millisecond) // Give OS time to release sockets.
+
 	return nil
 }
 


More information about the lxc-devel mailing list