Fixed race condition on deleting taskListContext from tasksLists map
Reviewers: samar, sivakk
Subscribers: jenkins, aravindv, venkat
@@ -357,13 +357,16 @@ func (e *matchingEngineImpl) getTask(taskList *taskListID) (*taskContext, error)
}
func (e *matchingEngineImpl) unloadTaskList(id *taskListID) {
- var tlCtx *taskListContext
e.taskListsLock.Lock()
- tlCtx = e.taskLists[*id]
+ tlCtx, ok := e.taskLists[*id]
+ if ok {
delete(e.taskLists, *id)
+ }
e.taskListsLock.Unlock()
+ if ok {
tlCtx.Stop()
}
+}
// Populate the decision task response based on context and scheduled/started events.
func (e *matchingEngineImpl) createPollForDecisionTaskResponse(context *taskContext,
