Commit 6fcf8ac2 authored by Phoebe Buckheister's avatar Phoebe Buckheister 🦎 Committed by Christian Mohrbacher

storage: properly release sessions when they are no longer needed

 * StorageResyncStarted must release all sessions it references
 * CloseChunkFile does not need a session for most things that can fail
   directly (and want to sent a response after that). reference the
   session only after all such checks have been done, then the session
   will be released properly.

see #579
parent a2aaa7a8
......@@ -17,9 +17,6 @@ bool CloseChunkFileMsgEx::processIncoming(ResponseContext& ctx)
App* app = Program::getApp();
Config* config = app->getConfig();
SessionStore* sessions = app->getSessions();
Session* session = sessions->referenceSession(getSessionID(), true);
SessionLocalFileStore* sessionLocalFiles = session->getLocalFiles();
SessionLocalFile* sessionLocalFile = NULL;
uint16_t targetID;
bool removeRes;
......@@ -31,6 +28,9 @@ bool CloseChunkFileMsgEx::processIncoming(ResponseContext& ctx)
std::string fileHandleID(getFileHandleID() );
bool isMirrorSession = isMsgHeaderFeatureFlagSet(CLOSECHUNKFILEMSG_FLAG_BUDDYMIRROR);
Session* session;
SessionLocalFileStore* sessionLocalFiles;
SessionLocalFile* sessionLocalFile = NULL;
// select the right targetID
......@@ -64,6 +64,9 @@ bool CloseChunkFileMsgEx::processIncoming(ResponseContext& ctx)
goto send_response;
}
session = sessions->referenceSession(getSessionID(), true);
sessionLocalFiles = session->getLocalFiles();
removeRes = sessionLocalFiles->removeSession(
fileHandleID, targetID, isMirrorSession, &sessionLocalFile);
if(!removeRes)
......
......@@ -37,5 +37,7 @@ void StorageResyncStartedMsgEx::deleteMirrorSessions(uint16_t targetID)
SessionLocalFileStore* sessionLocalFiles = session->getLocalFiles();
sessionLocalFiles->removeAllMirrorSessions(targetID);
sessions->releaseSession(session);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment