Fixed session cache race conditions

This commit is contained in:
Thulinma 2017-04-30 15:04:54 +02:00
parent 40b7cb7e63
commit 2cec1f7836
4 changed files with 64 additions and 19 deletions

View file

@ -179,6 +179,8 @@ namespace Mist{
char initialSync = 0;
//attempt to load sync status from session cache in shm
{
IPC::semaphore cacheLock(SEM_SESSCACHE, O_RDWR, ACCESSPERMS, 1);
if (cacheLock){cacheLock.wait();}
IPC::sharedPage shmSessions(SHM_SESSIONS, SHM_SESSIONS_SIZE, false, false);
if (shmSessions.mapped){
char shmEmpty[SHM_SESSIONS_ITEM];
@ -218,6 +220,7 @@ namespace Mist{
shmOffset += SHM_SESSIONS_ITEM;
}
}
if (cacheLock){cacheLock.post();}
}
unsigned int i = 0;
tmpEx.setSync(initialSync);