Cœur
8dd92069d6
Fix potential Null pointer dereference in bench_httpclient.c ( #1676 )
...
Co-authored-by: icy17 <1061499390@qq.com>
2024-06-23 21:15:23 +02:00
Cœur
5d830362dd
Fix potential Null pointer dereference in regress_dns.c ( #1675 )
...
Co-authored-by: icy17 <1061499390@qq.com>
2024-06-23 21:12:39 +02:00
Cœur
6d8c38afe7
Reducing the number of mingw warnings
2024-06-02 18:21:49 +03:00
Azat Khuzhin
13678f370c
gcc: fix some compiler errors from the new GCC ( #1658 )
...
gcc: fix some compiler errors from the new GCC
2024-06-02 00:53:58 +03:00
fanquake
f5b6104319
test: use evutil_timerclear over timerclear
2024-06-01 19:33:53 +03:00
Cœur
b202a72be4
temp size assert for #1632
2024-06-01 19:29:34 +03:00
Andy Pan
e58f1fa615
Fix the -Wint-conversion
...
---------
Signed-off-by: Andy Pan <i@andypan.me>
2024-06-01 18:24:43 +02:00
Andy Pan
ceb6551fa2
gcc: fix the -Wincompatible-pointer-types errors
...
---------
Signed-off-by: Andy Pan <i@andypan.me>
2024-06-01 18:24:43 +02:00
Andy Pan
7a9458c09b
Don't try to set SO_REUSEADDR and SO_REUSEPORT on Unix sockets ( #1625 )
2024-05-20 11:17:45 +02:00
Azat Khuzhin
0f51ba669a
test: mark http/timeout_read_server as retriable
2024-05-06 09:13:00 +02:00
Azat Khuzhin
ba97d94738
test: reset some static vars to avoid affecting other tests
2024-05-06 09:13:00 +02:00
Azat Khuzhin
479b5ed6f4
test: fix printing number of retries for FAILED message
2024-05-06 09:13:00 +02:00
Azat Khuzhin
d538f41f0a
test: add debugging for bufferevent/bufferevent_connect_fail_eventcb*
2024-05-06 09:13:00 +02:00
Azat Khuzhin
2d4d1747e9
test: suppress logging for buffer/add_file_leak1
...
Warnings from this test should be ignored:
[warn] evbuffer_file_segment_materialize: mmap(5, 0, 0) failed: Invalid argument
2024-05-06 09:13:00 +02:00
Azat Khuzhin
93a76aa275
test: add proper message in case of test failure
...
Right now it is impossible to understand what had been failed, but
after:
$ regress thread/conditions_simple
thread/conditions_simple: [forking]
FAIL /src/le/libevent/test/regress_thread.c:385: assert(n_signal == 0): 1 vs 0
[RETRYING thread/conditions_simple (attempts left 2, delay 1 sec)]
thread/conditions_simple: [forking]
FAIL /src/le/libevent/test/regress_thread.c:385: assert(n_signal == 0): 1 vs 0
[RETRYING thread/conditions_simple (attempts left 1, delay 1 sec)]
thread/conditions_simple: [forking]
FAIL /src/le/libevent/test/regress_thread.c:385: assert(n_signal == 0): 1 vs 0
[RETRYING thread/conditions_simple (attempts left 0, delay 1 sec)]
thread/conditions_simple: [forking]
FAIL /src/le/libevent/test/regress_thread.c:385: assert(n_signal == 0): 1 vs 0
[conditions_simple FAILED]
[FAILED thread/conditions_simple (attempts made -1)]
1/1 TESTS FAILED. (0 skipped)
2024-05-05 20:22:23 +02:00
Azat Khuzhin
d5745413cc
test: fix RETRYING message (add missing group prefix)
...
Before:
$ regress thread/conditions_simple
thread/conditions_simple: [forking]
FAIL /src/le/libevent/test/regress_thread.c:385: assert(n_signal == 0): 1 vs 0
[RETRYING conditions_simple (attempts left 2, delay 1 sec)]
After:
$ regress thread/conditions_simple
thread/conditions_simple: [forking]
FAIL /src/le/libevent/test/regress_thread.c:385: assert(n_signal == 0): 1 vs 0
[RETRYING thread/conditions_simple (attempts left 2, delay 1 sec)]
2024-05-05 20:21:58 +02:00
Cœur
eec47a6710
Fix typos ( #1634 )
2024-04-30 09:59:58 +02:00
Andy Pan
aef201a9fc
Change ident for EVFILT_USER to 0 and add a test ( #1582 )
...
Conventionally, ident for EVFILT_USER is set to 0 to avoid
collision of file descriptors, which is what other renowned
networking frameworks like netty(java), mio(rust), gnet(go),
swift-nio(swift), etc. do currently.
Co-authored-by: Azat Khuzhin <azat@libevent.org>
2024-04-29 07:35:33 +02:00
dockercui
147298a2d1
Fix some comments
...
Signed-off-by: dockercui <dockercui@aliyun.com>
2024-04-24 08:27:12 +02:00
williammuji
9de85b5834
fix WSOptions enum value and extended payload length bug
2024-04-15 10:31:04 +03:00
icy17
6e390911d0
Fix potential Null pointer dereference in regress_buffer.c
2024-04-15 10:26:46 +03:00
icy17
74217832a8
Fix potential Null pointer dereference in regress.c
2024-04-15 10:26:11 +03:00
icy17
d6e8835256
Fix potential Null pointer dereference in regress_et.c
2024-04-15 10:17:08 +03:00
icy17
d45dca4373
Fix potential Null pointer dereference in regress_thread.c
2024-04-15 10:16:26 +03:00
icy17
2bdf17370c
Fix potential Null pointer dereference in regress_finalize.c
2024-04-15 10:08:00 +03:00
icy17
17796a2d8a
Fix potential Null pointer dereference in regress_http.c
2024-04-15 10:06:42 +03:00
icy17
f9526e13ce
Fix potential NULL pointer dereference in regress_bufferevent.c
2024-04-15 10:05:32 +03:00
icy17
fc48803db4
Fix potential Null pointer dereference in regress_zlib.c ( #1597 )
...
Co-authored-by: Azat Khuzhin <a3at.mail@gmail.com>
2024-04-15 10:02:27 +03:00
Azat Khuzhin
539f73e319
Fix leak in evbuffer_add_file() on empty files
...
Found by oss-fuzz, after coverage had been improved in google/oss-fuzz#11257
v2: adjust test
v3: fix for windows (_get_osfhandle() crashes when called on closed fd)
v4: fix for EVENT__DISABLE_MM_REPLACEMENT
2024-03-12 09:29:47 +01:00
tgolang
9c8860ec6c
chore: remove repetitive words
...
Signed-off-by: tgolang <seekseat@aliyun.com>
2024-03-11 09:18:25 +01:00
Andy Pan
e66df92cfc
Accept SOCK_NONBLOCK/SOCK_CLOEXEC in type argument of socketpair ( #1567 )
...
Setting `SOCK_NONBLOCK` and `SOCK_CLOEXEC` in the `type` argument of `socketpair()` is widely supported across UNIX-like OS: Linux, *BSD, Solaris, etc., as is the `socket()`. This will conserve several extra system calls, we should use it where available.
### References
- [socketpair(2) on Linux](https://man7.org/linux/man-pages/man2/socketpair.2.html#HISTORY )
- [socketpair(2) on FreeBSD](https://man.freebsd.org/cgi/man.cgi?query=socketpair&sektion=2#DESCRIPTION )
- [socketpair(2) on DragonFly](https://man.dragonflybsd.org/?command=socketpair§ion=2 )
- [socketpair(2) on NetBSD](https://man.netbsd.org/socketpair.2#DESCRIPTION )
- [socketpair(2) on OpenBSD](https://man.openbsd.org/socketpair.2 )
- [socketpair(3C) on Solaris](https://docs.oracle.com/cd/E88353_01/html/E37843/socketpair-3c.html )
Changelog:
- Set SOCK_NONBLOCK and SOCK_CLOEXEC in the type argument of socketpair
- Avoid EPROTOTYPE on macOS and OpenBSD
- Eliminate the warnings about unused variables
- Add some comments
2024-03-07 09:19:11 +01:00
Azat Khuzhin
e4b8732701
Fix integer-overflow in ev_token_bucket_cfg_new
...
Found by oss-fuzz, after coverage had been improved in https://github.com/google/oss-fuzz/pull/11257
v2: better check (found by CI for windows)
2024-03-03 16:25:08 +01:00
Azat Khuzhin
c4fb0f7603
Fix divide-by-zero in ev_token_bucket_get_tick_
...
Found by oss-fuzz, after coverage had been improved in https://github.com/google/oss-fuzz/pull/11257
2024-02-20 08:58:04 +01:00
Azat Khuzhin
0dbd3eb3c9
tests: add test for EV_SIGNAL with timeout
...
Refs: https://github.com/libevent/libevent-book/issues/12
2024-02-19 22:07:32 +01:00
Ramon Ortega de Voor
ed35b30feb
Fix two compiler errors for unused variable and undefined function
...
In buffer.c a variable "flags" and a label "done" are defined but
never used if "EVENT__HAVEMMAP" is not defined.
The code does not work on platforms which do not provide
the function `socketpair()`. Introduce EVENT__HAVE_SOCKETPAIR flag
which determines if `socketpair()` or `evutil_ersatz_socketpair()`
is used.
2024-02-19 08:19:24 +01:00
Azat Khuzhin
87cdcc1868
http: change error for corrupted requests to 400 Bad Request
...
Previously it was 413 Request Entity Too Large, which was odd.
2024-02-18 17:02:45 +01:00
Azat Khuzhin
e60d039ddf
tests: add a test for malformed chunks
...
v2: fix test for win32 (and it more correct in general)
2024-02-18 17:02:32 +01:00
Sam James
4c38de8cb3
Fix -Walloc-size ( #1526 )
...
Co-authored-by: Azat Khuzhin <azat@libevent.org>
2023-11-26 21:52:32 +01:00
Azat Khuzhin
c15ba75d18
Merge branch 'evbuffer_add_reference_with_offset' - #1513
...
* evbuffer_add_reference_with_offset:
Add a comment for evbuffer_ref_cleanup_cb
tests: simplify test_evbuffer_add_reference_with_offset
Add function evbuffer_add_reference_with_offset()
2023-09-22 09:35:42 +02:00
Azat Khuzhin
d9780cf96a
Fix -Wsingle-bit-bitfield-constant-conversion warning in clang 16
...
report:
/src/le/libevent/sample/becat.c:304:29: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion]
case 'k': o.extra.keep = 1; break;
2023-09-21 22:04:17 +02:00
Azat Khuzhin
cc3a920073
tests: simplify test_evbuffer_add_reference_with_offset
2023-09-21 22:02:48 +02:00
MBeanwenshengming
648ec50e11
Add function evbuffer_add_reference_with_offset()
...
This is the same as evbuffer_add_reference(), but allows to specify
offset in the @data
v2: rename evbuffer_add_reference_misalign() to evbuffer_add_reference_with_offset()
2023-09-21 22:02:26 +02:00
Dmitry Ilyin
f39ad1c494
ws: replace evws_send with evws_send_text/evws_send_binary (ABI breakage) ( #1500 )
...
Replace evws_send with evws_send_text, and introduce new API -
evws_send_binary, that can be used to send binary frames.
But note, that this commit breaks the ABI compatibility, but it should be OK,
since there was only alpha release with evws_send, and nobody should rely on
this, and I hope nobody does (we decided to go this way to avoid supporting
deprecated API).
2023-08-31 21:38:41 +02:00
Azat Khuzhin
57d9eec641
Disable signalfd by default
...
signalfd may behave differently to sigaction/signal, so to avoid
breaking libevent users (like [1], [2]) disable it by default.
[1]: https://github.com/tmux/tmux/pull/3621
[2]: https://github.com/tmux/tmux/pull/3626
Also signalfd is not that perfect:
- you need to SIG_BLOCK the signal before
- blocked signals are not reset on exec
- blocked signals are allowed to coalesce - so in case of multiple
signals sent you may get the signal only once (ok for most of the
signals, but may be a problem for SIGCHLD, though you may call
waitpid() in a loop or use pidfd)
- and also one implementation problem -
sigprocmask is unspecified in a multithreaded process
Refs:
- https://lwn.net/Articles/415684/
- https://ldpreload.com/blog/signalfd-is-useless
Refs: https://github.com/libevent/libevent/issues/1460
Refs: #1342 (cc @dmantipov)
2023-07-13 21:21:09 +02:00
Vladislav Gusev
227510d577
Fix EVDNS_BASE_DISABLE_WHEN_INACTIVE ( #1493 )
...
I faced with strange problem: event loop doesn't exit after dns resolving with
`EVDNS_BASE_DISABLE_WHEN_INACTIVE`.
Stand:
- Ubuntu 22;
- libevent release-2.1.12-stable
- `resolve.conf` contains 2 nameservers;
- I use `evdns_base_new` with `EVDNS_BASE_DISABLE_WHEN_INACTIVE | EVDNS_BASE_INITIALIZE_NAMESERVERS` to avoid OS specific code.
After small investigation, look like events related with dns sockets added to
event_base before `evdns->disable_when_inactive` was initialized. `libevent`
did epoll_ctl(DEL) after resolving completed on the first socket, but the
second socket remained in the `epoll` interest list.
2023-07-13 21:20:33 +02:00
Krzysztof Dynowski
13366d2711
Test timer - synchronize clock before tv_timeout calculation.
2023-06-21 09:47:07 +02:00
Azat Khuzhin
fe610f2cdc
Fix util/mm_calloc_enomem under FreeBSD
...
It looks like the compiler optimizes this call out with tt_assert():
(gdb) disas /m test_event_calloc_enomem
Dump of assembler code for function test_event_calloc_enomem:
0x0000000000293bb0 <+0>: push %rbp
0x0000000000293bb1 <+1>: mov %rsp,%rbp
0x0000000000293bb4 <+4>: call 0x29f510 <__error@plt>
0x0000000000293bb9 <+9>: movl $0x0,(%rax)
0x0000000000293bbf <+15>: call 0x2990e0 <tinytest_set_test_failed_>
0x0000000000293bc4 <+20>: mov $0x2168e4,%edi
0x0000000000293bc9 <+25>: mov $0x220582,%esi
0x0000000000293bce <+30>: mov $0x20d893,%edx
0x0000000000293bd3 <+35>: mov $0x53a,%ecx
0x0000000000293bd8 <+40>: xor %eax,%eax
0x0000000000293bda <+42>: call 0x29f3b0 <printf@plt>
0x0000000000293bdf <+47>: mov $0x20da72,%edi
0x0000000000293be4 <+52>: mov $0x20f731,%esi
0x0000000000293be9 <+57>: xor %eax,%eax
0x0000000000293beb <+59>: pop %rbp
0x0000000000293bec <+60>: jmp 0x29f3b0 <printf@plt>
While with tt_ptr_op() it does not:
(gdb) disas /m test_event_calloc_enomem
Dump of assembler code for function test_event_calloc_enomem:
0x0000000000293bd0 <+0>: push %rbp
0x0000000000293bd1 <+1>: mov %rsp,%rbp
0x0000000000293bd4 <+4>: push %rbx
0x0000000000293bd5 <+5>: push %rax
0x0000000000293bd6 <+6>: call 0x29f610 <__error@plt>
0x0000000000293bdb <+11>: movl $0x0,(%rax)
0x0000000000293be1 <+17>: mov $0xffffffffffffffff,%rdi
0x0000000000293be8 <+24>: mov $0xffffffffffffffff,%rsi
0x0000000000293bef <+31>: call 0x2a01c0 <calloc@plt>
0x0000000000293bf4 <+36>: test %rax,%rax
0x0000000000293bf7 <+39>: je 0x293c2b <test_event_calloc_enomem+91>
2023-05-14 22:35:53 +02:00
Azat Khuzhin
13f5552336
test: add missing include of arpa/inet.h for ntohs in regress_ws.c
...
This will fix one warning in FreeBSD
2023-05-14 22:31:02 +02:00
Azat Khuzhin
6eba967e1c
Suppress -Wmacro-redefined for htonll/ntohll in OSX
...
OSX:
test/regress_ws.c:61:9: warning: 'htonll' macro redefined [-Wmacro-redefined]
#define htonll(x) \
^
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/sys/_endian.h:141:9: note: previous definition is here
#define htonll(x) __DARWIN_OSSwapInt64(x)
^
test/regress_ws.c:65:9: warning: 'ntohll' macro redefined [-Wmacro-redefined]
#define ntohll(x) htonll(x)
^
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/sys/_endian.h:140:9: note: previous definition is here
#define ntohll(x) __DARWIN_OSSwapInt64(x)
^
2023-05-14 22:01:18 +02:00
Azat Khuzhin
5f1fc92b13
Fix -Wtautological-constant-out-of-range-compare in regress_http under OSX
...
compiler warning:
test/regress_http.c:968:38: warning: result of comparison of constant 65536 with expression of type 'enum evhttp_cmd_type' is always true [-Wtautological-constant-out-of-range-compare]
if (evhttp_request_get_command(req) != EVHTTP_REQ_CUSTOM) {
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~
2023-05-14 21:55:43 +02:00