diff --git a/bindings/follow.go b/bindings/follow.go index 892a6311d7b5a76613303f379ffe7d0f2f0abdac..362ace98f2c8c66f53717b405153c261f75b2597 100644 --- a/bindings/follow.go +++ b/bindings/follow.go @@ -136,8 +136,18 @@ func (c *Cmix) IsHealthy() bool { return c.api.GetCmix().IsHealthy() } -// GetRunningProcesses returns the name of all running processes at the time -// of this call. +// GetRunningProcesses returns the names of all running processes at the time +// of this call. Note that this list may change and is subject to race +// conditions if multiple threads are in the process of starting or stopping. +// +// Returns: +// - []byte - A JSON marshalled list of all running processes. +// +// JSON Example: +// { +// "FileTransfer{BatchBuilderThread, FilePartSendingThread#0, FilePartSendingThread#1, FilePartSendingThread#2, FilePartSendingThread#3}", +// "MessageReception Worker 0" +// } func (c *Cmix) GetRunningProcesses() ([]byte, error) { return json.Marshal(c.api.GetRunningProcesses()) } diff --git a/fileTransfer/manager.go b/fileTransfer/manager.go index 6adcdc51a7bc7346ae99c4168af06f40caac2111..549a9a799dc9d6f75c415a71757954a36cc0d0f7 100644 --- a/fileTransfer/manager.go +++ b/fileTransfer/manager.go @@ -219,8 +219,8 @@ func (m *manager) StartProcesses() (stoppable.Stoppable, error) { batchBuilderStop := stoppable.NewSingle(batchBuilderThreadStoppable) // Start sending threads - // Note that the startSendingWorkerPool creates go routines for over worker - // As a result, there is no need to run it asynchronously. In fact, + // Note that the startSendingWorkerPool already creates thread for every + // worker. As a result, there is no need to run it asynchronously. In fact, // running this asynchronously could result in a race condition where // some worker threads are not added to senderPoolStop before that stoppable // is added to the multiStoppable. @@ -229,7 +229,6 @@ func (m *manager) StartProcesses() (stoppable.Stoppable, error) { // Create a multi stoppable multiStoppable := stoppable.NewMulti(fileTransferStoppable) - jww.DEBUG.Printf("Adding sender pool w/ name %s", senderPoolStop.Name()) multiStoppable.Add(senderPoolStop) multiStoppable.Add(batchBuilderStop) diff --git a/stoppable/multi.go b/stoppable/multi.go index e7e40ce5c6d86b33239edd17ae1223893de06137..3ac77c7507fb058af1deac2b098121b16d3569b0 100644 --- a/stoppable/multi.go +++ b/stoppable/multi.go @@ -76,7 +76,9 @@ func (m *Multi) GetStatus() Status { return lowestStatus } -// GetRunningProcesses returns a list of running Stoppable processes. +// GetRunningProcesses returns the names of all running processes at the time +// of this call. Note that this list may change and is subject to race +// conditions if multiple threads are in the process of starting or stopping. func (m *Multi) GetRunningProcesses() []string { m.mux.RLock() diff --git a/xxdk/cmix.go b/xxdk/cmix.go index b3f5e5bd42f3341553c1d57b3484ea6efa485bf5..a2b8b8b9ad3c6e7cc77c6eb325fabba17084cff0 100644 --- a/xxdk/cmix.go +++ b/xxdk/cmix.go @@ -397,8 +397,9 @@ func (c *Cmix) HasRunningProcessies() bool { return !c.followerServices.stoppable.IsStopped() } -// GetRunningProcesses returns the name of all running processes at the time -// of this call. +// GetRunningProcesses returns the names of all running processes at the time +// of this call. Note that this list may change and is subject to race +// conditions if multiple threads are in the process of starting or stopping. func (c *Cmix) GetRunningProcesses() []string { return c.followerServices.stoppable.GetRunningProcesses() }