]> granicus.if.org Git - libevent/log
libevent
5 years agotravis-ci: drop travis_wait (does not work with sub processes)
Azat Khuzhin [Mon, 13 Jan 2020 19:24:54 +0000 (22:24 +0300)]
travis-ci: drop travis_wait (does not work with sub processes)

Refs: https://github.com/travis-ci/travis-ci/issues/8526

5 years agocmake: do not print used method (EVENT_SHOW_METHOD) while running tests
Azat Khuzhin [Mon, 13 Jan 2020 19:24:54 +0000 (22:24 +0300)]
cmake: do not print used method (EVENT_SHOW_METHOD) while running tests

autotools don't, plus this will make CI logs cleaner

5 years agocmake: run regress test quietly like autotools (makes CI logs cleaner)
Azat Khuzhin [Mon, 13 Jan 2020 19:24:54 +0000 (22:24 +0300)]
cmake: run regress test quietly like autotools (makes CI logs cleaner)

5 years agoAdd callback support for error pages
nntrab [Tue, 9 Feb 2016 18:01:00 +0000 (18:01 +0000)]
Add callback support for error pages

The existing error pages are very basic and don't allow for
multi-lingual support or for conformity with other pages in a web site.
The aim of the callback functionality is to allow custom error pages to
be supported for calls to evhttp_send_error() by both calling
applications and Libevent itself.

A backward-incompatible change has been made to the title of error pages
sent by evhttp_send_error(). The original version of the function used
the reason argument as part of the title. That might have unforeseen
side-effects if it contains HTML tags. Therefore the title has been
changed to always use the standard status text.

