1222 Commits

Author SHA1 Message Date
Azat Khuzhin
c57f5c3490 Make rpc headers self-compilable
Fixes: #633
2018-05-07 02:40:16 +03:00
Azat Khuzhin
23c2914f6b Notify event base if there are no more events, so it can exit without delay
Fixes: #623
2018-04-26 01:14:49 +03:00
Azat Khuzhin
d1c8993c3c test/dns: install correct RLIMIT_NOFILE in bufferevent_connect_hostname_emfile
Otherwise poll() will fail with EINVAL:
       EINVAL The nfds value exceeds the RLIMIT_NOFILE value.

P.S. and cleanup this test a little, with early-return.

CI: https://travis-ci.org/libevent/libevent/jobs/370350426
2018-04-24 14:47:58 +03:00
Azat Khuzhin
e4edc7fc27 test/http: cover evhttp_connection_get_addr() for incomming connections
Refs: #510
2018-04-24 02:46:39 +03:00
Azat Khuzhin
a3d8f2e093 test/dns: verify bufferevent_socket_connect() errorcb invoking if socket() fails
Refs: #600
2018-04-24 02:05:30 +03:00
Azat Khuzhin
623ef3ccdc test/dns: cleanup test_bufferevent_connect_hostname() 2018-04-24 02:05:30 +03:00
Bernard Spil
28b8075400 Fix build with LibreSSL 2.7
LibreSSL 2.7 implements OpenSSL 1.1 API except for BIO_get_init()

See also: https://bugs.freebsd.org/226900
Signed-off-by: Bernard Spil <brnrd@FreeBSD.org>
Closes: #617 (cherry-pick)
2018-04-02 23:13:28 +03:00
Greg Hazel
4055081499 Call underlying bev ctrl GET_FD on filtered bufferevents
Fixes: #611
Fixes: #610
2018-03-25 22:38:25 +03:00
Azat Khuzhin
cb6995cf78 test/listener: cover immediate-close logic 2018-01-04 19:27:35 +03:00
John Fremlin
727bcea130 http: add callback to allow server to decline (and thereby close) incoming 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 https://github.com/bitcoin/bitcoin/issues/11368

Closes: #578 (patch cherry picked)
2017-12-18 03:00:04 +03:00
Azat Khuzhin
8a460e385a listener: cover closing of fd in case evconnlistener_free() called from acceptcb 2017-12-10 23:56:58 +03:00
Azat Khuzhin
c2c08e0203 Add missing includes into openssl-compat.h
Before it depends from the caller #include appropriate headers (at least
for OPENSSL_VERSION_NUMBER), but let's make it independent.

