From cedf0cb435b5ca53cc8141baed07078894945d2e Mon Sep 17 00:00:00 2001 From: Atin Mukherjee Date: Thu, 10 Jan 2019 14:01:32 +0530 Subject: [PATCH] brick-mux : fix error handling Fix error handling from ReadFromPidFile call. Also added a check to bypass detach if the brick pid is -1. Signed-off-by: Atin Mukherjee --- glusterd2/brickmux/demultiplex.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/glusterd2/brickmux/demultiplex.go b/glusterd2/brickmux/demultiplex.go index 212eb5508..d7399bfc4 100644 --- a/glusterd2/brickmux/demultiplex.go +++ b/glusterd2/brickmux/demultiplex.go @@ -32,11 +32,17 @@ func Demultiplex(b brick.Brickinfo) error { if err != nil { return err } - if pidOnFile, err = daemon.ReadPidFromFile(brickDaemon.PidFile()); err == nil { + if pidOnFile, err = daemon.ReadPidFromFile(brickDaemon.PidFile()); err != nil { log.WithFields(log.Fields{"brick": b.String(), "pidfile": brickDaemon.PidFile()}).Error("Failed to read the pidfile") return err + } + if pidOnFile == -1 { + log.WithFields(log.Fields{"brick": b.String(), + "pidfile": brickDaemon.PidFile()}).Error("Pid is -1") + return err + } brickDaemon.Socketfilepath, err = glusterdGetSockFromBrickPid(pidOnFile) if err != nil {