3465 Commits

Author SHA1 Message Date
Azat Khuzhin
484d0db0fb Merge branch 'cloudabi-fixes-pr-278'
Rebased version of #278

* cloudabi-fixes-pr-278:
  Assume that ke_udata is an integer type on CloudABI.
  Add missing include of <netinet/in.h>.
  Include <sys/ioctl.h>, <sys/resource.h> and <sys/wait.h> optionally.
2015-09-10 12:26:48 +03:00
Ed Schouten
5602e451ce Assume that ke_udata is an integer type on CloudABI. 2015-09-10 12:15:42 +03:00
Ed Schouten
b2c68bc22b Add missing include of <netinet/in.h>.
POSIX states that sockaddr_in6 should be declared in <netinet/in.h>. By
including this header, the code now builds on FreeBSD and CloudABI.
2015-09-10 12:14:35 +03:00
Ed Schouten
c1404b5651 Include <sys/ioctl.h>, <sys/resource.h> and <sys/wait.h> optionally.
Though CloudABI implements a very large part of POSIX, it does not
provide these header files, for the reason that there is no raw device
access, no resource limiting and no access to the global process table
through wait().

It looks like these header files are not actually needed in theory.
There don't seem to be any constructs in these source files that use
these features, but I suspect they might still be required on some
systems.
2015-09-10 12:14:27 +03:00
Sebastian Hahn
bfcedee038 Add a prototype for event_disable_debug_mode()
Exporting this function seems rather useless, as debugging mode has to
be enabled early and calling this function doesn't allow it to get
toggled back on later.

Fixes a compile warning when using clang 3.6.

Fixes #271
Fixes #224
2015-09-10 11:53:54 +03:00
Azat Khuzhin
714fc70500 http: export evhttp_connection_set_family()
Fixes #176
2015-09-10 11:46:30 +03:00
Azat Khuzhin
a0f308da99 test/regress_be: bufferevent_enable() shouldn't call eventcb by it's own
It must enter the event loop regardless BEV_OPT_DEFER_CALLBACKS, to avoid
potential errors with subsequent connect(), you will find more info in #43,
since this is a regression for it.
2015-09-10 11:19:08 +03:00
Azat Khuzhin
37dc9e0eca test/regress_be: introduce fake_listener_create() 2015-09-10 11:18:34 +03:00
Azat Khuzhin
9b16d9b845 Merge branch 'evhttp-request-own-fixes'
I hope that I validated all places where evhttp_request_free() called and
ownership of request can be belong to user-specific code.

* evhttp-request-own-fixes:
  http: fix evhttp_request_own() by checking EVHTTP_USER_OWNED in more cases
  test/regress_http: cover evhttp_request_own()

Fixes #68
2015-09-09 19:32:03 +03:00
Azat Khuzhin
b0d3964ff5 http: fix evhttp_request_own() by checking EVHTTP_USER_OWNED in more cases
Suggested-by: @ellzey
Fixes: http/request_own
Fixes: #68
2015-09-09 19:31:12 +03:00
Azat Khuzhin
6f6fa0d28a test/regress_http: cover evhttp_request_own() 2015-09-09 19:15:18 +03:00
Azat Khuzhin
2cba677978 Merge branch 'http-server-EOF-at-read-v3'
This patchset fixes an issue with detecting EOF in http server and add some
regression tests to make sure that we will not break anything.

* http-server-EOF-at-read-v3:
  http: fix detecting EOF without write
  test/regress_http: cover write during read
  test/regress_http: verify that closecb will be called without multiple write

Closes #78
Link: http://stackoverflow.com/questions/18743948/libevent2-http-server-how-to-detect-client-close/18776728?noredirect=1#18776728
2015-09-09 18:08:02 +03:00
Azat Khuzhin
7ed02ac129 http: fix detecting EOF without write
Before this patch http server don't knows when client disconnected until it
will try to write to it, IOW to detect is client still alive you need to write
something to client socket, however it is not convenient since it requires to
store all clients somewhere and poll them periodically, and I don't see any
regressions if we will leave EV_READ always (like libevhtp do), since we
already reset read callback in evhttp_write_buffer() (see
http/write_during_read).

Also since we don't disable EV_READ anymore we don't need some enable EV_READ,
so we will reduce number of epoll_ctl() calls.

Covered-by: http/terminate_chunked_oneshot
Covered-by: http/write_during_read
Fixes: #78
2015-09-09 18:06:42 +03:00
Azat Khuzhin
3d15aeb4fd test/regress_http: cover write during read
This is the regression for evhttp_write_buffer() where we reset readcb to avoid
illegal state:
http/write_during_read: [err] evhttp_read_cb: illegal connection state 7

If you will comment that this test will fail.
2015-09-09 18:06:37 +03:00
Azat Khuzhin
4be6c70bb0 test/regress_http: verify that closecb will be called without multiple write
And now this works incorrect, i.e. http layer will not detect EOF until another
write.

