// This should only be called while holding a lock on s.L. // This unfortunately holds the mutex for a little while, and if the // command dies super early, the entire slave pretty well deadlocks. // TODO: review this. func (s *SlaveNode) bootCommand(request *CommandRequest) { identifier := request.Name // TODO: If crashed, do something different... msg := messages.CreateSpawnCommandMessage(identifier) _, err := s.socket.WriteMessage(msg) if err != nil { slog.Error(err) return } commandFD, err := s.socket.ReadFD() if err != nil { fmt.Println(s.socket) slog.Error(err) return } fileName := strconv.Itoa(rand.Int()) commandFile := unixsocket.FdToFile(commandFD, fileName) request.Retchan <- commandFile }
// This should only be called while holding a lock on s.L. // This unfortunately holds the mutex for a little while, and if the // command dies super early, the entire slave pretty well deadlocks. // TODO: review this. func (s *SlaveNode) bootCommand(request *CommandRequest) { if s.State == SCrashed { request.Retchan <- &CommandReply{SCrashed, nil} return } identifier := request.Name msg := messages.CreateSpawnCommandMessage(identifier) _, err := s.socket.WriteMessage(msg) if err != nil { slog.Error(err) return } commandFD, err := s.socket.ReadFD() if err != nil { fmt.Println(s.socket) slog.Error(err) return } fileName := strconv.Itoa(rand.Int()) commandFile := unixsocket.FdToFile(commandFD, fileName) request.Retchan <- &CommandReply{s.State, commandFile} }
// This unfortunately holds the mutex for a little while, and if the // command dies super early, the entire slave pretty well deadlocks. // TODO: review this. func (s *SlaveNode) bootCommand(request *CommandRequest) { s.L.Lock() defer s.L.Unlock() s.trace("now sending command boot request %v", request) identifier := request.Name msg := messages.CreateSpawnCommandMessage(identifier) _, err := s.socket.WriteMessage(msg) if err != nil { slog.Error(err) return } commandFD, err := s.socket.ReadFD() if err != nil { fmt.Println(s.socket) slog.Error(err) return } fileName := strconv.Itoa(rand.Int()) commandFile := os.NewFile(uintptr(commandFD), fileName) request.Retchan <- &CommandReply{s.state, commandFile} }