diff --git a/assets_test.go b/assets_test.go index b0cee3b18..fa7931100 100644 --- a/assets_test.go +++ b/assets_test.go @@ -25,9 +25,15 @@ func TestAssetsPath(t *testing.T) { t.Errorf("Expected path to be a .caddy folder, got: %v", actual) } - os.Setenv("CADDYPATH", "testpath") + err := os.Setenv("CADDYPATH", "testpath") + if err != nil { + t.Error("Could not set CADDYPATH") + } if actual, expected := AssetsPath(), "testpath"; actual != expected { t.Errorf("Expected path to be %v, got: %v", expected, actual) } - os.Setenv("CADDYPATH", "") + err = os.Setenv("CADDYPATH", "") + if err != nil { + t.Error("Could not set CADDYPATH") + } } diff --git a/caddy.go b/caddy.go index 4c1cbb0ff..032d8721c 100644 --- a/caddy.go +++ b/caddy.go @@ -206,12 +206,15 @@ func (i *Instance) Restart(newCaddyfile Input) (*Instance, error) { // success! stop the old instance for _, shutdownFunc := range i.onShutdown { - err := shutdownFunc() + err = shutdownFunc() if err != nil { return i, err } } - i.Stop() + err = i.Stop() + if err != nil { + return i, err + } // Execute instantiation events EmitEvent(InstanceStartupEvent, newInst) @@ -483,14 +486,14 @@ func startWithListenerFds(cdyfile Input, inst *Instance, restartFds map[string]r if !IsUpgrade() && restartFds == nil { // first startup means not a restart or upgrade for _, firstStartupFunc := range inst.onFirstStartup { - err := firstStartupFunc() + err = firstStartupFunc() if err != nil { return err } } } for _, startupFunc := range inst.onStartup { - err := startupFunc() + err = startupFunc() if err != nil { return err } @@ -653,7 +656,10 @@ func startServers(serverList []Server, inst *Instance, restartFds map[string]res if fdIndex, ok := loadedGob.ListenerFds["tcp"+addr]; ok { file := os.NewFile(fdIndex, "") ln, err = net.FileListener(file) - file.Close() + if err != nil { + return err + } + err = file.Close() if err != nil { return err } @@ -661,7 +667,10 @@ func startServers(serverList []Server, inst *Instance, restartFds map[string]res if fdIndex, ok := loadedGob.ListenerFds["udp"+addr]; ok { file := os.NewFile(fdIndex, "") pc, err = net.FilePacketConn(file) - file.Close() + if err != nil { + return err + } + err = file.Close() if err != nil { return err } @@ -684,7 +693,10 @@ func startServers(serverList []Server, inst *Instance, restartFds map[string]res if err != nil { return err } - file.Close() + err = file.Close() + if err != nil { + return err + } } // packetconn if old.packet != nil { @@ -696,7 +708,10 @@ func startServers(serverList []Server, inst *Instance, restartFds map[string]res if err != nil { return err } - file.Close() + err = file.Close() + if err != nil { + return err + } } } } diff --git a/upgrade.go b/upgrade.go index 5e9f15589..8214937b9 100644 --- a/upgrade.go +++ b/upgrade.go @@ -136,7 +136,10 @@ func Upgrade() error { // immediately close our dup'ed fds and the write end of our signal pipe for _, f := range extraFiles { - f.Close() + err = f.Close() + if err != nil { + return err + } } // feed Caddyfile to the child @@ -144,7 +147,10 @@ func Upgrade() error { if err != nil { return err } - wpipe.Close() + err = wpipe.Close() + if err != nil { + return err + } // determine whether child startup succeeded answer, readErr := ioutil.ReadAll(sigrpipe)