Fixes: #574
2017-11-22 10:35:01 +03:00
Azat Khuzhin
306747e51c Fix crashing http server when callback do not reply in place from *gencb*
This is the second hunk of the first patch
5ff8eb26371c4dc56f384b2de35bea2d87814779 ("Fix crashing http server when
callback do not reply in place")

Fixes: #567
2017-11-04 19:15:32 +03:00
Azat Khuzhin
5ff8eb2637 Fix crashing http server when callback do not reply in place
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>
2017-10-29 20:30:42 +03:00
Kiyoshi Aman
8b0aa7b36a Port event_rpcgen.py and test/check-dumpevents.py to Python 3.
These scripts remain compatible with Python 2.
2017-09-25 11:35:23 +03:00
Vincent JARDIN
56010f37ae test: fix warning
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);
2017-09-11 21:56:30 +02:00
Carlo Marcelo Arenas Belón
a86f89d333 test: avoid regress hanging in macOS
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
2017-09-11 01:48:35 +03:00
Carlo Marcelo Arenas Belón
63c4bf78d6 test: fix 32bit linux regress 2017-09-01 15:50:36 -07:00
Ondřej Kuzník
cf7f5b0dc4 Fix tests with detached builds
Closes: #524
2017-07-16 21:35:05 +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
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
Azat Khuzhin
8acfb0cd21 test: do not return void 2017-03-14 13:21:16 +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
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
Jan Beich
d057c45e8f Unbreak build with LibreSSL after openssl 1.1 support added
Fixes: 3e9e0a0d46e4 ("Make it build using OpenSSL 1.1.0")
Fixes: #445
2017-01-30 00:25:26 +03:00
Jan Beich
77ec05e50d test/bench*: prefix event-config.h macros after 0dda56a48e94 2017-01-29 23:02:41 +03:00
Jan Beich
d9118c8daa test/bench_httpclient: restore SO_LINGER usage after 0dda56a48e94 2017-01-29 23:02:41 +03:00
Azat Khuzhin
ea1d30cac4 test: register different tests in automake
Before this patch we have one test.sh (well test-script.sh), and tooks
very long to run it sequentially, but they are pretty lightweight, so we
should run then in parallel.
2017-01-22 03:22:07 +03:00
Azat Khuzhin
54d7473f91 test: run different tests under different options (in a wrapper) 2017-01-22 03:21:43 +03:00
Azat Khuzhin
d6bafbbeb2 test/dns: replace servname since solaris does not have "http"
Yes, by default solaris (solaris10.dev 5.10 Generic_147148-26 i86pc i386 i86pc)
does not have "http" in /etc/services
2017-01-20 02:16:50 +03:00
Azat Khuzhin
09b6201304 test/ssl: fix bufferevent_getfd() for bufferevent_openssl_filter_new() 2017-01-19 20:53:05 +03:00
Azat Khuzhin
d77fcea15f test/https: separate cases for https client with filtered openssl bufferevent
- http/https_filter_chunk_out # now hang
- http/https_filter_basic     # works, since writes only before connect()
2017-01-19 20:53:05 +03:00
Azat Khuzhin
d047c2412e test/ssl: cover case when we writing to be_openssl after connecting
Right now it fails because of regression for filtered openssl
bufferevent, and by it I mean ssl/bufferevent_filter_write_after_connect
test, and by fails - hang.

Regression-for: da52933550fd4736aa1c213b6de497e2ffc31e34 ("be_openssl:
don't call do_write() directly from outbuf_cb")
2017-01-19 20:53:05 +03:00
Azat Khuzhin
3c7422fc52 test/thread: netbsd is too slow, increase timeout for conditions_simple 2017-01-19 20:51:38 +03:00
Azat Khuzhin
0786253115 test/dns: run async resolving after sync one (to avoid timeouts)
If system resolver (sync one) will respond too slow, then we can fail async
request and evdns will retransmit tham again, but evdns server will accept that
failed requets, so we will have not 2 requests but 4.

Reproduced on centos box sometimes.
2017-01-19 20:50:22 +03:00
Azat Khuzhin
26f416c1a5 test/http: turn off some tests that based on backlog filling (falky)
Since this technique does not work well everywhere, anyway it fails from time
to time.

See: https://travis-ci.org/libevent/libevent/jobs/186426446
2017-01-08 05:22:02 +03:00
Azat Khuzhin
4798de6c64 test: fix util/date_rfc1123 under win32
Refs: #417
v2: check when gmtime() returns NULL
v3: fix overflow cases
2016-12-22 18:10:24 +03:00
Azat Khuzhin
4545807db4 Fix UB in evutil_date_rfc1123()
As pointed in https://github.com/libevent/libevent/pull/417#issuecomment-267860738
  "code is unsafe because in evutil_date_rfc1123() the pointer to the
  automatic variable struct tm cur is used outside the scope it defined."

Checked with `clang -fsanitize=address -fsanitize-address-use-after-scope`
and test that call evutil_date_rfc1123() with tm==NULL
2016-12-22 14:46:38 +03:00
Vis Virial
360aa233f0 add tests for evutil_date_rfc1123(). 2016-12-19 00:58:49 +03:00
Azat Khuzhin
cfe2ab22f2 test/https: fix ssl dirty bypass for https_simple
Tests:
- http/https_simple_dirty # not affected, since dirty is the default
- http/https_simple       # affected

v2: fix compilation with -DEVENT__DISABLE_OPENSSL=ON
2016-12-07 01:30:41 +03:00
Azat Khuzhin
45247e6fd9 test/https: cover multiple request over the same connection
Introduce two new tests:
- http/https_connection         # fail
- http/https_persist_connection # ok

Reported-by: liutao74748@163.com
2016-12-07 01:24:40 +03:00
Azat Khuzhin
e6ae069b48 test/http: sanity check for http_request_empty_done() 2016-12-07 01:24:40 +03:00
Azat Khuzhin
532a47ce1e test: fix building under openssl 1.1 (init functions has been deprecated)
Refs: #397
2016-12-07 01:14:16 +03:00
Azat Khuzhin
336f3b11e5 Fix _FILE_OFFSET_BITS redinition (solaris/autotools)
So firstly include our header (config.h) -- <evconfig-private.h>, and
only after it <sys/types.h> since latest has #ifdef guard, while our
config.h is not inteded for this.

And besides all this thing with LARGE_FILE is a abit awkward, since we
don't nefine _LP64/_LP32 anyway, and so we have next error actually (64bit VS
32bit):
==> solaris: In file included from ./util-internal.h:30:0,
==> solaris:                  from test/regress_ssl.c:49:
  ==> solaris: ./evconfig-private.h:29:0: warning: "_FILE_OFFSET_BITS" redefined
  ==> solaris:  #define _FILE_OFFSET_BITS 64
  ==> solaris:  ^
  ==> solaris: In file included from /usr/include/sys/types.h:17:0,
  ==> solaris:                  from test/regress_ssl.c:38:
  ==> solaris: /opt/csw/lib/gcc/i386-pc-solaris2.10/5.2.0/include-fixed/sys/feature_tests.h:196:0: note: this is the location of the previous definition
  ==> solaris:  #define _FILE_OFFSET_BITS 32
  ==> solaris:  ^

