• Show log

    Commit

  • Hash : cf249e7d
    Author : Mike Smellie
    Date : 2010-07-19T13:44:56

    Possible fix to 100% cpu usage with epoll and openssl
    
    I'm running a fairly simple bit of test code using libevent2 with epoll and
    openssl bufferevents and I've run into a 100% cpu usage problem.
    
    Looking into it 100% usage was caused by epoll_wait constantly
    returning write events on the openssl socket when it shouldn't really have
    been looking for write events at all (N_ACTIVE_CALLBACKS() was returning 0
    also).
    
    Looking a bit deeper eventbuffer_openssl socket seems to be requesting
    that the EV_WRITE event be removed when it should, but the event isn't
    actually being removed from epoll.
    
    Continuing to follow this I think I've found a bug in
    event_changelist_del.
    
    For evpoll event_del calls event_changelist_del which caches the change
    which is then actioned later when evpoll_dispatch is called.
    
    In event_changlist_del there is a check so that if the currently changed
    action is an add then the cached action is changed to a no-op rather than a
    delete (which makes sense). The problem arises if there are more than
    two add or delete operations between calls to dispatch, in this case it's
    possible that the delete is turned into a no-op when it shouldn't have
    been.
    
    For example starting with the event on, a delete followed by an add and
    then another delete results in a no-op when it should have been a delete (I
    added a fair bit of debug output that seems to confirm this behaviour).
    
    I've applied a small change that checks the original old_event stored with
    the change and only converts the delete to a no-op if the event isn't on in
    old_event. This seems to have fixed my problem.
    

  • README

  • 0. BUILDING AND INSTALLATION (Briefly)
    
    $ ./configure
    $ make
    $ make verify   # (optional)
    $ sudo make install
    
    1. BUILDING AND INSTALLATION (In Depth)
    
    To build libevent, type
    
    $ ./configure && make
    
         (If you got libevent from the git repository, you will
          first need to run the included "autogen.sh" script in order to
          generate the configure script.)
    
    Install as root via
    
    # make install
    
    You can run the regression tests by running
    
    $ make verify
    
    Before, reporting any problems, please run the regression tests.
    
    To enable the low-level tracing build the library as:
    
       CFLAGS=-DUSE_DEBUG ./configure [...]
    
    Standard configure flags should work.  In particular, see:
    
       --disable-shared          Only build static libraries
       --prefix                  Install all files relative to this directory.
    
    
    The configure script also supports the following flags:
    
       --enable-gcc-warnings     Enable extra compiler checking with GCC.
       --disable-malloc-replacement
                                 Don't let applications replace our memory
                                 management functions
       --disable-openssl         Disable support for OpenSSL encryption.
       --disable-thread-support  Don't support multithreaded environments.
    
    2. USEFUL LINKS:
    
    For the latest released version of Libevent, see the official website at
    http://monkey.org/~provos/libevent/ .
    
    There's a pretty good work-in-progress manual up at
       http://www.wangafu.net/~nickm/libevent-book/ .
    
    For the latest development versions of Libevent, access our Git repository
    via
       "git clone git://levent.git.sourceforge.net/gitroot/levent/libevent"
    
    You can browse the git repository online at
    http://levent.git.sourceforge.net/git/gitweb-index.cgi .
    
    To report bugs, request features, or submit patches to Libevent,
    use the Sourceforge trackers at
    https://sourceforge.net/tracker/?group_id=50884 .
    
    There's also a libevent-users mailing list for talking about Libevent
    use and development: http://archives.seul.org/libevent/users/
    
    3. ACKNOWLEDGMENTS
    
    The following people have helped with suggestions, ideas, code or
    fixing bugs:
    
      Alejo
      Weston Andros Adamson
      William Ahern
      Stas Bekman
      Ka-Hing Cheung
      Andrew Danforth
      Christopher Davis
      Mike Davis
      Shie Erlich
      Alexander von Gernler
      Artur Grabowski
      Aaron Hopkins
      Tani Hosokawa
      Claudio Jeker
      Valery Kyholodov
      Marko Kreen
      Scott Lamb
      Adam Langley
      Christopher Layne
      Philip Lewis
      David Libenzi
      Moshe Litvin
      Hagne Mahre
      Lubomir Marinov
      Nick Mathewson
      James Mansion
      Andrey Matveev
      Caitlin Mercer
      Trond Norbye
      Richard Nyberg
      Jon Oberheide
      Phil Oleson
      Dave Pacheco
      Tassilo von Parseval
      Pierre Phaneuf
      Ryan Phillips
      Jon Poland
      Bert JW Regeer
      Hanna Schroeter
      Kevin Springborn
      Ferenc Szalai
      Dug Song
      Zack Weinberg
      Taral
      propanbutan
      mmadia
    
    If we have forgotten your name, please contact us.