Reported-in: #78
2015-09-08 16:43:05 +03:00
Azat Khuzhin
cf2cf2a01a test: run regress with EVENT_DEBUG_MODE=1 and without
This could show some bugs like "event_assign called on an already added event",
and some others that debugging mode could track.
2015-09-02 19:38:30 +03:00
Azat Khuzhin
6ea66554df test/regress: fix bufferevent_pair_release_lock with EVENT_DEBUG_MODE
Before this patch you will see next error:
$ EVENT_DEBUG_MODE= regress --no-fork bufferevent/bufferevent_pair_release_lock
bufferevent/bufferevent_pair_release_lock: [err] evthread initialization must be called BEFORE anything else!
2015-09-02 19:37:00 +03:00
Azat Khuzhin
4637aa8841 sample/https-client: add -timeout option 2015-09-02 19:34:52 +03:00
Azat Khuzhin
620aae969c Merge branch 'be-openssl-drop-fd_is_set-v4'
This must fix some issues with bufferevent openssl layer + some cleanups.

* be-openssl-drop-fd_is_set-v4:
  be_openssl: don't use *_auto() in do_handshake() we can't have fd == -1 there
  be_openssl: don't call set_open_callbacks() if fd == -1
  be_openssl: introduce be_openssl_auto_fd() helper
  be_openssl: introduce set_open_callbacks_auto()
  be_openssl: get rid off hackish "fd_is_set", to fix some corner cases
2015-09-02 19:34:15 +03:00
Azat Khuzhin
877280db09 be_openssl: don't use *_auto() in do_handshake() we can't have fd == -1 there 2015-09-02 19:28:33 +03:00
Azat Khuzhin
e8a2da96e3 be_openssl: don't call set_open_callbacks() if fd == -1
This must be illegal, firstly we must do set_do handshake and only after this
we could read/write.
2015-09-02 19:27:09 +03:00
Azat Khuzhin
2a8a7112a5 be_openssl: introduce be_openssl_auto_fd() helper 2015-09-02 19:27:01 +03:00
Azat Khuzhin
510da71fae be_openssl: introduce set_open_callbacks_auto()
This will split cases when we need to extract fd (cases when we have fd==-1
passed to set_open_callbacks()), and cases when we mustn't have to do this --
SET_FD via be_openssl_ctrl().
2015-09-02 19:25:21 +03:00
Azat Khuzhin
40b0379833 be_openssl: get rid off hackish "fd_is_set", to fix some corner cases
This patch is a cleanup and a bug fix, it drops ```fd_is_set``` flag, and
replace it with some checks to event_initialized(), and now we will not call
event_assign() on already added event, plus we will delete event when we really
have to (this patch fixes the case when server is down, IOW before this patch
we will not call event_del() because ```fd_is_set``` was reset to 0) and this
will fix some issues with retries in http layer for ssl.

Reported-in: #258
Fixes: regress ssl/bufferevent_socketpair_timeout
Fixes: regress ssl/bufferevent_socketpair_timeout_freed_fd
2015-09-02 19:20:19 +03:00
Azat Khuzhin
af85ecfccc Merge branch 'test-regress-be-openssl-v2'
This patchset is a bunch of regression tests for bufferevent openssl layer,
some of them already show some bugs, that bugs will be fixed in the next
patches.

* test-regress-be-openssl-v2:
  test/regress_ssl: check events fd/pending after timeout triggered
  test/regress_ssl: cover case when server didn't up (failed with timeout)
  test/regress_ssl: covert that we can't change fd with underlying
  test/regress_ssl: cover that events (read/write) at finish not pending
  test/regress_ssl: cover fd manipulations
  test/regress_ssl: convert open_ssl_bufevs() to mask
  test/regress_ssl: convert client/server to mask too
  test/regress_ssl: cover "allow_dirty_shutdown"
  test/regress_ssl: convert regress_bufferevent_openssl() to bitmask
2015-09-02 19:18:08 +03:00
Azat Khuzhin
cdafdf017e test/regress_ssl: check events fd/pending after timeout triggered
In this case client can't connect to server, and this bring to the front some
bugs with assigning on already added events (because of ```fd_is_set``` stuff),
for more info see #258, since this is the reproducible for it.
2015-09-02 19:15:27 +03:00
Azat Khuzhin
74845f1198 test/regress_ssl: cover case when server didn't up (failed with timeout) 2015-09-02 19:08:36 +03:00
Azat Khuzhin
df507afafd test/regress_ssl: covert that we can't change fd with underlying 2015-09-02 19:07:08 +03:00
Azat Khuzhin
762edb46a8 test/regress_ssl: cover that events (read/write) at finish not pending 2015-09-02 19:06:45 +03:00
Azat Khuzhin
b78a829752 test/regress_ssl: cover fd manipulations 2015-09-02 19:04:52 +03:00
Azat Khuzhin
46bba73103 test/regress_ssl: convert open_ssl_bufevs() to mask 2015-09-02 19:04:45 +03:00
Azat Khuzhin
34559913c0 test/regress_ssl: convert client/server to mask too 2015-09-02 19:04:39 +03:00
Azat Khuzhin
0430327364 test/regress_ssl: cover "allow_dirty_shutdown" 2015-09-02 19:04:11 +03:00
Azat Khuzhin
342e116ff6 test/regress_ssl: convert regress_bufferevent_openssl() to bitmask 2015-09-02 19:04:11 +03:00
Ed Schouten
ce1776c96d Test against SO_REUSEADDR (along with _WIN32).
This makes the code build on other systems that also don't have
SO_REUSEADDR without requiring special code.

