Skip to content

Commit

Permalink
removed nil channel sets
Browse files Browse the repository at this point in the history
  • Loading branch information
wonwuakpa-msft committed Oct 21, 2024
1 parent 0f823a5 commit 0efbae4
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions ste/jobStatusManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,19 +176,17 @@ func (jm *jobMgr) handleStatusUpdateMessage() {
case <-jstm.listReq:
/* Display stats */
js.Timestamp = time.Now().UTC()
if jstm.respChan != nil {
select {
case jstm.respChan <- *js:
// Send on the channel
case <-jstm.statusMgrDone:
// If we time out, no biggie. This isn't world-ending, nor is it essential info. The other side stopped listening by now.
}
defer func() { // Exit gracefully if panic
if recErr := recover(); recErr != nil {
jm.Log(common.LogError, "Cannot send message on respChan")
}
}()
select {
case jstm.respChan <- *js:
// Send on the channel
case <-jstm.statusMgrDone:
// If we time out, no biggie. This isn't world-ending, nor is it essential info. The other side stopped listening by now.
}
defer func() { // Exit gracefully if panic
if recErr := recover(); recErr != nil {
jm.Log(common.LogError, "Cannot send message on respChan")
}
}()
// Reset the lists so that they don't keep accumulating and take up excessive memory
// There is no need to keep sending the same items over and over again
js.FailedTransfers = []common.TransferDetail{}
Expand All @@ -198,8 +196,6 @@ func (jm *jobMgr) handleStatusUpdateMessage() {
close(jstm.statusMgrDone)
close(jstm.respChan)
close(jstm.listReq)
jstm.listReq = nil
jstm.respChan = nil
return
}
}
Expand Down

0 comments on commit 0efbae4

Please sign in to comment.