Permalink
Commits on Feb 28, 2018
  1. Fix base unlocking in event_del() if event_base_set() runned in anoth…

    azat committed Feb 27, 2018
    …er thread
    
    Image next situation:
      T1:                                        T2:
       event_del_()
         lock the event.ev_base.th_base_lock
         event_del_nolock_()                     event_set_base()
         unlock the event.ev_base.th_base_lock
    
    In this case we will unlock the wrong base after event_del_nolock_()
    returns, and deadlock is likely to happens, since event_base_set() do
    not check any mutexes (due to it is possible to do this only if event is
    not inserted anywhere).
    
    So event_del_() has to cache the base before removing the event, and
    cached base.th_base_lock after.
Commits on Feb 27, 2018
Commits on Feb 24, 2018
  1. Provide Makefile variables LIBEVENT_{CFLAGS,CPPFLAGS,LDFLAGS}

    stenn authored and azat committed May 14, 2017
    This will allow a parent package to specify compiler, CPP, and linker
    flags to a libevent built as a sub-package. Document this in
    whatsnew-2.2.txt.
    
    Picked-from: #506
    Closes: #506
Commits on Feb 20, 2018
  1. http: remove message in case !Content-Length and Connection!=close

    azat committed Feb 13, 2018
    Since [1] GET can have body, and hence for every incomming connection it
    will print this error.
    
    [1] db483e3 ("Allow bodies for
    GET/DELETE/OPTIONS/CONNECT")
    
    Noticed-by: BotoX (irc)
    Refs: #408
Commits on Feb 12, 2018
  1. buffer: fix incorrect unlock of the buffer mutex (for deferred callba…

    azat committed Feb 12, 2018
    …cks)
    
    TSAN reports:
      WARNING: ThreadSanitizer: unlock of an unlocked mutex (or by a wrong thread) (pid=17111)
          #0 pthread_mutex_unlock /build/gcc/src/gcc/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:3621 (libtsan.so.0+0x00000003b71c)
          #1 evbuffer_add <null> (libevent_core-2.2.so.1+0x00000000ddb6)
          ...
    
        Mutex M392 (0x7b0c00000f00) created at:
          #0 pthread_mutex_init /build/gcc/src/gcc/libsanitizer/tsan/tsan_interceptors.cc:1117 (libtsan.so.0+0x0000000291af)
          #1 <null> <null> (libevent_pthreads-2.2.so.1+0x000000000d46)
          ...
    
    $ addr2line -e /lib/libevent_core-2.2.so.1 0x00000000ddb6
    /src/libevent/buffer.c:1815 (discriminator 1)
    
    Introduced-in: ae2b84b ("Replace
    deferred_cbs with event_callback-based implementation.")
Commits on Jan 15, 2018
  1. Fix typos in comments

    delimitry committed Jan 15, 2018
Commits on Jan 9, 2018
  1. http: fix leaks in evhttp_uriencode()

    azat committed Jan 9, 2018
    Fixes: #584
Commits on Jan 4, 2018
  1. Merge branch 'listener-immediate-close'

    azat committed Jan 4, 2018
    * listener-immediate-close:
      test/listener: cover immediate-close logic
      Immediately stop trying to accept more connections if listener disabled
  2. Immediately stop trying to accept more connections if listener disabled

    vii authored and azat committed Dec 18, 2017
    This is a refined version of the logic previously in #578
    
    The rationale is that the consumer of sockets may wish to temporarily
    delay accepting for some reason (e.g. being out of file-descriptors).
    The kernel will then queue them up. The kernel queue is bounded and
    programs like NodeJS will actually try to quickly accept and then close
    (as the current behaviour before this PR).
    
    However, it seems that libevent should allow the user to choose whether
    to accept and respond correctly if the listener is disabled.
Commits on Dec 18, 2017
  1. Fixed last_with_datap description

    wodny committed Dec 18, 2017
    Grammar and typo fix
  2. http: add callback to allow server to decline (and thereby close) inc…

    vii authored and azat committed Dec 1, 2017
    …oming connections.
    
    This is important, as otherwise clients can easily exhaust the file
    descriptors available on a libevent HTTP server, which can cause
    problems in other code which does not handle EMFILE well: for example,
    see bitcoin/bitcoin#11368
    
    Closes: #578 (patch cherry picked)
Commits on Dec 16, 2017
Commits on Dec 10, 2017
  1. CONNECT method only takes an authority

    ghazel authored and azat committed Dec 2, 2017
  2. If precise_time is false, we should not set EVENT_BASE_FLAG_PRECISE_T…

    yongqing.jiao authored and azat committed Dec 9, 2017
    …IMER
    
    Fixes: 630f077 ("Simple unit tests for
    monotonic timers")
  3. Merge branch 'evconnlistener-do-not-close-client-fd'

    azat committed Dec 10, 2017
    Fixes: #577
    
    * evconnlistener-do-not-close-client-fd:
      listener: cover closing of fd in case evconnlistener_free() called from acceptcb
      Revert "Fix potential fd leak in listener_read_cb()"
  4. Revert "Fix potential fd leak in listener_read_cb()"

    azat committed Dec 5, 2017
    This reverts commit a695a72.
    
    @kgraefe:
      "I believe that this commit is just wrong: if lev->cnt is not 1 after
      the callback, new_fd will still never be closed in listener_read_cb().
      So in that case it is the responsibility of the user's code to close
      the file descriptor (which is fine). But why shouldn't it be in the
      other case? And how does the user's code know?"
    
    And I agree
Commits on Nov 29, 2017
  1. Fix generation of LibeventConfig.cmake for the installation tree

    okodron committed Nov 29, 2017
    'LIBEVENT_INCLUDE_DIRS' is properly initialized in 'LibeventConfig.cmake' as
    'LibeventConfig.cmake.in' contains usage of 'LIBEVENT_CMAKE_DIR' and
    'EVENT_INSTALL_INCLUDE_DIR' variables but not 'EVENT_CMAKE_DIR' and
    'EVENT__INCLUDE_DIRS'.
    Related typos are fixed.
Commits on Nov 22, 2017
  1. Add missing includes into openssl-compat.h

    azat committed Nov 22, 2017
    Before it depends from the caller #include appropriate headers (at least
    for OPENSSL_VERSION_NUMBER), but let's make it independent.
    
    Fixes: #574
Commits on Nov 19, 2017
Commits on Nov 5, 2017
  1. Fix incorrect ref to evhttp_get_decoded_uri in http.h

    ejurgensen committed Nov 5, 2017
    Replaces reference in the http.h include header file to evhttp_get_decoded_uri
    with evhttp_uridecode. There is no function called evhttp_get_decoded_uri.
Commits on Nov 4, 2017
  1. Fix crashing http server when callback do not reply in place from *ge…

    azat committed Nov 4, 2017
    …ncb*
    
    This is the second hunk of the first patch
    5ff8eb2 ("Fix crashing http server when
    callback do not reply in place")
    
    Fixes: #567
Commits on Oct 30, 2017
  1. Allow bodies for GET/DELETE/OPTIONS/CONNECT

    azat committed Oct 29, 2017
    I checked with nginx, and via it's lua bindings it allows body for all
    this methods. Also everybody knows that some of web-servers allows body
    for GET even though this is not RFC conformant.
    
    Refs: #408
  2. Do not crash when evhttp_send_reply_start() is called after a timeout.

    Andreas Gustafsson authored and azat committed Sep 26, 2017
    This fixes the crash reported in issue #509.  The "would be nice"
    items discussed in #509 can be addressed separately.
Commits on Oct 29, 2017
  1. Fix crashing http server when callback do not reply in place

    azat committed Oct 22, 2017
    General http callback looks like:
      static void http_cb(struct evhttp_request *req, void *arg)
      {
        evhttp_send_reply(req, HTTP_OK, "Everything is fine", NULL);
      }
    
    And they will work fine becuase in this case http will write request
    first, and during write preparation it will disable *read callback* (in
    evhttp_write_buffer()), but if we don't reply immediately, for example:
      static void http_cb(struct evhttp_request *req, void *arg)
      {
        return;
      }
    
    This will leave connection in incorrect state, and if another request
    will be written to the same connection libevent will abort with:
      [err] ../http.c: illegal connection state 7
    
    Because it thinks that read for now is not possible, since there were no
    write.
    
    Fix this by disabling EV_READ entirely. We couldn't just reset callbacks
    because this will leave EOF detection, which we don't need, since user
    hasn't replied to callback yet.
    
    Reported-by: Cory Fields <cory@coryfields.com>
Commits on Oct 21, 2017
  1. fix handling of close_notify (ssl) in http with openssl bufferevents

    azat committed Sep 13, 2017
    Since it can arrive after we disabled events in that bufferevent and
    reseted fd, hence evhttp_error_cb() could be called after
    SSL_RECEIVED_SHUTDOWN.
    
    Closes: #557
Commits on Sep 25, 2017
  1. Port `event_rpcgen.py` and `test/check-dumpevents.py` to Python 3.

    Aerdan authored and azat committed Sep 14, 2017
    These scripts remain compatible with Python 2.
Commits on Sep 24, 2017
  1. Remove OpenSSL paragram from README

    azat committed Sep 24, 2017
    Because it is mauvais ton to use binaries instead of normal packages
    (like apt-get in debian, pacman in arch, and others).
    
    Plus that link was borken and according to [1] OpenSSL do not ship
    binaries officially.
    
    And personally I don't think that this is not obvious that you need
    openssl libraries to build libevent with it's support, and BTW you need
    headers too (of course).
    
    [1]: https://www.openssl.org/community/binaries.html
    Fixes: #562
Commits on Sep 11, 2017
  1. test: fix warning

    vjardin6WIND committed Sep 11, 2017
    In function ‘send_a_byte_cb’:
    test/regress.c:1853:2: warning: ignoring return value of ‘write’, declared with
    attribute warn_unused_result [-Wunused-result]
      (void) write(*sockp, "A", 1);
Commits on Sep 10, 2017
  1. configure: avoid false positive in DragonFlyBSD

    carenas authored and azat committed Aug 19, 2017
    by default, the max buffer size is 16K and histeresis is at 50%, so
    a bigger read is needed to unlock writes than you would expect from
    other BSD (512 bytes)
    
    this doesn't introduce any regression on FreeBSD 11.1, OpenBSD 6.1, NetBSD 7.1,
    macOS 10.12.6 and of course DragonFlyBSD 4.8.1, and most of them show
    a max pipe size of 64K, so the read call should drain them all regardless
    of how conservative they are on the free pipe space they will require
    (usually 512 bytes) before kevent reports the fd as ready for write.
    
    I couldn't find a reference to which bug this code was trying to look for
    and it seems to be there from the beginning of git history so it might be
    no longer relevant.
    
    Issue: #548
  2. test: avoid regress hanging in macOS

    carenas authored and azat committed Aug 16, 2017
    a backtrace of the process without this patch :
      * thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
        * frame #0: 0x00007fffb1fb7d96 libsystem_kernel.dylib`kevent + 10
          frame #1: 0x0000000108ed0a58 libevent-2.2.1.dylib`kq_dispatch + 696
          frame #2: 0x0000000108ec53d8 libevent-2.2.1.dylib`event_base_loop + 696
          frame #3: 0x0000000108e1763b regress`test_fork + 1931
          frame #4: 0x0000000108e5c7ad regress`run_legacy_test_fn + 45
          frame #5: 0x0000000108e690aa regress`testcase_run_one + 858
          frame #6: 0x0000000108e6954f regress`tinytest_main + 495
          frame #7: 0x0000000108e5c94b regress`main + 171
          frame #8: 0x00007fffb1e88235 libdyld.dylib`start + 1
          frame #9: 0x00007fffb1e88235 libdyld.dylib`start + 1
    
    Issue: #546
  3. autotools: confirm openssl is working before using

    carenas authored and azat committed Aug 29, 2017
    latest versions of macOS provide pkg-config and libraries for an ancient
    version of openssl as part of the system, but no headers
Commits on Sep 1, 2017