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.
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.
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#271Fixes#224
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.
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
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
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.
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_()