diff --git a/ChangeLog b/ChangeLog index ad3d58f9..5d08b8bd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-04-20 Tatsuhiro Tsujikawa + + Increased _epEvents size if necessary. + * src/EpollEventPoll.cc + * src/EpollEventPoll.h + 2010-04-20 Tatsuhiro Tsujikawa Removed EventRType template parameter diff --git a/src/EpollEventPoll.cc b/src/EpollEventPoll.cc index edec5b5a..c5a96c81 100644 --- a/src/EpollEventPoll.cc +++ b/src/EpollEventPoll.cc @@ -77,11 +77,12 @@ struct epoll_event EpollEventPoll::KSocketEntry::getEvents() return epEvent; } -EpollEventPoll::EpollEventPoll():_logger(LogFactory::getInstance()) +EpollEventPoll::EpollEventPoll(): + _epEventsSize(EPOLL_EVENTS_MAX), + _epEvents(new struct epoll_event[_epEventsSize]), + _logger(LogFactory::getInstance()) { _epfd = epoll_create(EPOLL_EVENTS_MAX); - - _epEvents = new struct epoll_event[EPOLL_EVENTS_MAX]; } EpollEventPoll::~EpollEventPoll() @@ -178,6 +179,11 @@ bool EpollEventPoll::addEvents(sock_t socket, } } else { _socketEntries.insert(i, socketEntry); + if(_socketEntries.size() > _epEventsSize) { + _epEventsSize *= 2; + delete [] _epEvents; + _epEvents = new struct epoll_event[_epEventsSize]; + } event.addSelf(socketEntry); diff --git a/src/EpollEventPoll.h b/src/EpollEventPoll.h index 78dc45bc..eb3a4c7e 100644 --- a/src/EpollEventPoll.h +++ b/src/EpollEventPoll.h @@ -78,6 +78,8 @@ private: int _epfd; + size_t _epEventsSize; + struct epoll_event* _epEvents; static const size_t EPOLL_EVENTS_MAX = 1024;