3850 Commits

Author SHA1 Message Date
Azat Khuzhin
74a2f5935a le-proxy: fix compiling under win32 (because of no "inline" in C)
Include <util-internal.h> for regular "inline", since it is used everywhere.
2017-05-29 21:49:58 +03:00
Azat Khuzhin
d22e12eefa http-connect: exit on error 2017-05-28 16:38:55 +03:00
Azat Khuzhin
15da23cfdb test: do not use .fieldname in structure initializations (fixes win32)
Fixes: #497
2017-05-01 21:57:23 +03:00
Azat Khuzhin
8d89c21258 Add missing print-winsock-errors.c into dist archive
Refs: #497
2017-05-01 21:55:00 +03:00
Maximilian Brunner
00ae45fe53 le-proxy: add missing return statement (UAF)
Refs: #501501501501501501501501501
2017-04-30 02:00:23 +03:00
José Luis Millán
0b4b0efdb8 Return from event_del() after the last event callback termination
Delete the event from the queue before blocking for the current
event callback termination.

Ensures that no callback is being executed when event_del() returns,
hence making this function a secure mechanism to access data which is
handled in the event callack.

Fixes: #236
Fixes: #225
Refs: 6b4b77a
Fixes: del_wait
2017-04-30 01:40:42 +03:00
Azat Khuzhin
5ff83989f3 test: cover that after event_del() callback will not be scheduled again
Refs: #236
Refs: #225
2017-04-30 01:35:03 +03:00
Gonçalo Ribeiro
f988c5ca0e Correct URL for the libevent logo 2017-04-29 23:37:20 +03:00
David Benjamin
c6c74ce265 Explicitly call SSL_clear when reseting the fd.
If reconnecting the via BEV_CTRL_SET_FD, bufferevent_openssl.c expects
OpenSSL to reuse the configuration state in the SSL object but retain
connection state. This corresponds to the SSL_clear API.

The code currently only calls SSL_set_connect_state or
SSL_set_accept_state. Due to a quirk in OpenSSL, doing this causes the
handshake to implicitly SSL_clear the next time it is entered. However,
this, in the intervening time, leaves the SSL object in an odd state as
the connection state has not been dropped yet. This behavior also does
not appear to be documented by OpenSSL.

Instead, call SSL_clear explicitly:
https://www.openssl.org/docs/manmaster/man3/SSL_clear.html
2017-04-21 19:19:04 -04:00
Dominic Chen
92cc0b9c3d bufferevent: refactor to use type check macros 2017-04-13 16:13:11 -04:00
Azat Khuzhin
266f43af77 Fix arc4random_addrandom() detecting and fallback (regression)
But this is kind of hot-fix, we definitelly need more sane arc4random
compat layer.

Fixes: #488
Introduced-in: 6541168 ("Detect arch4random_addrandom() existence")
2017-03-27 17:04:33 +03:00
Azat Khuzhin
177e2171cb Make event_count macros cleaner
Fixes: #489
2017-03-26 21:42:19 +03:00
Xiang Zhang
2e52bace9f fix evutil_make_internal_pipe_'s comment that fd[0] for read and f[1] for write 2017-03-18 15:25:20 +03:00
Azat Khuzhin
b1e8a4138f cmake: use APPEND during exporting targets (for old cmake)
On centos with cmake 2.8.12.2:
  CMake Error at cmake/AddEventLibrary.cmake:92 (export):
    export called with target "event_extra_shared" which requires target
    "event_core_shared" that is not in the export list.

    If the required target is not easy to reference in this call, consider
    using the APPEND option with multiple separate calls.

But on newer cmake I guess everything is ok.