An example of the error callback can be found in this
[version](https://github.com/libevent/libevent/files/123607/http-server.zip)
of the 'http-server' sample. It will output error pages with very bright
backgrounds, the error code using a very large font size and the reason.

Closes: #323 (cherr-picked from PR)
5 years agoMerge branch 'http-connect'
Azat Khuzhin [Sun, 12 Jan 2020 12:34:51 +0000 (15:34 +0300)]
Merge branch 'http-connect'

After this patchset http-connect works with pproxy [1]:

    $ pproxy -l http://:8000/ -vvv &
    $ http-connect //127.1:8000 http://kernel.org:80/

  [1]: https://pypi.org/project/pproxy/

* http-connect:
  http-connect: do not check connection on GET cb
  http-connect: set Host header (for CONNECT and GET) (like curl)
  http-connect: cleanup and helpers
  http: do not close connection for CONNECT
  http: do not assume body for CONNECT

Fixes: #946
5 years agohttp-connect: do not check connection on GET cb
Azat Khuzhin [Sun, 12 Jan 2020 12:31:50 +0000 (15:31 +0300)]
http-connect: do not check connection on GET cb

5 years agohttp-connect: set Host header (for CONNECT and GET) (like curl)
Azat Khuzhin [Sun, 12 Jan 2020 12:24:35 +0000 (15:24 +0300)]
http-connect: set Host header (for CONNECT and GET) (like curl)

5 years agohttp-connect: cleanup and helpers
Azat Khuzhin [Sun, 12 Jan 2020 12:14:24 +0000 (15:14 +0300)]
http-connect: cleanup and helpers

5 years agohttp: do not close connection for CONNECT
Azat Khuzhin [Sun, 12 Jan 2020 12:29:48 +0000 (15:29 +0300)]
http: do not close connection for CONNECT

5 years agohttp: do not assume body for CONNECT
Azat Khuzhin [Sun, 12 Jan 2020 10:43:18 +0000 (13:43 +0300)]
http: do not assume body for CONNECT

5 years agoAdded uninstall target check to cmakelists
Dimo Markov [Wed, 8 Jan 2020 18:37:16 +0000 (20:37 +0200)]
Added uninstall target check to cmakelists

5 years agoFix compilation without OPENSSL_API_COMPAT
Azat Khuzhin [Sun, 5 Jan 2020 16:02:22 +0000 (19:02 +0300)]
Fix compilation without OPENSSL_API_COMPAT

Use the following for openssl 1.1+:
- X509_getm_notBefore over X509_get_notBefore
- X509_getm_notAfter  over X509_get_notAfter
- use OPENSSL_VERSION_NUMBER over SSLeay()
- add missing headers

Refs: openssl/openssl@0b7347effee5

5 years agoevutil_time: Implements usleep() using wait funtion on Windows
yuangongji [Fri, 27 Dec 2019 09:53:28 +0000 (17:53 +0800)]
evutil_time: Implements usleep() using wait funtion on Windows

5 years agoInitialize variable to 0 replace use memset function in sample/hello-world.c
yangyongsheng [Sun, 29 Dec 2019 12:52:17 +0000 (20:52 +0800)]
Initialize variable to 0 replace use memset function in sample/hello-world.c

5 years agoappveyor: switch to Previous Visual Studio 2019 (VS issues after update)
Azat Khuzhin [Tue, 10 Dec 2019 06:25:39 +0000 (09:25 +0300)]
appveyor: switch to Previous Visual Studio 2019 (VS issues after update)

After update [1] of the Visual Studio 2019 image cmake unable to find
path to the c compiler [2]:

    cmake : CMake Error at CMakeLists.txt:47 (project):
    At line:1 char:1
    + cmake -G 'Visual Studio 16 2019' -A x64 ..
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (CMake Error at ...t:47 (project)::String) [], RemoteException
        + FullyQualifiedErrorId : NativeCommandError

      The CMAKE_C_COMPILER:
        C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.23.28105/bin/Hostx64/x64/cl.exe
      is not a full path to an existing compiler tool.

  [1]: https://github.com/appveyor/ci/issues/3231
       https://www.appveyor.com/updates/2019/12/09/
  [2]: https://ci.appveyor.com/project/libevent/libevent/builds/29431286/job/a68h7dn9rcride9g

5 years agoAdd support for priority inheritance
Andre Pereira Azevedo Pinto [Thu, 5 Dec 2019 01:56:54 +0000 (17:56 -0800)]
Add support for priority inheritance

Add support for posix mutex priority inheritance. This is important to
avoid priority inversion in systems running with threads with different
priorities.

Signed-off-by: Andre Azevedo <andre.azevedo@gmail.com>
5 years agocmake: set CMAKE_{RUNTIME,LIBRARY,ARCHIVE}_OUTPUT_DIRECTORY they are not defined
Azat Khuzhin [Sat, 30 Nov 2019 12:48:36 +0000 (15:48 +0300)]
cmake: set CMAKE_{RUNTIME,LIBRARY,ARCHIVE}_OUTPUT_DIRECTORY they are not defined

This will allow overriding them in parent cmake rules, i.e. if libevent
is used via add_subdirectory().

Closes: #931
5 years agocmake: use CMAKE_LIBRARY_OUTPUT_DIRECTORY for the final shared library symlink
Azat Khuzhin [Sat, 30 Nov 2019 12:53:52 +0000 (15:53 +0300)]
cmake: use CMAKE_LIBRARY_OUTPUT_DIRECTORY for the final shared library symlink

Fixes: 669a53f3 ("cmake: set library names to be the same as with autotools")
5 years agoappveyor: fix EVENT_CMAKE_OPTIONS expansion (for multiple arguments)
Azat Khuzhin [Sun, 17 Nov 2019 20:22:53 +0000 (23:22 +0300)]
appveyor: fix EVENT_CMAKE_OPTIONS expansion (for multiple arguments)

Fixes: 63f73ee2 ("CI: integrate testing for components export")
5 years agotest-ratelim: calculate timers bias (for slow CPUs) to avoid false-positive
Azat Khuzhin [Sun, 17 Nov 2019 15:13:51 +0000 (18:13 +0300)]
test-ratelim: calculate timers bias (for slow CPUs) to avoid false-positive

This can be/should be done for regression tests too.

Refs: https://ci.appveyor.com/project/libevent/libevent/builds/28916689/job/kg621aa194a0qbym
Refs: https://github.com/libevent/libevent/pull/917#issuecomment-553811834
v2: EVENT_BASE_FLAG_PRECISE_TIMER

5 years agomailmap: add name/email aliases for yuangongji (name and email)
Azat Khuzhin [Sun, 17 Nov 2019 12:41:22 +0000 (15:41 +0300)]
mailmap: add name/email aliases for yuangongji (name and email)

Before:
  $ git log --format='%aE %aN' --author=yuangongji | sort | uniq -c
       30 82787816@qq.com yuangongji
        1 82787816@qq.com yuangongji (A)

After:
  $ git log --format='%aE %aN' --author=yuangongji | sort | uniq -c
       34 yuangongji@foxmail.com yuangongji

5 years agoMerge #929 -- cmake package improvements
Azat Khuzhin [Sat, 16 Nov 2019 23:45:54 +0000 (02:45 +0300)]
Merge #929 -- cmake package improvements

Example:

  find_package(Libevent 2.2.0 REQUIRED COMPONENTS core)
  add_executable(test test.c)
  target_link_libraries(test ${LIBEVENT_LIBRARIES})

* upstream/pr/929:
  CI: integrate testing for components export
  cmake: test for find_package()
  cmake: improve package config file

5 years agoappveyor: fix openssl version mismatch warning
yuangongji [Tue, 22 Oct 2019 14:29:12 +0000 (22:29 +0800)]
appveyor: fix openssl version mismatch warning

yuangongji:

  "Many warnings appear when building and running with Visual Studio 2019 in Appveyor:

   WARN C:\projects\libevent\test\regress_ssl.c:210: Version mismatch for openssl: compiled with 1000214f but running with 1000212f

   Simply add the openssl binary to the "PATH" environment variable to fix it.

   I wrote a simple demo to reproduce it: https://github.com/ygj6/verify
   I see there are dozens of openssl libraries in the system of appveyor: https://ci.appveyor.com/project/ygj6/verify/builds/28290688
   If you do not specify which openssl to use, the system cannot find the correct library."

5 years agoappveyor: disable parallel tests execution
Azat Khuzhin [Sat, 16 Nov 2019 23:37:59 +0000 (02:37 +0300)]
appveyor: disable parallel tests execution

Refs: https://github.com/libevent/libevent/pull/917#issuecomment-553784701

5 years agoCI: integrate testing for components export
yuangongji [Thu, 14 Nov 2019 10:34:56 +0000 (18:34 +0800)]
CI: integrate testing for components export

5 years agocmake: test for find_package()
yuangongji [Thu, 14 Nov 2019 10:28:31 +0000 (18:28 +0800)]
cmake: test for find_package()

5 years agocmake: improve package config file
yuangongji [Thu, 7 Nov 2019 10:26:47 +0000 (18:26 +0800)]
cmake: improve package config file

5 years agoLink with iphlpapi only on windows
Azat Khuzhin [Wed, 6 Nov 2019 18:41:38 +0000 (21:41 +0300)]
Link with iphlpapi only on windows

Fixes: 9fecb59a ("Parse IPv6 scope IDs.")
Refs: #923

5 years agoParse IPv6 scope IDs.
Philip Homburg [Tue, 29 Oct 2019 14:48:53 +0000 (15:48 +0100)]
Parse IPv6 scope IDs.

5 years agoRelax bufferevent_connect_hostname_emfile
Azat Khuzhin [Thu, 31 Oct 2019 06:18:58 +0000 (09:18 +0300)]
Relax bufferevent_connect_hostname_emfile

Do not do any assumptions on the error for the EMFILE from
getaddrinfo(), expect just any error.

Fixes: #924
5 years agoautotools: fails build when need but can not find openssl
yuangongji [Sat, 26 Oct 2019 14:31:18 +0000 (22:31 +0800)]
autotools: fails build when need but can not find openssl

5 years agocmake: eliminate duplicate installation of public headers
yuangongji [Fri, 25 Oct 2019 13:54:13 +0000 (21:54 +0800)]
cmake: eliminate duplicate installation of public headers

5 years agoMerge pull request #915 from ygj6 -- evutil_socketpair win32 fixes
Azat Khuzhin [Mon, 21 Oct 2019 19:21:19 +0000 (22:21 +0300)]
Merge pull request #915 from ygj6 -- evutil_socketpair win32 fixes

* upstream/pr/915:
  appveyor: add vs2019 os to test some new features brought by Win10
  test: add testcase for evutil_socketpair()
  evutil: make evutil_socketpair() have the same behavior on Windows with build number lower and higher than 17063

5 years agoappend to CMAKE_MODULE_PATH
Michael Davidsaver [Mon, 21 Oct 2019 17:36:49 +0000 (10:36 -0700)]
append to CMAKE_MODULE_PATH

Don't override any -DCMAKE_MODULE_PATH= passed from CLI
to eg. test custom Platform/ support.

5 years agoappveyor: add vs2019 os to test some new features brought by Win10
yuangongji [Fri, 18 Oct 2019 15:32:14 +0000 (23:32 +0800)]
appveyor: add vs2019 os to test some new features brought by Win10

5 years agotest: add testcase for evutil_socketpair()
yuangongji [Fri, 18 Oct 2019 13:11:37 +0000 (21:11 +0800)]
test: add testcase for evutil_socketpair()

5 years agoevutil: make evutil_socketpair() have the same behavior on Windows with build number...
yuangongji [Fri, 18 Oct 2019 13:03:40 +0000 (21:03 +0800)]
evutil: make evutil_socketpair() have the same behavior on Windows with build number lower and higher than 17063

5 years agoDo not use sysctl.h on linux (it had been deprecated)
Azat Khuzhin [Tue, 15 Oct 2019 22:11:51 +0000 (01:11 +0300)]
Do not use sysctl.h on linux (it had been deprecated)

It had been deprecated for a long time (AFAIK), but since
glibc-2.29.9000-309-g744e829637 it produces a #warning

5 years agoevutil: implement socketpair with unix domain socket on Win10
yuangongji [Sat, 12 Oct 2019 10:45:52 +0000 (18:45 +0800)]
evutil: implement socketpair with unix domain socket on Win10

5 years agotravis-ci: add OPENSSL_1_1=yes for the openssl 1.1 to distinguish it in list
Azat Khuzhin [Mon, 14 Oct 2019 20:22:55 +0000 (23:22 +0300)]
travis-ci: add OPENSSL_1_1=yes for the openssl 1.1 to distinguish it in list

5 years agotravis-ci: use matrix.include over env.matrix/matrix.exclude for coveralls
Azat Khuzhin [Mon, 14 Oct 2019 20:20:23 +0000 (23:20 +0300)]
travis-ci: use matrix.include over env.matrix/matrix.exclude for coveralls

5 years agotravis-ci: build with clang only basic configurations
Azat Khuzhin [Mon, 14 Oct 2019 19:32:01 +0000 (22:32 +0300)]
travis-ci: build with clang only basic configurations

I tried to exclude clang instead (for PRs), but matrix.exclude cannot
have conditions (i..e matrix.exclude.if).

5 years agoUse matrix.include.if over matrix.exclude.if for doxygen
Azat Khuzhin [Mon, 14 Oct 2019 09:20:45 +0000 (12:20 +0300)]
Use matrix.include.if over matrix.exclude.if for doxygen

And use if.repo over if.slug

Fixes: aeb014cc ("Do not try to deploy documentaion for PR")
5 years agoDo not try to deploy documentaion for PR
Azat Khuzhin [Sun, 13 Oct 2019 23:49:55 +0000 (02:49 +0300)]
Do not try to deploy documentaion for PR

Anyway access to security variables is forbidden for PRs.

v2: use travis-ci conditions, to avoid running addons

5 years agoFix all all yamllint warnings in travis/appveyor rules
Azat Khuzhin [Tue, 8 Oct 2019 21:16:50 +0000 (00:16 +0300)]
Fix all all yamllint warnings in travis/appveyor rules

5 years agoappveyor: do not allow any failures
Azat Khuzhin [Tue, 8 Oct 2019 21:13:01 +0000 (00:13 +0300)]
appveyor: do not allow any failures

Yes we still have flacky tests, but anyway two main configuration can
fail too (and they do fail from time to time) so let's not allow any
failures and see how this will go.

(Credits to @ygj6 via #910)

5 years agoappveyor: fix build script for compiling using mingw-w64
yuangongji [Tue, 8 Oct 2019 14:01:01 +0000 (22:01 +0800)]
appveyor: fix build script for compiling using mingw-w64

5 years agosample/https-client: link crypt32 explicitly when build with mingw-w64
yuangongji [Tue, 8 Oct 2019 13:38:58 +0000 (21:38 +0800)]
sample/https-client: link crypt32 explicitly when build with mingw-w64

5 years agoMerge remote-tracking branch 'upstream/pr/908'
Azat Khuzhin [Mon, 7 Oct 2019 19:10:14 +0000 (22:10 +0300)]
Merge remote-tracking branch 'upstream/pr/908'

* upstream/pr/908:
  Avoid transforming base C_FLAGS set deliberately

5 years agoFix compat with NetBSD >= 10
Kamil Rytarowski [Thu, 3 Oct 2019 23:26:47 +0000 (01:26 +0200)]
Fix compat with NetBSD >= 10

kevent::udata was switched from intptr_t to void*.

Handle both cases with the GCC extension typeof().

5 years agoAvoid transforming base C_FLAGS set deliberately
William A Rowe Jr [Thu, 3 Oct 2019 18:40:52 +0000 (11:40 -0700)]
Avoid transforming base C_FLAGS set deliberately

The CMAKE_C_FLAGS_DEBUG, CMAKE_C_FLAGS_RELEASE, CMAKE_C_FLAGS_MINSIZEREL
and CMAKE_C_FLAGS_RELWITHDEBINFO options are correctly and deliberately
toggled to use the libcmt (/MT) flag options in place of the usual
msvcrt (/MD) options, but this isn't necessarily desired by the user.
The default choice can be overriden with the EVENT__MSVC_STATIC_RUNTIME
cmake option.

However, the /MD flag that is the choice of CMake only enters into
play for the four types of builds above. If the user introduces another
CMAKE_BUILD_TYPE, the base CMAKE_C_FLAGS must not be manipulated, as
that value (and the CMAKE_C_FLAGS_{custom} value) have been explicitly
chosen by the user/developer deploying this library, and the mismatch
between these flags in different dependencies results in link errors.

The CMake build schema itself doesn't place an /MD flag in CMAKE_BUILD_TYPE
so any /M compile option in that variable needs to be retained.

Signed-off-by: William Rowe <wrowe@pivotal.io>
Signed-off-by: Yechiel Kalmenson <ykalmenson@pivotal.io>
5 years agotinytest: support timeout on Windows
yuangongji [Thu, 26 Sep 2019 13:47:51 +0000 (21:47 +0800)]
tinytest: support timeout on Windows

5 years agoMerge branch 'upstream/pr/899' (evbuffer_freeze testcase enhancements)
Azat Khuzhin [Sun, 22 Sep 2019 15:44:55 +0000 (18:44 +0300)]
Merge branch 'upstream/pr/899' (evbuffer_freeze testcase enhancements)

* upstream/pr/899:
  improve the description of parameter to evbuffer_read()
  regress_buffer: improve testcase for evbuffer_freeze()

5 years agoimprove the description of parameter to evbuffer_read()
yuangongji [Sat, 21 Sep 2019 15:37:38 +0000 (23:37 +0800)]
improve the description of parameter to evbuffer_read()

5 years agoregress_buffer: improve testcase for evbuffer_freeze()
yuangongji [Thu, 19 Sep 2019 14:19:58 +0000 (22:19 +0800)]
regress_buffer: improve testcase for evbuffer_freeze()

5 years agoevbuffer_add_file: fix freeing of segment in the error path
Azat Khuzhin [Sat, 21 Sep 2019 20:30:48 +0000 (23:30 +0300)]
evbuffer_add_file: fix freeing of segment in the error path

if evbuffer_add_file_segment() fails it returns -1, so we should call
evbuffer_file_segment_free() only on error, and this -1 not 0.

Fixes: 6a81b1f5 ("Avoid double-free on error in evbuffer_add_file. Found by coverity.")
Backport-to: 2.1
5 years agoevutil_time: detect and use _gmtime64_s()/_gmtime64()
yuangongji [Thu, 19 Sep 2019 07:24:51 +0000 (15:24 +0800)]
evutil_time: detect and use _gmtime64_s()/_gmtime64()

5 years agohttp: rename bind_socket_ai() to create_bind_socket_nonblock()
yuangongji [Wed, 18 Sep 2019 20:12:59 +0000 (23:12 +0300)]
http: rename bind_socket_ai() to create_bind_socket_nonblock()

5 years agohttp: make sure the other fields in ext_method are not changed by the callback
yuangongji [Mon, 16 Sep 2019 15:24:32 +0000 (23:24 +0800)]
http: make sure the other fields in ext_method are not changed by the callback

5 years agohttps-client: load certificates from the system cert store on Windows
yuangongji [Sun, 15 Sep 2019 13:45:26 +0000 (21:45 +0800)]
https-client: load certificates from the system cert store on Windows

5 years agoBuild doxygen documentation via cmake (to fill variables)
Azat Khuzhin [Sun, 8 Sep 2019 19:30:54 +0000 (22:30 +0300)]
Build doxygen documentation via cmake (to fill variables)

Refs: #782

5 years agoDeploy documentation to libevent-doc.github.io
Azat Khuzhin [Sun, 8 Sep 2019 08:47:04 +0000 (11:47 +0300)]
Deploy documentation to libevent-doc.github.io

Based-on: https://github.com/ygj6/libevent/commit/4a86dcb4df0f9dc69f7722a1ba7567ef3b8447c8.patch (by @ygj6)

5 years agoFix checking return value of the evdns_base_resolv_conf_parse()
Azat Khuzhin [Thu, 5 Sep 2019 20:31:19 +0000 (23:31 +0300)]
Fix checking return value of the evdns_base_resolv_conf_parse()

Reported-by: Maxim Gorbachyov <maxim.gorbachyov@gmail.com>
5 years agocmake: fix getrandom() detection
Azat Khuzhin [Tue, 3 Sep 2019 21:46:01 +0000 (00:46 +0300)]
cmake: fix getrandom() detection

Fixes: 86f55b04 ("arc4random: replace sysctl() with getrandom (on linux)")
5 years agoarc4random: replace sysctl() with getrandom (on linux)
Azat Khuzhin [Mon, 2 Sep 2019 21:34:35 +0000 (00:34 +0300)]
arc4random: replace sysctl() with getrandom (on linux)

Since sysctl() is deprecated for a long-long time, according to
sysctl(2):

    Since Linux 2.6.24, uses of this system call result in warnings in the kernel log.

Fixes: #890
Suggested-by: Pierce Lopez
5 years agoUpgrade autoconf (after upgrading minimum required to 2.67)
yuangongji [Fri, 30 Aug 2019 02:21:07 +0000 (10:21 +0800)]
Upgrade autoconf (after upgrading minimum required to 2.67)

- AC_PROG_SED
- AC_USE_SYSTEM_EXTENSIONS
- AC_TRY_COMPILE -> AC_COMPILE_IFELSE
- AC_TRY_RUN -> AC_RUN_IFELSE
...

Also use:
- AC_CONFIG_AUX_DIR

Refs: #870
Fixes: 3f09e923 ("Change the minimum version of automake to 1.13 and autoconf to 2.67")
5 years agoRevert "Warn if forked from the event loop during event_reinit()"
Azat Khuzhin [Thu, 29 Aug 2019 19:57:44 +0000 (22:57 +0300)]
Revert "Warn if forked from the event loop during event_reinit()"

Thinking about this more and realizing that this was a mistake, so
should be reverted.

In a nut shell I guess most of the apps calls event_reinit() from the
loop (see [1] for example), and this should be totally fine (the bit
with the signals [2] handled in event_reinit() gracefully)

  [1]: https://archives.seul.org/libevent/users/Aug-2019/msg00009.html
  [2]: https://github.com/libevent/libevent/pull/833#issuecomment-501834453

This reverts commit 497ef904d544ac51de43934549dbeccce8e6e8f8.

Reported-by: mikulas@twibright.com
Backport-to: 2.1
5 years agoFixes spelling
Boris.Dergachov [Mon, 2 Sep 2019 08:11:58 +0000 (11:11 +0300)]
Fixes spelling

5 years agoDoxygen documentation improvements
yuangongji [Thu, 29 Aug 2019 11:40:10 +0000 (19:40 +0800)]
Doxygen documentation improvements

- Documentation for `bufferevent_compat.h` and `rpc.h` is not generated
  since the `@file` command is missing. It can be fixed by adding
  `@file` in file comment block.
- The briefs of buffer.h,bufferevent.h and some other files are missing.
  Adding `@brief` command can fix it.
- The parameters in the function declaration are different from the
  parameters following the `@param` command.We should change them to the
  same.
- Documentation of `watch.h` is not generated since `watch.h` has not
  been added to the Doxyfile `INPUT` tag.

- Add link to the watch.h in event.h

5 years agoeliminate some C4267 warnings in Windows
yuangongji [Wed, 28 Aug 2019 03:41:53 +0000 (11:41 +0800)]
eliminate some C4267 warnings in Windows

5 years agoautotools: attach doxygen target into all target
yuangongji [Fri, 23 Aug 2019 14:31:28 +0000 (22:31 +0800)]
autotools: attach doxygen target into all target

v2: disable man pages by default

5 years agocmake: attach doxygen target into all target
yuangongji [Fri, 23 Aug 2019 13:48:05 +0000 (21:48 +0800)]
cmake: attach doxygen target into all target

v2: Disable non-html generator for doxygen by default
v3: convert cmake option to doxygen config

5 years agoFix memory corruption in EV_CLOSURE_EVENT_FINALIZE with debug enabled
Jan Kasiak [Thu, 22 Aug 2019 20:36:12 +0000 (16:36 -0400)]
Fix memory corruption in EV_CLOSURE_EVENT_FINALIZE with debug enabled

Call event_debug_note_teardown_ before evcb_evfinalize to avoid possible
UAF (if finalizer free's event).

5 years agotest: prevent duplicate event_enable_debug_mode() for TT_ENABLE_DEBUG_MODE
Jan Kasiak [Tue, 27 Aug 2019 05:00:56 +0000 (01:00 -0400)]
test: prevent duplicate event_enable_debug_mode() for TT_ENABLE_DEBUG_MODE

5 years agotest: introduce TT_ENABLE_DEBUG_MODE flag
Azat Khuzhin [Mon, 26 Aug 2019 19:43:35 +0000 (22:43 +0300)]
test: introduce TT_ENABLE_DEBUG_MODE flag

5 years agotravis-ci: add openssl1.1 into travis build matrix
yuangongji [Tue, 20 Aug 2019 12:05:25 +0000 (20:05 +0800)]
travis-ci: add openssl1.1 into travis build matrix

Fixes: #705
5 years agosample/http-server: fix parameter parsing
David Disseldorp [Tue, 20 Aug 2019 23:10:19 +0000 (01:10 +0200)]
sample/http-server: fix parameter parsing

argv[1] is currently unconditionally passed as the docroot to
send_document_cb(). This is broken if any optional parameters are
provided, such as -p <port>.

Signed-off-by: David Disseldorp <ddiss@samba.org>
5 years agosample/signal-test: fix use of uninitialized variable
David Disseldorp [Tue, 20 Aug 2019 23:00:07 +0000 (01:00 +0200)]
sample/signal-test: fix use of uninitialized variable

signal_int is uninitialized in the !base error path.

Signed-off-by: David Disseldorp <ddiss@samba.org>
5 years agosample: fix 'INFINITY' undeclared error
ygj6 [Wed, 14 Aug 2019 11:47:45 +0000 (19:47 +0800)]
sample: fix 'INFINITY' undeclared error

5 years agobecat: avoid using anonymous structures
ygj6 [Tue, 13 Aug 2019 09:10:37 +0000 (17:10 +0800)]
becat: avoid using anonymous structures

It hasn't been part of the C standard until C11, although it is very
useful GCC extension it is better to avoid using this in cross platform
projects like libevent.

5 years agoFix typos in comments (sample/test/event-internal.h)
dota17 [Tue, 6 Aug 2019 10:19:15 +0000 (18:19 +0800)]
Fix typos in comments (sample/test/event-internal.h)

5 years agosample/signal-test: add NULL checks
dota17 [Thu, 8 Aug 2019 13:28:20 +0000 (21:28 +0800)]
sample/signal-test: add NULL checks

Fixes: #865
5 years agoAdd becat into .gitignore
Azat Khuzhin [Fri, 9 Aug 2019 09:25:21 +0000 (12:25 +0300)]
Add becat into .gitignore

5 years agoChange the minimum version of automake to 1.13 and autoconf to 2.67
ygj6 [Thu, 8 Aug 2019 13:48:21 +0000 (21:48 +0800)]
Change the minimum version of automake to 1.13 and autoconf to 2.67

When I run make check via automake with a version of 1.12.6 or lower, I got this error:

    /bin/sh: line 9: ./test_runner_epoll: No such file or directory
    FAIL: test_runner_epoll
    /bin/sh: line 9: ./test_runner_select: No such file or directory
    FAIL: test_runner_select
    /bin/sh: line 9: ./test_runner_kqueue: No such file or directory
    FAIL: test_runner_kqueue
    /bin/sh: line 9: ./test_runner_evport: No such file or directory
    FAIL: test_runner_evport
    /bin/sh: line 9: ./test_runner_devpoll: No such file or directory
    FAIL: test_runner_devpoll
    /bin/sh: line 9: ./test_runner_poll: No such file or directory
    FAIL: test_runner_poll
    /bin/sh: line 9: ./test_runner_win32: No such file or directory
    FAIL: test_runner_win32
    /bin/sh: line 9: ./test_runner_timerfd: No such file or directory
    FAIL: test_runner_timerfd
    /bin/sh: line 9: ./test_runner_changelist: No such file or directory
    FAIL: test_runner_changelist
    /bin/sh: line 9: ./test_runner_timerfd_changelist: No such file or directory
    FAIL: test_runner_timerfd_changelist

Open the Makefile generated by command ./autogen.sh && ./configure
I can see the errors are caused by this line:

    if $(TESTS_ENVIRONMENT) $${dir}$$tst $(AM_TESTS_FD_REDIRECT); then

$${dir}$$tst will expand to ./test_runner_epoll, but test_runner_epoll is only a target in test/include.am,
not a file, so it print:

    /bin/sh: line 9: ./test_runner_epoll: No such file or directory.

It seems like a bug in automake 1.12.6.
The errors will disappear if I simply upgrade automake to 1.13, and upgrade autoconf to 2.65
(2.65 is the lowest version dependent by automake-1.13).

When I build with automake-1.13 and autoconf-2.66, I got another error:

    configure.ac:667: error: AC_CHECK_SIZEOF: requires literal arguments

The code in configure.ac line 667 is :

    AC_CHECK_SIZEOF(void *)

It is a bug in autoconf-2.66 :
http://gnu-autoconf.7623.n7.nabble.com/AC-CHECK-SIZEOF-int-is-error-in-autoconf-2-66-td13537.html

Finally, everything works fine when using automake-1.13 and autoconf-2.67.
Refs: #858

5 years agoAdd Uninstall.cmake.in into dist archive
Azat Khuzhin [Sat, 3 Aug 2019 11:32:21 +0000 (14:32 +0300)]
Add Uninstall.cmake.in into dist archive

Fixes: #863
5 years agobuffer: fix possible NULL dereference in evbuffer_setcb() on ENOMEM
Azat Khuzhin [Wed, 31 Jul 2019 07:34:38 +0000 (10:34 +0300)]
buffer: fix possible NULL dereference in evbuffer_setcb() on ENOMEM

[ @azat:

  - add return heredoc for evbuffer_setcb()
  - add unit test with event_set_mem_functions()
  - look through the report from abi-compliance-checker/abi-dumper
]

Closes: #855
5 years agoChange autoconf version to 2.62 and automake version to 1.11.2
yuangongji [Sat, 27 Jul 2019 14:41:39 +0000 (22:41 +0800)]
Change autoconf version to 2.62 and automake version to 1.11.2

On my computer, the version of autoconf is 2.59 and automake is 1.9
I build with autogen.sh & configure & make and failed.

I find In Makefile.am:
    include/event2/event-config.h: config.h make-event-config.sed
        $(AM_V_GEN)test -d include/event2 || $(MKDIR_P) include/event2
        $(AM_V_at)$(SED) -f $(srcdir)/make-event-config.sed < config.h > $@T
        $(AM_V_at)mv -f $@T $@

There are three undefined variables: MKDIR_P, AM_V_GEN and AM_V_at.
Then I tried:
- autoconf-2.60 / automake-1.10
- autoconf-2.61 / automake-1.11
- autoconf-2.62 / automake-1.11.2

And only autoconf-2.62 & automake-1.11.2 is ok.

Therefore, I recommend changing the autoconf version from 2.59 to 2.62
and automake version from 1.9 to 1.11.2.

Plus autoconf 2.59 is too old - 2003.12.16 [1], so as automake 1.9 -
2004.08.11 [2], while $(AM_V_GEN)/$(AM_V_at) had been introduced in
371a1237 back in 2012.

  [1]: http://ftp.gnu.org/gnu/autoconf/
  [1]: http://ftp.gnu.org/gnu/automake/

Fixes: 371a1237 ("Make quiet build even quieter")
5 years agocmake: install shared library only if it was requested
Azat Khuzhin [Thu, 11 Jul 2019 21:00:12 +0000 (00:00 +0300)]
cmake: install shared library only if it was requested

  $ cmake -DEVENT__LIBRARY_TYPE=static ..
  ...
  CMake Error:
  Error evaluating generator expression:

    $<TARGET_FILE_DIR:event_core_shared>

  No target "event_core_shared"

Fixes: #853
Fixes: 669a53f3 ("cmake: set library names to be the same as with autotools")
5 years agoMissing <winerror.h> on win7/MinGW(MINGW32_NT-6.1)/MSYS
yuangongji [Tue, 2 Jul 2019 16:27:22 +0000 (00:27 +0800)]
Missing <winerror.h> on win7/MinGW(MINGW32_NT-6.1)/MSYS

5 years agocmake: set library names to be the same as with autotools
yuangongji [Tue, 9 Jul 2019 16:30:12 +0000 (00:30 +0800)]
cmake: set library names to be the same as with autotools

libtool has VERSION_INFO [1], cmake has SOVERSION/VERSION instead
(although it has different format). Also libtool has RELEASE [2] while
cmake do not have analog yet [3], hence manual symlinks should be
created.

  [1]: https://www.gnu.org/software/libtool/manual/html_node/Libtool-versioning.html
  [2]: https://www.gnu.org/software/libtool/manual/html_node/Release-numbers.html
  [3]: https://gitlab.kitware.com/cmake/cmake/issues/17652

Plus osx has compatibility_version/current_version dylib properties and
cmake do not have separate properties for them [4], hence manual LINK_FLAGS.
And also there INSTALL_NAME_DIR property which should be adjusted too.

  [4]: https://public.kitware.com/Bug/view.php?id=4383

So after all changes, here is an example before/after for osx and linux:

  # osx
    # autotools
    .libs/libevent_pthreads-2.2.1.dylib
    .libs/libevent_pthreads.dylib -> libevent_pthreads-2.2.1.dylib
    /usr/local/lib/libevent_pthreads-2.2.1.dylib (compatibility version 2.0.0, current version 2.0.0)
    # cmake
      # before patch
      lib/libevent_pthreads.2.2.0.dylib
      lib/libevent_pthreads.dylib -> libevent_pthreads.2.2.0.dylib
      @rpath/libevent_pthreads.2.2.0.dylib (compatibility version 2.2.0, current version 0.0.0)
      # after patch
      lib/libevent_pthreads-2.2.1.dylib
      lib/libevent_pthreads.dylib -> libevent_pthreads-2.2.1.dylib
      /vagrant/.cmake/inst/lib/libevent_pthreads-2.2.1.dylib (compatibility version 2.0.0, current version 2.0.0)

  # linux
    # autotools
    .libs/libevent_pthreads-2.2.so.1 -> libevent_pthreads-2.2.so.1.0.0
    .libs/libevent_pthreads-2.2.so.1.0.0
    .libs/libevent_pthreads.so -> libevent_pthreads-2.2.so.1.0.0
    # cmake
      # before patch
      lib/libevent_pthreads.so -> libevent_pthreads.so.2.2.0
      lib/libevent_pthreads.so.2.2.0
      # after patch
      lib/libevent_pthreads-2.2.so -> libevent_pthreads-2.2.so.1
      lib/libevent_pthreads-2.2.so.1 -> libevent_pthreads-2.2.so.1.0.0
      lib/libevent_pthreads-2.2.so.1.0.0
      lib/libevent_pthreads.so -> libevent_pthreads-2.2.so.1.0.0

Closes: #838 (cherry-picked)
Closes: #760
5 years agoEnable _GNU_SOURCE for Android
Keith Smiley [Mon, 8 Jul 2019 21:06:55 +0000 (14:06 -0700)]
Enable _GNU_SOURCE for Android

When targeting the Android NDK _GNU_SOURCE is not enabled by default:

```
 /*
  * With bionic, you always get all C and POSIX API.
  *
  * If you want BSD and/or GNU extensions, _BSD_SOURCE and/or _GNU_SOURCE are
  * expected to be defined by callers before *any* standard header file is
  * included.
  *
  * In our header files we test against __USE_BSD and __USE_GNU.
  */
 #if defined(_GNU_SOURCE)
 #  define __USE_BSD 1
 #  define __USE_GNU 1
 #endif
```

Because of this `pipe2` is not available:

```
 #if defined(__USE_GNU)
 int pipe2(int __fds[2], int __flags) __INTRODUCED_IN(9);
 #endif
```

The function used to check if it does exist:

```
CHECK_FUNCTION_EXISTS_EX(pipe2 EVENT__HAVE_PIPE2)
```

Just check that the _linking_ succeeds, which it does, it's just not
visible in the import, leading to a warning (or error):

```
evutil.c:2637:6: error: implicit declaration of function 'pipe2' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        if (pipe2(fd, O_NONBLOCK|O_CLOEXEC) == 0)
            ^
```

When targeting the NDK it should be safe to always opt into this. Clang
would pass the right flag for us automatically _if_ the source was C++
instead of C.

5 years agoEnable kqueue for APPLE targets
Keith Smiley [Tue, 2 Jul 2019 17:47:47 +0000 (10:47 -0700)]
Enable kqueue for APPLE targets

The CMAKE_CROSSCOMPILING variable is not set for Apple targets seemingly
because of cmake implementation details (more info
https://cmake.org/cmake/help/latest/variable/CMAKE_CROSSCOMPILING.html).
Since Apple targets have working kqueue implementations this check makes
sure we enable it always when those are the targets, without users
having to explicitly set EVENT__HAVE_WORKING_KQUEUE

5 years agoWarn if forked from the event loop during event_reinit()
Azat Khuzhin [Mon, 1 Jul 2019 20:54:02 +0000 (23:54 +0300)]
Warn if forked from the event loop during event_reinit()

Calling fork() from the event loop is not a great idea, since at least
it shares some internal pipes (for handling signals) before
event_reinit() call

Closes: #833
5 years agoautotools: do not install bufferevent_ssl.h under --disable-openssl
Azat Khuzhin [Wed, 26 Jun 2019 06:36:49 +0000 (09:36 +0300)]
autotools: do not install bufferevent_ssl.h under --disable-openssl

Refs: https://github.com/libevent/libevent/issues/760#issuecomment-502345788

5 years agocmake: link against shell32.lib/advapi32.lib
Azat Khuzhin [Tue, 25 Jun 2019 22:27:20 +0000 (01:27 +0300)]
cmake: link against shell32.lib/advapi32.lib

Fixes: #844
Refs: #760 (cmake-vs-autotools)

5 years agoAdd README.md/Documentation into dist archive
Azat Khuzhin [Tue, 25 Jun 2019 22:20:53 +0000 (01:20 +0300)]
Add README.md/Documentation into dist archive

Fixes: #841
5 years agoRequire cmake >= 3.1.2 (for correct openssl 1.0.2 detection)
Azat Khuzhin [Tue, 25 Jun 2019 21:59:41 +0000 (00:59 +0300)]
Require cmake >= 3.1.2 (for correct openssl 1.0.2 detection)

@ygj6 reported:
  "My platform is MacOS 10.13.5, This problem only happens on Mac.

   As written in the file CMakeLists.txt, the minimum required version of cmake is 3.1:
     cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
   So I built this project with cmake-3.1.0, but I got the following errors:

       CMake Error at /usr/local/cmake-3.1.0/share/cmake/Modules/FindOpenSSL.cmake:293 (list):
         list GET given empty list
       Call Stack (most recent call first):
         CMakeLists.txt:824 (find_package)

       CMake Error at /usr/local/cmake-3.1.0/share/cmake/Modules/FindOpenSSL.cmake:294 (list):
         list GET given empty list
       Call Stack (most recent call first):
         CMakeLists.txt:824 (find_package)

       CMake Error at /usr/local/cmake-3.1.0/share/cmake/Modules/FindOpenSSL.cmake:296 (list):
         list GET given empty list
       Call Stack (most recent call first):
         CMakeLists.txt:824 (find_package)

       CMake Error at /usr/local/cmake-3.1.0/share/cmake/Modules/FindOpenSSL.cmake:298 (list):
         list GET given empty list
       Call Stack (most recent call first):
         CMakeLists.txt:824 (find_package)

   I googled this error and got this answer:
     https://bugs.archlinux.org/task/43688

   It is a bug in FindOpenSSL.cmake on cmake-3.1.0 and fixed on cmake-3.1.2 .
   Of course, It was successful when rebuilding with cmake-3.1.2 .
   So I suggest setting the minimum version required for cmake to 3.1.2 or higher.
   "

Closes: #845
Refs: https://github.com/Kitware/CMake/commit/de4ccee75a89519f95fcbcca75abc46577bfefea

5 years agoevdns: add new options -- so-rcvbuf/so-sndbuf
Azat Khuzhin [Sat, 15 Jun 2019 20:18:05 +0000 (23:18 +0300)]
evdns: add new options -- so-rcvbuf/so-sndbuf

This will allow to customize SO_RCVBUF/SO_SNDBUF for nameservers in this
evdns_base, you may want to adjust them if the kernel starts dropping
udp packages.

5 years agoevutil: drop force_check from evutil_check_interfaces() (unused)
Azat Khuzhin [Fri, 14 Jun 2019 21:16:00 +0000 (00:16 +0300)]
evutil: drop force_check from evutil_check_interfaces() (unused)

5 years agoevutil: set the have_checked_interfaces in evutil_check_interfaces()
jeremyerb [Fri, 14 Jun 2019 14:19:51 +0000 (10:19 -0400)]
evutil: set the have_checked_interfaces in evutil_check_interfaces()

Closes: #836 (cherry-picked)
Fixes: #834