Skip to content

Commit

Permalink
crashfix: iterator invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
outman-zhou committed Apr 24, 2020
1 parent 23ded3b commit d31e2e9
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions mars/stn/src/longlink_task_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -523,8 +523,9 @@ bool LongLinkTaskManager::__SingleRespHandle(std::list<TaskProfile>::iterator _i
}

void LongLinkTaskManager::__BatchErrorRespHandleByUserId(const std::string& _user_id, ErrCmdType _err_type, int _err_code, int _fail_handle, uint32_t _src_taskid, bool _callback_runing_task_only) {
auto first = lst_cmd_.begin();
while(first != lst_cmd_.end()) {
std::list<TaskProfile> temp = lst_cmd_;
auto first = temp.begin();
while(first != temp.end()) {
if(first->task.user_id != _user_id) {
++first;
continue;
Expand Down Expand Up @@ -556,16 +557,21 @@ void LongLinkTaskManager::__BatchErrorRespHandle(const std::string& _name, ErrCm
continue;
}

bool erased_from_list = false;
auto longlink = GetLongLink(first->task.channel_name);
if(longlink != nullptr) {
const ConnectProfile &profile = longlink->Channel()->Profile();
if (_src_taskid == Task::kInvalidTaskID || _src_taskid == first->task.taskid)
__SingleRespHandle(first, _err_type, _err_code, _fail_handle, profile);
erased_from_list = __SingleRespHandle(first, _err_type, _err_code, _fail_handle, profile);
else
__SingleRespHandle(first, _err_type, 0, _fail_handle, profile);
erased_from_list = __SingleRespHandle(first, _err_type, 0, _fail_handle, profile);
}

first = next;
if (erased_from_list){
// fallback iterator to begin
first = lst_cmd_.begin();
}
}

lastbatcherrortime_ = ::gettickcount();
Expand Down

0 comments on commit d31e2e9

Please sign in to comment.