From ffc5d76623728103bc5138c8552692d7c7a3fbb6 Mon Sep 17 00:00:00 2001 From: postmannen Date: Fri, 8 Oct 2021 22:39:46 +0200 Subject: [PATCH] removed no longer needed mutex --- README.md | 5 ----- processes.go | 2 +- requests.go | 2 -- server.go | 3 +-- 4 files changed, 2 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 0b218c5..64ef95e 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,6 @@ The idea behind Steward is to help out with exactly these issues, allowing you t - [Subject](#subject) - [Complete subject example](#complete-subject-example) - [TODO](#todo) - - [Move the processes map into it's own go routine](#move-the-processes-map-into-its-own-go-routine) - [Services at startup of Steward. Could be implemented by having a local folder of messages to go through at startup. What is needed](#services-at-startup-of-steward-could-be-implemented-by-having-a-local-folder-of-messages-to-go-through-at-startup-what-is-needed) - [Add Op option the remove messages from the queue on nodes](#add-op-option-the-remove-messages-from-the-queue-on-nodes) - [Disclaimer](#disclaimer) @@ -1000,10 +999,6 @@ For CliCommand message to a node named "ship1" of type Command and it wants an A ## TODO -### Move the processes map into it's own go routine - -Use channels to update and get values, and get rid of the use of mutex's. - ### Services at startup of Steward. Could be implemented by having a local folder of messages to go through at startup. What is needed - A Handler that writes to this folder. diff --git a/processes.go b/processes.go index a791ce4..db9738e 100644 --- a/processes.go +++ b/processes.go @@ -19,7 +19,7 @@ type processes struct { // The active spawned processes active procsMap // mutex to lock the map - mu sync.RWMutex + // mu sync.RWMutex // The last processID created lastProcessID int // The instance global prometheus registry. diff --git a/requests.go b/requests.go index aa8ac5f..3bb6a26 100644 --- a/requests.go +++ b/requests.go @@ -375,7 +375,6 @@ func (m methodREQOpCommand) handler(proc process, message Message, nodeName stri switch message.Operation.OpCmd { case "ps": - proc.processes.mu.Lock() // Loop the the processes map, and find all that is active to // be returned in the reply message. @@ -389,7 +388,6 @@ func (m methodREQOpCommand) handler(proc process, message Message, nodeName stri } } - proc.processes.mu.Unlock() case "startProc": // Set the empty interface type dst to &OpStart. diff --git a/server.go b/server.go index 31c51d5..bec2c05 100644 --- a/server.go +++ b/server.go @@ -431,7 +431,7 @@ func (s *server) routeMessagesToProcess(dbFileName string) { // message channel. if valueOK { // fmt.Printf(" * DEBUG1.3 * MUTEX.LOCK before range existingProcIDMap, samDBValue.id: %#v, existingProcIDMap length: %v\n", samTmp.samDBValue.ID, len(existingProcIDMap)) - s.processes.mu.Lock() + // var pid int var proc process // forLoopCounter := 1 @@ -449,7 +449,6 @@ func (s *server) routeMessagesToProcess(dbFileName string) { // forLoopCounter++ } - s.processes.mu.Unlock() // We have found the process to route the message to, deliver it. proc.subject.messageCh <- m