* control: safely restart DHCP server
* control: use mutex in all POST,PUT,DELETE handlers
This commit is contained in:
12
dhcp.go
12
dhcp.go
@@ -50,6 +50,11 @@ func handleDHCPSetConfig(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
err = dhcpServer.Stop()
|
||||
if err != nil {
|
||||
log.Error("failed to stop the DHCP server: %s", err)
|
||||
}
|
||||
|
||||
if newconfig.Enabled {
|
||||
err := dhcpServer.Start(&newconfig)
|
||||
if err != nil {
|
||||
@@ -57,12 +62,7 @@ func handleDHCPSetConfig(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
}
|
||||
if !newconfig.Enabled {
|
||||
err := dhcpServer.Stop()
|
||||
if err != nil {
|
||||
log.Error("failed to stop the DHCP server: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
config.DHCP = newconfig
|
||||
httpUpdateConfigReloadDNSReturnOK(w, r)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user