Fixes: 7182c2f561570cd9ceb704623ebe9ae3608c7b43 ("cmake: build SHARED
and STATIC libraries (like autoconf does)")
2017-03-14 13:37:59 +03:00
Azat Khuzhin
d84f020545 Merge branch 'win32-fixes'
This patchset fixes win32 builds after some previous patches (referenced
in particular commits), and also removes some quirks for win32.

* win32-fixes:
  test: do not return void
  log/win32: fix exporting extern variable
  log-internal: missing extern "C"
  log: remove USE_GLOBAL_FOR_DEBUG_LOGGING
  cmake: Export missing symbols for win32
  cmake: eliminate EVENT_BUILDING_REGRESS_TEST, since we link with shared libs
  test: windows doesn't have WNOWAIT
  cmake: clean not used #defines from event-config.h
  cmake: add <pthread.h> only for non-win32
2017-03-14 13:31:02 +03:00
Azat Khuzhin
8acfb0cd21 test: do not return void 2017-03-14 13:21:16 +03:00
Azat Khuzhin
92cf234b0c log/win32: fix exporting extern variable
==> win:   C:\vagrant\log.c(73): error C2370: 'event_debug_logging_mask_' : redefinition; different storage class [C:\vagrant\.cmake-vagrant\event_core_shared.vcxproj]
2017-03-14 12:55:40 +03:00
Azat Khuzhin
a9c2116fac log-internal: missing extern "C" 2017-03-14 08:47:18 +03:00
Azat Khuzhin
49dcf4d554 log: remove USE_GLOBAL_FOR_DEBUG_LOGGING
Fixes: 9081b66c9c1446b11c0052bade799fafb460efed ("Export symbols for
-fvisibility=hidden (under cmake)")
2017-03-14 08:47:18 +03:00
Azat Khuzhin
48ead58e77 cmake: Export missing symbols for win32 2017-03-14 08:47:18 +03:00
Azat Khuzhin
30f2a969e8 cmake: eliminate EVENT_BUILDING_REGRESS_TEST, since we link with shared libs
Before 7182c2f561570cd9ceb704623ebe9ae3608c7b43 ("cmake: build SHARED
and STATIC libraries (like autoconf does)") it links with *.c.
2017-03-14 00:33:37 +03:00
Azat Khuzhin
a4b1828d6d test: windows doesn't have WNOWAIT
Fixes: 66a4eb0c3ae3b1f22b084b2d3aeb5c872f37efbd ("Check for WNOWAIT in
waitpid() in runtime (not in cmake/configure)")
2017-03-14 00:04:26 +03:00
Azat Khuzhin
d5e1087044 cmake: clean not used #defines from event-config.h
- _LARGE_FILES: we have it in evconfig-private.h.in, drop from event-config.h
- EVENT___FILE_OFFSET_BITS: remove it for now
- EVENT__const
2017-03-13 22:13:13 +03:00
Azat Khuzhin
2d2299cf7a cmake: add <pthread.h> only for non-win32
Fixes: b2b4b4d74e78a3e4fe7a74224d1e6aada5bde351 ("cmake: add <pthread.h>
into CMAKE_REQUIRED_INCLUDES for sizeof(pthread_t)")
2017-03-13 22:09:27 +03:00
Azat Khuzhin
882f537c40 cmake: fix pkgconfig generation (copy-paste typo) 2017-03-13 21:41:10 +03:00
Azat Khuzhin
489991a2b2 Merge branch 'cmake-missing-bits'
This patchset adds next missing things (in compare to autotools):
- pkgconfig
- event_pthreads/event_openssl
- compile shared/static libraries always

And some fixes, because it will not build after fixing other things:
- export missing symbols for cmake (-fvisibility=hidden)

* cmake-missing-bits:
  cmake: support visibility for AppleClang too
  cmake: fix export absolute path and relative path and cleanup a bit
  cmake: generate and install pkgconfig files
  cmake: build SHARED and STATIC libraries (like autoconf does)
  cmake: add missing event_openssl/event_pthreads libraries
  Export symbols for -fvisibility=hidden (under cmake)

Refs: #246
2017-03-13 21:08:07 +03:00
Azat Khuzhin
805e1aa819 cmake: support visibility for AppleClang too
Defaults apple linker behaviour is -two_levelnamespace, and you cannot
use "-undefined suppress" with it, so let's link non event_core with
event_core library to avoid undefined symbols.
2017-03-13 16:25:30 +03:00
Azat Khuzhin
fd5a3fc036 cmake: fix export absolute path and relative path and cleanup a bit
Remove next vars, since I don't think that somebody want to change it:
- bin
- lib
- include

And fix exports problem:
  CMake Error: INSTALL(EXPORT "LibeventTargets") given absolute DESTINATION "/usr/lib/cmake/libevent" but the export references an installation of target "event_core_static" which has relative DESTINATION "lib".
2017-03-13 16:20:40 +03:00
Azat Khuzhin
86c7357525 cmake: generate and install pkgconfig files
Fixes: #443
2017-03-13 16:20:40 +03:00
Azat Khuzhin
7182c2f561 cmake: build SHARED and STATIC libraries (like autoconf does)
Since they are useful for debugging, and if autotools build them then
cmamke has to do this too, to make migration more simple.

And now:
- tests: uses shared libraries (since this is upstreams one)
- other binaries: uses static libraries

This removes next private config:
- EVENT__NEED_DLLIMPORT
2017-03-13 16:20:40 +03:00
Azat Khuzhin
72ef9d1652 cmake: add missing event_openssl/event_pthreads libraries
This will remove openssl requirement if you don't use it (i.e. if you
not link with openssl_pthreads).

Plus it fixes some linking dependencies:
- libm required only for test-ratelim

And fix some coding style alignment issues.

Refs: #246
2017-03-13 12:57:22 +03:00
Azat Khuzhin
9081b66c9c Export symbols for -fvisibility=hidden (under cmake)
Fixes: #442
2017-03-13 12:57:22 +03:00
Azat Khuzhin
83b1584700 travis-ci: do not run coverage on osx
First of all we don't really need two of them, and also with apple-clang
it will fail (because of our checks in cmake), so just exclude it from
the build matrix.
2017-03-12 15:01:09 +03:00
Azat Khuzhin
7004ee8e86 travis-ci: use travis_retry to reduce number of problems with flacky tests 2017-03-12 13:21:53 +03:00
Azat Khuzhin
e01b993703 appveyor: remove -DEVENT__ENABLE_VERBOSE_DEBUG=ON build
See-also: c199df7bc78824ff579ff34c5f9f922034e8fa31 ("travis-ci: remove
-DEVENT__ENABLE_VERBOSE_DEBUG=ON (too much useless logs)")
2017-03-12 13:21:53 +03:00
Shuo Chen
65870949e7 Fix detection of timerfd_create() in CMake. 2017-03-12 01:00:41 -08:00
Azat Khuzhin
819d049377 Do not add epoll_sub (syscall wrappers) for epoll in cmake
Nowadays mostly all supported OS'es has this wrappers, and some of them (like
SmartOS) has wrappers but doesn't have __NR_epoll* defines for syscall numbers,
so just drop them (instead of adding yet another check int cmake like autotools
has, since this will break building in cross-compile environment).

Also one minor note, configure doesn't added epoll_sub.c either, since it check
epoll_create() in runtime.

And I tested it in SmartOS and it even works (`make verify`).

Fixes: #463
2017-03-08 23:34:44 +03:00
Azat Khuzhin
5aade2d30b Merge branch 'cmake-configure-fixes-v2'
Fixes in cmake, to make it more like configure and support some
cross-compiling.

* cmake-configure-fixes-v2:
  cmake: fix extracting of the version from git (check for number of matches)
  Detect arch4random_addrandom() existence
  Use off_t instead of ev_off_t for sendfile() (fixes android build)
  cmake: detect _GNU_SOURCE not by __GNU_LIBRARY__ only (fallback to _GNU_SOURCE)
  Check for WNOWAIT in waitpid() in runtime (not in cmake/configure)
  cmake: add <pthread.h> into CMAKE_REQUIRED_INCLUDES for sizeof(pthread_t)
  cmake: fix values for #cmakedefine
  cmake: drop duplicates from event-config template
  cmake: add value for the #cmakedefine macros (like autoconf)
  cmake: Fix checking of enum values from sysctl.h
2017-03-08 17:58:26 +03:00
Azat Khuzhin
d65e3e1dbe cmake: fix extracting of the version from git (check for number of matches) 2017-03-08 13:31:55 +03:00
Marek Sebera
6541168d70 Detect arch4random_addrandom() existence
Refs: #370
Refs: #475
2017-03-08 13:31:55 +03:00
Azat Khuzhin
f479a00894 Use off_t instead of ev_off_t for sendfile() (fixes android build)
Refs: #475
2017-03-08 13:31:55 +03:00
Azat Khuzhin
71a56bd3a7 cmake: detect _GNU_SOURCE not by __GNU_LIBRARY__ only (fallback to _GNU_SOURCE)
Fixes pipe2() on Android-9/armv7-a

Refs: #475
2017-03-08 13:31:55 +03:00
Azat Khuzhin
66a4eb0c3a Check for WNOWAIT in waitpid() in runtime (not in cmake/configure)
Because checking in cmake breaks cross-compiling.

Introduced-in: 43eb56c7c738e3642f0981e3dd6ab9e082eec798.
Fixes: #482
Fixes: #462
Refs: #475

v2: use waitid() with WNOWAIT
v3: use WNOWAIT only if it available in waitpid(), because not all netbsd
    supports it
2017-03-08 13:31:55 +03:00
Azat Khuzhin
b2b4b4d74e cmake: add <pthread.h> into CMAKE_REQUIRED_INCLUDES for sizeof(pthread_t)
Fixes: #475
2017-03-08 13:31:55 +03:00
Azat Khuzhin
7f945b2d1b cmake: fix values for #cmakedefine 2017-03-08 13:31:53 +03:00
Azat Khuzhin
852726028f cmake: drop duplicates from event-config template 2017-03-08 12:47:32 +03:00
Azat Khuzhin
336ab816c8 cmake: add value for the #cmakedefine macros (like autoconf)
Before this patch for cmake we had:
  #define EVENT__HAVE_ACCEPT4
  /* #undef EVENT__HAVE_ARC4RANDOM */

While autotools has:
 #define EVENT__HAVE_ACCEPT4 1
 /* #undef EVENT__HAVE_ARC4RANDOM */
2017-03-08 12:47:31 +03:00
Azat Khuzhin
fa135bdcd9 cmake: Fix checking of enum values from sysctl.h
CheckSymbolExists do not do this, so add new CheckConstExists that will
use CheckCSourceCompiles() to check this.

v2: use set() instead of string(APPEND)
2017-03-08 12:47:22 +03:00
Azat Khuzhin
c199df7bc7 travis-ci: remove -DEVENT__ENABLE_VERBOSE_DEBUG=ON (too much useless logs)
I guess we can revert part of 59649f7 commit, we tried, but it adds more problems than solves.

Refs: https://github.com/libevent/libevent/pull/476#issuecomment-284259602
2017-03-06 02:56:27 +03:00
Azat Khuzhin
98faf19895 Merge branch 'fix-openssl-linking'
* fix-openssl-linking:
  sample/https-client: use ERR_remove_*state() when we have them
  Do not check for ERR_remove_thread_state() (do not link ssl into every library)

Closes: #476
2017-03-06 02:46:38 +03:00