For cmake it commented in: 8b228e27f57300be61b57a41a2ec8666b726dc34
("Lot's of cmake updates")
2016-12-06 13:21:28 +03:00
Azat Khuzhin
253e7fa90c util-internal: fix __func__ redefinition (netbsd)
==> netbsd: In file included from ../listener.c:57:0:
==> netbsd: ../util-internal.h:58:0: warning: "__func__" redefined [enabled by default]
==> netbsd:  #define __func__ EVENT____func__
==> netbsd:  ^
==> netbsd: In file included from /usr/include/amd64/types.h:39:0,
==> netbsd:                  from /usr/include/sys/types.h:45,
==> netbsd:                  from ../listener.c:30:
==> netbsd: /usr/include/sys/cdefs.h:394:0: note: this is the location of the previous definition
==> netbsd:  #define __func__ __PRETTY_FUNCTION__
2016-12-06 12:54:33 +03:00
Azat Khuzhin
2c62062e12 Fix signedness differ for iov_base (solaris) 2016-12-06 12:54:33 +03:00
Philip Prindeville
6bf2061c4b C90 doesn't like declarations intermingled with statements
So move all of the declarations to the top of the offending function.

This patch includes both of issues (Fixes:), from @jeking3 and
@pprindeville

Fixes: #418
Fixes: nmathewson/Libevent#136
2016-12-06 09:56:28 +03:00
Tim Hentenaar
cb0df5cfac test/regress: cover a polling of invalid fd
Test that an event's callback is called if the fd is closed prior to being
polled for activity.

azat: make it run only for poll backend/method, and do not close fd
twice
2016-11-04 03:28:42 +03:00
Thomas Bernard
e983712456 use ev_uint16_t instead of unsigned short for port
Like in `sockaddr_in` structure in /usr/include/netinet/in.h

@azat: convert all other users (bench, compat, ..) and tweak message
Fixes: #178
Fixes: #196
Refs: 6bf1ca78
Link: https://codereview.appspot.com/156040043/#msg4
2016-10-26 01:41:13 +03:00