1
0
Fork 0
mirror of https://github.com/postmannen/ctrl.git synced 2024-12-14 12:37:31 +00:00

removed no longer needed mutex

This commit is contained in:
postmannen 2021-10-08 22:39:46 +02:00
parent bbfea0afd5
commit ffc5d76623
4 changed files with 2 additions and 10 deletions

View file

@ -65,7 +65,6 @@ The idea behind Steward is to help out with exactly these issues, allowing you t
- [Subject](#subject) - [Subject](#subject)
- [Complete subject example](#complete-subject-example) - [Complete subject example](#complete-subject-example)
- [TODO](#todo) - [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) - [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) - [Add Op option the remove messages from the queue on nodes](#add-op-option-the-remove-messages-from-the-queue-on-nodes)
- [Disclaimer](#disclaimer) - [Disclaimer](#disclaimer)
@ -1000,10 +999,6 @@ For CliCommand message to a node named "ship1" of type Command and it wants an A
## TODO ## 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 ### 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. - A Handler that writes to this folder.

View file

@ -19,7 +19,7 @@ type processes struct {
// The active spawned processes // The active spawned processes
active procsMap active procsMap
// mutex to lock the map // mutex to lock the map
mu sync.RWMutex // mu sync.RWMutex
// The last processID created // The last processID created
lastProcessID int lastProcessID int
// The instance global prometheus registry. // The instance global prometheus registry.

View file

@ -375,7 +375,6 @@ func (m methodREQOpCommand) handler(proc process, message Message, nodeName stri
switch message.Operation.OpCmd { switch message.Operation.OpCmd {
case "ps": case "ps":
proc.processes.mu.Lock()
// Loop the the processes map, and find all that is active to // Loop the the processes map, and find all that is active to
// be returned in the reply message. // 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": case "startProc":
// Set the empty interface type dst to &OpStart. // Set the empty interface type dst to &OpStart.

View file

@ -431,7 +431,7 @@ func (s *server) routeMessagesToProcess(dbFileName string) {
// message channel. // message channel.
if valueOK { if valueOK {
// fmt.Printf(" * DEBUG1.3 * MUTEX.LOCK before range existingProcIDMap, samDBValue.id: %#v, existingProcIDMap length: %v\n", samTmp.samDBValue.ID, len(existingProcIDMap)) // 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 pid int
var proc process var proc process
// forLoopCounter := 1 // forLoopCounter := 1
@ -449,7 +449,6 @@ func (s *server) routeMessagesToProcess(dbFileName string) {
// forLoopCounter++ // forLoopCounter++
} }
s.processes.mu.Unlock()
// We have found the process to route the message to, deliver it. // We have found the process to route the message to, deliver it.
proc.subject.messageCh <- m proc.subject.messageCh <- m