Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Core crash when cancelling server timers
#1
0
When cancelling server timers a core will crash as it is removing a timer from the map and increasing the iterator twice by calling erase() function and afterwards increasing it once again when entering a new cycle of loop. One way of solving this issue is to first collect the timers which must be removed and clean them up at the end. You can also add a simple counter which is increased at each end of the loop's cycle and remove the timer directly from the first loop by specifying the position with the counter itself.

Note that this issue seems to appear after upgrading code to C++11 or higher.

Replace the following function inside questmanager.cpp:
Code:
void CQuestManager::CancelServerTimers(DWORD arg)
    {
        vector<pair<string, DWORD>> ServerTimersToDelete;

        for (const auto& kv : m_mapServerTimer) {
            if (kv.first.second == arg) {
                LPEVENT event = kv.second;
                event_cancel(&event);
                ServerTimersToDelete.push_back(kv.first);
            }
        }

        // Delete all the required server timers
        for (const auto &timer : ServerTimersToDelete)
            m_mapServerTimer.erase(timer);

        // Clean up
        ServerTimersToDelete.clear();
    }
Reply
#2
0
Many thanks for support how I can thank you?
Reply
#3
0
It is remarkable, very good message

Latest firmwares https://samfirm.shop samfirm shop
link 789jksndjhwev23d34@#fgdfgh
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)