Mixe for Privacy and Anonymity in the Internet
Public Member Functions | Private Attributes
CASocketGroupEpoll Class Reference

#include <CASocketGroupEpoll.hpp>

Collaboration diagram for CASocketGroupEpoll:
[legend]

List of all members.

Public Member Functions

 CASocketGroupEpoll (bool bWrite)
 ~CASocketGroupEpoll ()
SINT32 setPoolForWrite (bool bWrite)
SINT32 add (CASocket &s, void *datapointer)
 Adds the socket s to the socket group.
SINT32 add (CAMuxSocket &s, void *datapointer)
 Adds the socket s to the socket group.
SINT32 remove (CASocket &s)
SINT32 remove (CAMuxSocket &s)
SINT32 select ()
SINT32 select (UINT32 time_ms)
 Waits for events on the sockets.
bool isSignaled (void *datapointer)
void * getFirstSignaledSocketData ()
void * getNextSignaledSocketData ()

Private Attributes

SINT32 m_hEPFD
struct epoll_event * m_pEvents
struct epoll_event * m_pEpollEvent
SINT32 m_iNumOfReadyFD
SINT32 m_iAktSignaledSocket
CAMutex m_csFD_SET

Detailed Description

Definition at line 38 of file CASocketGroupEpoll.hpp.


Constructor & Destructor Documentation

Definition at line 31 of file CASocketGroupEpoll.cpp.

References m_hEPFD, m_pEpollEvent, m_pEvents, MAX_POLLFD, and setPoolForWrite().

  {
    m_hEPFD=epoll_create(MAX_POLLFD);
    m_pEpollEvent=new struct epoll_event;
    memset(m_pEpollEvent,0,sizeof(struct epoll_event));
    m_pEvents=new struct epoll_event[MAX_POLLFD];
    setPoolForWrite(bWrite);
  }

Here is the call graph for this function:

Definition at line 40 of file CASocketGroupEpoll.cpp.

References m_hEPFD, m_pEpollEvent, and m_pEvents.

  {
    close(m_hEPFD);
    delete[] m_pEvents;
    m_pEvents = NULL;
    delete m_pEpollEvent;
    m_pEpollEvent = NULL;
  }

Member Function Documentation

SINT32 CASocketGroupEpoll::add ( CASocket s,
void *  datapointer 
) [inline]

Adds the socket s to the socket group.

Additional one can set a parameter datapointer, which is assoziated with the socke s

Definition at line 47 of file CASocketGroupEpoll.hpp.

References E_SUCCESS, CASocket::getSocket(), CAMutex::lock(), m_csFD_SET, m_hEPFD, m_pEpollEvent, SOCKET, and CAMutex::unlock().

Referenced by CAFirstMix::doUserLogin_internal(), CAFirstMixB::loop(), and CAFirstMixA::loop().

        {
          SINT32 ret=E_SUCCESS;
          m_csFD_SET.lock();
          SOCKET socket=s.getSocket();
          m_pEpollEvent->data.ptr=datapointer;
          
          //if(epoll_ctl(m_hEPFD,EPOLL_CTL_ADD,socket,m_pEpollEvent)!=0)
          //  ret=E_UNKNOWN;
          ret=epoll_ctl(m_hEPFD,EPOLL_CTL_ADD,socket,m_pEpollEvent);
          m_csFD_SET.unlock();
          return ret;
        }

Here is the call graph for this function:

SINT32 CASocketGroupEpoll::add ( CAMuxSocket s,
void *  datapointer 
) [inline]

Adds the socket s to the socket group.

Additional one can set a parameter datapointer, which is assoziated with the socke s

Definition at line 63 of file CASocketGroupEpoll.hpp.

References E_SUCCESS, CAMuxSocket::getSocket(), CAMutex::lock(), m_csFD_SET, m_hEPFD, m_pEpollEvent, SOCKET, and CAMutex::unlock().

        {
          SINT32 ret=E_SUCCESS;
          m_csFD_SET.lock();
          SOCKET socket=s.getSocket();
          m_pEpollEvent->data.ptr=datapointer;
          //if(epoll_ctl(m_hEPFD,EPOLL_CTL_ADD,socket,m_pEpollEvent)!=0)
          //  ret=E_UNKNOWN;
          ret=epoll_ctl(m_hEPFD,EPOLL_CTL_ADD,socket,m_pEpollEvent);
          m_csFD_SET.unlock();
          return ret;
        }

Here is the call graph for this function:

Definition at line 183 of file CASocketGroupEpoll.hpp.

References m_iAktSignaledSocket, m_iNumOfReadyFD, and m_pEvents.

Referenced by CAFirstMixB::loop(), CAFirstMixA::loop(), and CAFirstMixA::sendToUsers().

        {
          m_iAktSignaledSocket=0;
          if(m_iNumOfReadyFD>0)
            return m_pEvents[0].data.ptr;
          return NULL;
        }
bool CASocketGroupEpoll::isSignaled ( void *  datapointer) [inline]
Remarks:
temporarlly removed - can be enabled agian than requested...

Definition at line 173 of file CASocketGroupEpoll.hpp.

References m_iNumOfReadyFD, and m_pEvents.

Referenced by CAChain::isSignaledInSocketGroup(), CAFirstMixB::loop(), CAFirstMixA::loop(), and CAFirstMixA::sendToUsers().

        {
          for(SINT32 i=0;i<m_iNumOfReadyFD;i++)
            {
              if(datapointer==m_pEvents->data.ptr)
                return true;
            }
          return false;
        }

Definition at line 76 of file CASocketGroupEpoll.hpp.

References ASSERT, E_SUCCESS, E_UNKNOWN, CAMutex::lock(), m_csFD_SET, m_hEPFD, m_pEpollEvent, and CAMutex::unlock().

Referenced by CAFirstMixA::closeConnection(), CAFirstMixB::loop(), and CAChain::removeFromAllSocketGroupsInternal().

        {
          SINT32 ret=E_SUCCESS;
          m_csFD_SET.lock();
          if(epoll_ctl(m_hEPFD,EPOLL_CTL_DEL,s.getSocket(),m_pEpollEvent)!=0)
            ret=E_UNKNOWN;
          ASSERT(ret==E_SUCCESS,"Error in Epoll socket group remove")
          m_csFD_SET.unlock();
          return ret;
        }

Here is the call graph for this function:

Definition at line 87 of file CASocketGroupEpoll.hpp.

References ASSERT, E_SUCCESS, E_UNKNOWN, CAMutex::lock(), m_csFD_SET, m_hEPFD, m_pEpollEvent, and CAMutex::unlock().

        {
          SINT32 ret=E_SUCCESS;
          m_csFD_SET.lock();
          if(epoll_ctl(m_hEPFD,EPOLL_CTL_DEL,s.getSocket(),m_pEpollEvent)!=0)
            ret=E_UNKNOWN;
          ASSERT(ret==E_SUCCESS,"Error in Epoll socket group remove")
          m_csFD_SET.unlock();
          return ret;
        }

Here is the call graph for this function:

Definition at line 98 of file CASocketGroupEpoll.hpp.

References E_UNKNOWN, CAMutex::lock(), m_csFD_SET, m_hEPFD, m_iNumOfReadyFD, m_pEvents, MAX_POLLFD, and CAMutex::unlock().

Referenced by CAFirstMixB::loop(), CAFirstMixA::loop(), and CAFirstMixA::sendToUsers().

Here is the call graph for this function:

SINT32 CASocketGroupEpoll::select ( UINT32  time_ms) [inline]

Waits for events on the sockets.

If after ms milliseconds no event occurs, E_TIMEDOUT is returned

Parameters:
time_ms- maximum milliseconds to wait
Return values:
E_TIMEDOUT,ifother ms milliseconds no event occurs
E_UNKNOWN,ifan error occured
Returns:
number of read/writeable sockets

Definition at line 118 of file CASocketGroupEpoll.hpp.

References E_TIMEDOUT, E_UNKNOWN, CAMutex::lock(), m_csFD_SET, m_hEPFD, m_iNumOfReadyFD, m_pEvents, MAX_POLLFD, and CAMutex::unlock().

Here is the call graph for this function:

Definition at line 49 of file CASocketGroupEpoll.cpp.

References E_SUCCESS, and m_pEpollEvent.

Referenced by CASocketGroupEpoll().

  {
    if(bWrite)
      m_pEpollEvent->events=EPOLLOUT|EPOLLERR|EPOLLHUP;
    else
      m_pEpollEvent->events=EPOLLIN|EPOLLERR|EPOLLHUP;
    return E_SUCCESS;
  }

Member Data Documentation

Definition at line 205 of file CASocketGroupEpoll.hpp.

Referenced by add(), remove(), and select().

Definition at line 200 of file CASocketGroupEpoll.hpp.

Referenced by add(), CASocketGroupEpoll(), remove(), select(), and ~CASocketGroupEpoll().

struct epoll_event* CASocketGroupEpoll::m_pEpollEvent [private]
struct epoll_event* CASocketGroupEpoll::m_pEvents [private]

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