{
BOOL Found = FALSE;
PSIDREQRESULT ReqResult = NULL;
PSIDCACHEMGR scm;
scm = ReferenceSidCacheMgr(SidCacheMgr);
if (scm != NULL)
{
EnterCriticalSection(&scm->Lock);
/* search the cache */
Found = FindSidInCache(scm,
pSid,
&ReqResult);
if (!Found)
{
/* the sid is not in the cache, queue it if not already queued */if (!QueueSidLookup(scm,
pSid,
CompletionProc,
Context))
{
PSIDREQRESULT FoundReqResult = NULL;
/* unable to queue it, look it up now */LeaveCriticalSection(&scm->Lock);
/* lookup everything we need */if (!LookupSidInformation(scm,
pSid,
&ReqResult))
{
ReqResult = NULL;
}
EnterCriticalSection(&scm->Lock);
/* see if the SID was added to the cache in the meanwhile */if (!FindSidInCache(scm,
pSid,
&FoundReqResult))
{
if (ReqResult != NULL)
{
/* cache the results */CacheLookupResults(scm,
pSid,
ReqResult);
}
}
else
{
if (ReqResult != NULL)
{
/* free the information of our lookup and use the cached information*/DereferenceSidReqResult(scm,
ReqResult);
}
ReqResult = FoundReqResult;
}
Found = (ReqResult != NULL);
}
}
LeaveCriticalSection(&scm->Lock);
/* call the completion callback */if (Found)
{
CompletionProc(SidCacheMgr,
pSid,
ReqResult,
Context);
if (ReqResult != NULL)
{
HeapFree(scm->Heap,
0,
ReqResult);
}
}
DereferenceSidCacheMgr(scm);
}
return Found;
}
Generated on Sat May 26 2012 05:04:42 for ReactOS by
1.7.6.1
ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.