3444 Commits

Author SHA1 Message Date
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
Azat Khuzhin
a50f5f0ac0 http: reuse connected address only with EVHTTP_CON_REUSE_CONNECTED_ADDR 2015-08-18 20:06:53 +03:00
Azat Khuzhin
eedbeff368 be_sock: sanity check in bufferevent_socket_set_conn_address() 2015-08-18 20:06:53 +03:00
Azat Khuzhin
3889612488 be: replace sockaddr_storage with sockaddr_in6 for conn_address
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).
2015-08-18 20:06:53 +03:00
Azat Khuzhin
2c271e24f5 be: we don't need to use getpeername() we we have conn_address
Since getpeername() could fail.
2015-08-18 20:06:53 +03:00
Azat Khuzhin
e5615aa7a3 be: replace conn_address by full struct instead of pointer 2015-08-18 20:06:53 +03:00
Azat Khuzhin
f4874d8c1f test/http: cover retrying with saved conn_address by shutting down dns server 2015-08-18 20:06:52 +03:00
Azat Khuzhin
54c887d823 http: use IP address that we got before (if any) during retrying
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.
2015-08-18 20:06:52 +03:00
Azat Khuzhin
8bb3842552 bufferevent: move conn_address out from http into bufferevent
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.
2015-08-18 20:06:52 +03:00
Azat Khuzhin
dc33c78391 be: make @sa const for bufferevent_socket_connect() 2015-08-18 20:06:52 +03:00
Azat Khuzhin
a8d32c2353 util: make @sa const for evutil_socket_connect_() 2015-08-18 20:06:52 +03:00
Azat Khuzhin
1d34498ea3 sample: add HTTP CONNECT tunnelling example using libevent http layer 2015-08-18 12:59:50 +03:00
Azat Khuzhin
22061ac1e9 http: introduce evhttp_request_free_() helper 2015-08-18 11:58:13 +03:00
Azat Khuzhin
6540da3893 http: introduce evhttp_is_request_connection_close() helper 2015-08-18 11:57:54 +03:00
Mark Ellzey
1dbb55da32 Updated gitignore 2015-06-21 22:05:21 -04:00
Mark Ellzey
bdeec440f1 Merge pull request #190 from JohnOhl/evhttp-post-fix
evhttp: Fix failure to send all output data for POST/PUT requests
2015-06-17 08:24:52 -07:00
Mark Ellzey
620ff243c6 Update dns-example.
There's somebody out there who is going to have a compiler from 1986 who will complain. Better to fix c99 now.
2015-06-17 08:05:53 -07:00
Mark Ellzey
bde231d725 Merge pull request #183 from azat/dns-example
Some improvements for dns-example
2015-06-17 08:00:19 -07:00
Mark Ellzey
109b03f402 Merge pull request #254 from zeliard/master
Fix bench_httpclient to support win32
2015-06-07 09:39:24 -07:00
Seungmo Koo
cb96931236 Update bench_httpclient.c
*fixed: socket_geterror instead of WSAGetLastError
2015-06-07 15:51:15 +09:00
Mark Ellzey
57d059befb Merge pull request #253 from ellzey/master
Set correct socklen for PF_INET6 sockaddr len
2015-06-06 02:39:29 -07:00
zeliard
4e9325e8dc *fix: bench_httpclient to support win32 2015-06-05 16:39:26 +09:00