[ azat: partially revert WIN32 check since SO_REUSEADDR on win32 differs from
unix semantics. ]

Closes #275
2015-09-02 19:01:48 +03:00
Azat Khuzhin
25e56fdbc1 tests/regress_ssl: drop duplicated assert 2015-09-01 20:40:03 +03:00
Christopher Wiley
2828bdb980 Always define missing TAILQ functions from sys/queue.h
On both Android and Ubuntu machines, TAILQ_END is not defined.  This
header also does not seem to be part of standard BSD sys/queue.h

Fix this by always defining missing TAILQ_ macros rather than
conditioning on a particular macro.

Fixes #267
2015-08-25 23:00:20 +03:00
Ed Schouten
fd36647af1 Don't use BSD u_* types.
These types are not part of POSIX. As we only use them in a small number
of places, we'd better replace them by C standard types. This makes a
larger part of the code build for CloudABI.
2015-08-25 19:15:50 +03:00
Ed Schouten
193c7de505 Remove BSD-ism: TIMEVAL_TO_TIMESPEC().
Systems like CloudABI implement kqueue() but do not provide the
BSD-specific TIMEVAL_TO_TIMESPEC() macro. Change the code to perform
this manually, as it is not hard to do this conversion.
2015-08-25 15:32:25 +02:00
Azat Khuzhin
c21229192f be: include all variations of headers for sockaddr_in6 struct
Fixes: c42bc6b279fd7cd4bc9b04c86a12e2ec5512cce1 ("be: fix sockaddr_in6 type
definition for win32")
Fixes: e04555155816306f23829a15b747664a57330c28 ("Merge branch
'reuse-conn_address-on-retry-v11'")
CI: https://ci.appveyor.com/project/nmathewson/libevent/build/2.1.5.109
Tested: manually
2015-08-20 00:13:29 +03:00
Azat Khuzhin
dfad1a460a http: eliminate warning about "socklen" in evhttp_connection_connect_() 2015-08-19 23:00:49 +03:00
Azat Khuzhin
c42bc6b279 be: fix sockaddr_in6 type definition for win32
bufferevent-internal.h:217:23: error: field 'in6' has incomplete type
   struct sockaddr_in6 in6;
                       ^
CI: https://ci.appveyor.com/project/nmathewson/libevent/build/2.1.5.108
2015-08-19 22:52:22 +03:00
Azat Khuzhin
f3d7ff5da2 sample/https-client: don't try to free uninitialized SSL
sample/https-client.c:459:3: warning: ‘ssl’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   SSL_free(ssl);
2015-08-19 13:23:20 +03:00
Azat Khuzhin
24a1f25ab6 sample/https-client: graceful exit with freeing memory (to make valgrind happy) 2015-08-19 13:19:41 +03:00
Andrey Skriabin
29a04825d0 https-client: correctly handle URLs with no path (like "https://host:port")
path == NULL check removed

Fixes: #233
Fixes: #234
2015-08-19 12:28:03 +03:00
Azat Khuzhin
6dc71e70dc sample/http-connect: don't use assert() to make it work with NDEBUG
Otherwise it will not work for cmake release target type.
2015-08-18 21:59:25 +03:00
Azat Khuzhin
9f0bff3f68 test/regress_http: initialize "dns_base" to avoid reading trash
Even though it is very unlikely, but it will better to fix this.
2015-08-18 21:32:03 +03:00
Azat Khuzhin
f976d4360b sample/http-connect: made it compatible with C90 2015-08-18 21:29:03 +03:00
Azat Khuzhin
e045551558 Merge branch 'reuse-conn_address-on-retry-v11'
There is regression tests and also this code worked/tested during crawling a
huge number of pages (billions).

* reuse-conn_address-on-retry-v11:
  be_sock: bufferevent_socket_set_conn_address(): assert instead of silent no-op
  http: reuse connected address only with EVHTTP_CON_REUSE_CONNECTED_ADDR
  be_sock: sanity check in bufferevent_socket_set_conn_address()
  be: replace sockaddr_storage with sockaddr_in6 for conn_address
  be: we don't need to use getpeername() we we have conn_address
  be: replace conn_address by full struct instead of pointer
  test/http: cover retrying with saved conn_address by shutting down dns server
  http: use IP address that we got before (if any) during retrying
  bufferevent: move conn_address out from http into bufferevent
  be: make @sa const for bufferevent_socket_connect()
  util: make @sa const for evutil_socket_connect_()
2015-08-18 21:21:52 +03:00
Azat Khuzhin
0ab88c2a9c be_sock: bufferevent_socket_set_conn_address(): assert instead of silent no-op 2015-08-18 20:41:16 +03:00