Skip to content

Commit

Permalink
Reduce the size of the RunEpollOnce stack frame by 800kb. This fixes …
Browse files Browse the repository at this point in the history
…the long-standing epoll+threads issue (eventmachine#84)
  • Loading branch information
tmm1 committed Apr 29, 2009
1 parent 6626063 commit 1f6a4c9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
11 changes: 5 additions & 6 deletions ext/em.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -440,26 +440,25 @@ bool EventMachine_t::_RunEpollOnce()
{
#ifdef HAVE_EPOLL
assert (epfd != -1);
struct epoll_event ev [MaxEpollDescriptors];
int s;

#ifdef BUILD_FOR_RUBY
TRAP_BEG;
#endif
s = epoll_wait (epfd, ev, MaxEpollDescriptors, 50);
s = epoll_wait (epfd, epoll_events, MaxEpollDescriptors, 50);
#ifdef BUILD_FOR_RUBY
TRAP_END;
#endif

if (s > 0) {
for (int i=0; i < s; i++) {
EventableDescriptor *ed = (EventableDescriptor*) ev[i].data.ptr;
EventableDescriptor *ed = (EventableDescriptor*) epoll_events[i].data.ptr;

if (ev[i].events & (EPOLLERR | EPOLLHUP))
if (epoll_events[i].events & (EPOLLERR | EPOLLHUP))
ed->ScheduleClose (false);
if (ev[i].events & EPOLLIN)
if (epoll_events[i].events & EPOLLIN)
ed->Read();
if (ev[i].events & EPOLLOUT) {
if (epoll_events[i].events & EPOLLOUT) {
ed->Write();
epoll_ctl (epfd, EPOLL_CTL_MOD, ed->GetSocket(), ed->GetEpollEvent());
// Ignoring return value
Expand Down
3 changes: 3 additions & 0 deletions ext/em.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,9 @@ class EventMachine_t
private:
bool bEpoll;
int epfd; // Epoll file-descriptor
#ifdef HAVE_EPOLL
struct epoll_event epoll_events [MaxEpollDescriptors];
#endif

bool bKqueue;
int kqfd; // Kqueue file-descriptor
Expand Down

0 comments on commit 1f6a4c9

Please sign in to comment.