mirror of
https://gitee.com/an-tao/drogon.git
synced 2024-12-02 11:47:56 +08:00
parent
80a8f62e30
commit
fda2719dd4
@ -188,6 +188,7 @@ class Session
|
||||
{
|
||||
std::lock_guard<std::mutex> lck(mutex_);
|
||||
sessionId_ = id;
|
||||
needToChange_ = false;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -71,14 +71,11 @@ void SessionManager::changeSessionId(const SessionPtr &sessionPtr)
|
||||
auto oldId = sessionPtr->sessionId();
|
||||
auto newId = utils::getUuid();
|
||||
sessionPtr->setSessionId(newId);
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mapMutex_);
|
||||
// For requests sent before setting the new session ID to the client, we
|
||||
// reserve the old session slot for a period of time.
|
||||
sessionMapPtr_->runAfter(10, [this, oldId = std::move(oldId)]() {
|
||||
LOG_TRACE << "remove the old slot of the session";
|
||||
sessionMapPtr_->erase(oldId);
|
||||
});
|
||||
sessionMapPtr_->insert(newId, sessionPtr, timeout_);
|
||||
}
|
||||
sessionMapPtr_->insert(newId, sessionPtr, timeout_);
|
||||
// For requests sent before setting the new session ID to the client, we
|
||||
// reserve the old session slot for a period of time.
|
||||
sessionMapPtr_->runAfter(10, [this, oldId = std::move(oldId)]() {
|
||||
LOG_TRACE << "remove the old slot of the session";
|
||||
sessionMapPtr_->erase(oldId);
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue
Block a user