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.
* 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
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
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.
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>
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."
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
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.
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>
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)
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.
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>.
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.
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:
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
]
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.
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.
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.
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)
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
```
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.
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
@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.
"
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.