Retail products


Traffic interception SDK

Control every TCP/IP network connection

  • Route connections via proxy
  • Redirect connections and modify the data
  • Block connections and applications
SSL interception SDK

View SSL in plaintext and modify it

  • View the SSL stream decrypted in plaintext
  • Redirect SSL connection and modify decrypted data
  • Browser shows "SSL lock" without warnings

Documentation


CWin32ReadWriteLock Class Reference

#include <Win32ReadWriteLock.h>

Inheritance diagram for CWin32ReadWriteLock:
Collaboration diagram for CWin32ReadWriteLock:

List of all members.


Public Member Functions

virtual BOOL LockRead (unsigned long ulMSTimeout=INFINITE)
virtual void UnlockRead ()
virtual BOOL LockWrite ()
virtual void UnlockWrite ()
virtual BOOL Escalate (unsigned long ulMSTimeout, unsigned long ulIterations)
virtual void StopEscalation ()
 CWin32ReadWriteLock (int iMaximumReaders)
virtual ~CWin32ReadWriteLock ()

Protected Member Functions

int GetMaximumReaders () const

Detailed Description

Definition at line 50 of file Win32ReadWriteLock.h.


Constructor & Destructor Documentation

KOMODIA_NAMESPACE_START CWin32ReadWriteLock::CWin32ReadWriteLock ( int  iMaximumReaders  ) 

Definition at line 51 of file Win32ReadWriteLock.cpp.

00051                                                             : CGenericReadWriteLock(iMaximumReaders),
00052                                                                 m_pSemaphore(NULL),
00053                                                                 m_pMutex(NULL),
00054                                                                 m_bWriter(FALSE),
00055                                                                 m_bEscalation(FALSE),
00056                                                                 m_iReaders(0)
00057 {
00058     //Allocate the mutex and the semaphores
00059     m_pMutex=COSManager::CreateMutex();
00060     m_pSemaphore=COSManager::CreateSemaphore(iMaximumReaders,iMaximumReaders);
00061 }

CWin32ReadWriteLock::~CWin32ReadWriteLock (  )  [virtual]

Definition at line 63 of file Win32ReadWriteLock.cpp.

00064 {
00065     //Delete the mutexs and semaphores
00066     delete m_pMutex;
00067     delete m_pSemaphore;
00068 }


Member Function Documentation

BOOL CWin32ReadWriteLock::Escalate ( unsigned long  ulMSTimeout,
unsigned long  ulIterations 
) [virtual]

Implements CGenericReadWriteLock.

Definition at line 168 of file Win32ReadWriteLock.cpp.

00170 {
00171     //Try to lock for write
00172     if (LockWrite())
00173         return TRUE;
00174 
00175     //Try to escalate 
00176     CMutexAutoRelease aRelease(m_pMutex,TRUE);
00177 
00178     //Change the escalation status
00179     m_bEscalation=TRUE;
00180 
00181     //Exit from the mutex
00182     aRelease.Release();
00183 
00184     //And wait to see if we can continue
00185     for (unsigned long ulCounter=0;ulCounter<ulIterations;++ulCounter)
00186     {
00187         //Can we write
00188         if (LockWrite())
00189             return TRUE;
00190 
00191         //Wait
00192         Sleep(ulMSTimeout);
00193     }
00194 
00195     //Failed to escalate
00196     return FALSE;
00197 }

int CGenericReadWriteLock::GetMaximumReaders (  )  const [protected, inherited]

Definition at line 55 of file GenericReadWriteLock.cpp.

00056 {
00057     return m_iMaximumReaders;
00058 }

BOOL CWin32ReadWriteLock::LockRead ( unsigned long  ulMSTimeout = INFINITE  )  [virtual]

Implements CGenericReadWriteLock.

Definition at line 70 of file Win32ReadWriteLock.cpp.

00071 {
00072     //First lock the mutex and check the read flag
00073     CMutexAutoRelease aRelease(m_pMutex,TRUE);
00074 
00075     //Check the flag
00076     if (m_bEscalation || m_bWriter)
00077         //Can't lock
00078         return FALSE;
00079 
00080     //Check if we will be locked ?
00081     if (m_iReaders==GetMaximumReaders())
00082     {
00083         //Release the lock and try to get it
00084         aRelease.Release();
00085 
00086         //Lock the semaphore
00087         if (m_pSemaphore->Aquire(ulMSTimeout))
00088             return FALSE;
00089         else
00090         {
00091             //Relock it
00092             aRelease.Aquire();
00093 
00094             //Check if there are writers ?
00095             if (m_bEscalation || m_bWriter)
00096             {
00097                 //So soon ?
00098                 //Release what we got
00099                 m_pSemaphore->Release();
00100 
00101                 //Exit
00102                 return FALSE;
00103             }
00104             else
00105                 //Increase the count
00106                 ++m_iReaders;
00107         }
00108     }
00109     else if (m_pSemaphore->Aquire(ulMSTimeout))
00110         return FALSE;
00111     else
00112         //Increase the semaphore and our count
00113         ++m_iReaders;
00114 
00115     //Done
00116     return TRUE;
00117 }

BOOL CWin32ReadWriteLock::LockWrite (  )  [virtual]

Implements CGenericReadWriteLock.

Definition at line 135 of file Win32ReadWriteLock.cpp.

00136 {
00137     //First lock the mutex and check the read flag
00138     CMutexAutoRelease aRelease(m_pMutex,TRUE);
00139 
00140     //Check the flag
00141     if (m_iReaders || m_bWriter)
00142         //Can't lock
00143         return FALSE;
00144 
00145     //Indicate we are writing
00146     m_bWriter=TRUE;
00147 
00148     //Done
00149     return TRUE;
00150 }

void CWin32ReadWriteLock::StopEscalation (  )  [virtual]

Implements CGenericReadWriteLock.

Definition at line 199 of file Win32ReadWriteLock.cpp.

00200 {
00201     //First lock the mutex and check the read flag
00202     CMutexAutoRelease aRelease(m_pMutex,TRUE);
00203 
00204     //Remove escalation flag
00205     m_bEscalation=FALSE;
00206 }

void CWin32ReadWriteLock::UnlockRead (  )  [virtual]

Implements CGenericReadWriteLock.

Definition at line 119 of file Win32ReadWriteLock.cpp.

00120 {
00121     //First lock the mutex and check the read flag
00122     CMutexAutoRelease aRelease(m_pMutex,TRUE);
00123 
00124     //Do we have readers
00125     if (m_iReaders)
00126     {
00127         //Release the semaphore
00128         m_pSemaphore->Release();
00129 
00130         //Decrease the count
00131         --m_iReaders;
00132     }
00133 }

void CWin32ReadWriteLock::UnlockWrite (  )  [virtual]

Implements CGenericReadWriteLock.

Definition at line 152 of file Win32ReadWriteLock.cpp.

00153 {
00154     //First lock the mutex and check the read flag
00155     CMutexAutoRelease aRelease(m_pMutex,TRUE);
00156 
00157     //Do we have readers
00158     if (m_bWriter)
00159     {
00160         //Not writing
00161         m_bWriter=FALSE;
00162 
00163         //Remove escalation flag
00164         m_bEscalation=FALSE;
00165     }
00166 }


The documentation for this class was generated from the following files: