|
|
|
@ -73,7 +73,8 @@ TR_commManagerEpollAddEndpoint(void * _this, TR_CommEndPoint endpoint) |
|
|
|
int handle = endpoint->transport->handle; |
|
|
|
struct epoll_event event; |
|
|
|
|
|
|
|
this->events[handle] = EPOLLET; |
|
|
|
//this->events[handle] = EPOLLET; |
|
|
|
this->events[handle] = 0; |
|
|
|
event.data.ptr = endpoint; |
|
|
|
event.events = this->events[handle]; |
|
|
|
|
|
|
|
@ -100,8 +101,9 @@ TR_commManagerEpollSelect(void * _this, TR_Event event, int timeout) |
|
|
|
&& ((TR_TcpSocket)endpoint->transport)->listen) { |
|
|
|
TR_hashAdd(cmgr->accept, endpoint); |
|
|
|
} else { |
|
|
|
TR_hashAdd(cmgr->read, endpoint); |
|
|
|
|
|
|
|
if (! event->subject->fin) { |
|
|
|
TR_hashAdd(cmgr->read, endpoint); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
this->events[handle] &= ~EPOLLIN; |
|
|
|
@ -111,15 +113,43 @@ TR_commManagerEpollSelect(void * _this, TR_Event event, int timeout) |
|
|
|
} |
|
|
|
|
|
|
|
if ((events[i].events & EPOLLOUT) == EPOLLOUT) { |
|
|
|
if (! event->subject->fin) { |
|
|
|
TR_hashAdd(cmgr->write, endpoint); |
|
|
|
this->events[handle] &= ~EPOLLOUT; |
|
|
|
_event.data.ptr = endpoint; |
|
|
|
_event.events = this->events[handle]; |
|
|
|
epoll_ctl(this->handle, EPOLL_CTL_MOD, handle, &_event); |
|
|
|
} |
|
|
|
this->events[handle] &= ~EPOLLOUT; |
|
|
|
_event.data.ptr = endpoint; |
|
|
|
_event.events = this->events[handle]; |
|
|
|
epoll_ctl(this->handle, EPOLL_CTL_MOD, handle, &_event); |
|
|
|
} |
|
|
|
|
|
|
|
if ((events[i].events & EPOLLHUP) == EPOLLHUP) { |
|
|
|
TR_eventHandlerIssueEvent( |
|
|
|
(TR_EventHandler)_this, |
|
|
|
TR_eventSubjectEmit( |
|
|
|
(TR_EventSubject)endpoint, |
|
|
|
TR_CEP_EVENT_SHUT_WRITE, |
|
|
|
NULL)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
static |
|
|
|
inline |
|
|
|
void |
|
|
|
TR_commManagerEpollDisable(void * _this, uint32_t mask, TR_Event event) |
|
|
|
{ |
|
|
|
TR_CommManagerEpoll this = _this; |
|
|
|
TR_CommEndPoint endpoint = (TR_CommEndPoint)event->subject; |
|
|
|
int handle = endpoint->transport->handle; |
|
|
|
struct epoll_event _event; |
|
|
|
|
|
|
|
this->events[handle] &= ~mask; |
|
|
|
_event.data.ptr = endpoint; |
|
|
|
_event.events = this->events[handle]; |
|
|
|
|
|
|
|
epoll_ctl(this->handle, EPOLL_CTL_MOD, handle, &_event); |
|
|
|
} |
|
|
|
|
|
|
|
static |
|
|
|
inline |
|
|
|
void |
|
|
|
@ -155,6 +185,20 @@ TR_commManagerEpollEnableRead(void * _this, TR_Event event) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
static |
|
|
|
void |
|
|
|
TR_commManagerEpollDisableWrite(void * _this, TR_Event event) |
|
|
|
{ |
|
|
|
TR_commManagerEpollDisable(_this, EPOLLOUT, event); |
|
|
|
} |
|
|
|
|
|
|
|
static |
|
|
|
void |
|
|
|
TR_commManagerEpollDisableRead(void * _this, TR_Event event) |
|
|
|
{ |
|
|
|
TR_commManagerEpollDisable(_this, EPOLLIN, event); |
|
|
|
} |
|
|
|
|
|
|
|
static |
|
|
|
void |
|
|
|
TR_commManagerEpollClose(void * _this, TR_Event event) |
|
|
|
@ -178,6 +222,8 @@ TR_INIT_IFACE( |
|
|
|
TR_commManagerEpollSelect, // TR_DISPATCHER_EVENT_DATA_WAIT |
|
|
|
TR_commManagerEpollEnableWrite, // TR_CEP_EVENT_PENDING_DATA => WRITE_BLOCK |
|
|
|
TR_commManagerEpollEnableRead, // TR_CEP_EVENT_READ_BLOCK |
|
|
|
TR_commManagerEpollDisableWrite, |
|
|
|
TR_commManagerEpollDisableRead, |
|
|
|
TR_commManagerEpollClose); // TR_CEP_EVENT_CLOSE |
|
|
|
TR_CREATE_CLASS( |
|
|
|
TR_CommManagerEpoll, |
|
|
|
|