Fix race in FirewalldInit
It was possible that signalHandler won't start because connections is not assigned. Signed-off-by: Alexander Morozov <lk4d4@docker.com>
This commit is contained in:
parent
d3d6eed2b3
commit
112ff23e41
1 changed files with 11 additions and 10 deletions
|
@ -2,9 +2,10 @@ package iptables
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/godbus/dbus"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type IPV string
|
||||
|
@ -40,6 +41,9 @@ func FirewalldInit() {
|
|||
if err != nil {
|
||||
logrus.Errorf("Failed to connect to D-Bus system bus: %s", err)
|
||||
}
|
||||
if connection != nil {
|
||||
go signalHandler()
|
||||
}
|
||||
|
||||
firewalldRunning = checkRunning()
|
||||
}
|
||||
|
@ -76,13 +80,11 @@ func (c *Conn) initConnection() error {
|
|||
|
||||
c.signal = make(chan *dbus.Signal, 10)
|
||||
c.sysconn.Signal(c.signal)
|
||||
go signalHandler()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func signalHandler() {
|
||||
if connection != nil {
|
||||
for signal := range connection.signal {
|
||||
if strings.Contains(signal.Name, "NameOwnerChanged") {
|
||||
firewalldRunning = checkRunning()
|
||||
|
@ -91,7 +93,6 @@ func signalHandler() {
|
|||
reloaded()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func dbusConnectionChanged(args []interface{}) {
|
||||
|
|
Loading…
Reference in a new issue