Functions

Beesnest/DcLoginManager.cpp File Reference

#include "DcLoginManager.h"

Go to the source code of this file.

Functions

int DcClean (void *pParam)

Function Documentation

int DcClean ( void *  pParam )

The problem with the cleaning system is that the function CheckResponse can be called many times from many different threads, as if using DAA, this is the function that check access before sending any protected page. In addition the running time of this function is some what long as this is the function that do the response digest calculation on the server side.
If the cleaning thread will delete a taken challenge, the system will crush. On the other hand, I don't want to lock the Mutex for the entire running time of this function, because then it will mutilate other CheckResponse functions that needs to run in other threads. There is no reason way these functions cannot run in the same time.
To solve this problem I use "Taken Challenges" global counter. When CheckResponse is called it increases this counter by one, and waits on the Mutex. After getting the Mutex it releases it immediately and start working. When it is done, it decreases the counter by one. Every time a challenge needs to be deleted, a semaphore is signaled (just before CheckResponse returns).
The cleaning thread waits on this semaphore. After getting a signal, it sleeps for few seconds (from other reasons - the invalid challenge can still be used by the browser, if it is a multi-frame page). After the delay the thread calls the cleaning function. The cleaning function checks first if the counter value is zero, if not it exits immediately. If the counter is zero, it iterates through the challenges list and clean every challenge that is marked for deletion, and old unused challenges. in the beginning of every iteration cycle, it checks the counter again, if it is not zero, it exits immediately, so CheckResponse can start working. The uncleared challenges will have to wait for the next signal on the semaphore.

Parameters:
pParamPointer to bool (isCleanThreadGo) that tell the function to exit (close the thread).
Returns:
(int) The return code from the thread.

Definition at line 533 of file DcLoginManager.cpp.