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!
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
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().
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
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
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.
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
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
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.
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.
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_()
We need only ipv6/ipv4 for connect in bufferevent, and since
sockaddr_storage is pretty big (128 bytes) it will be better to use
sockaddr_in6 here (it will fit ipv4 too).
Before this patch every time we are retrying our request we resolve
domain, but we could optimize this (since UDP is slow) by using cached
conn_address value, so do this.
In http the only case when when we could store it is when we already
connected, *but* if we are doing request using domain name, then we need
to do request to nameserver to get IP address, and this is handled by
bufferevent.
So when we have IP address (from nameserver) and don't have connection
to this IP address, we could already cache it to avoid extra DNS
requests (since UDP is slow), and we can't do this from http layer, only
from bufferevent.