https-client: add -retries argument, for connection retries

Using evhttp_connection_set_retries() API.
bufferevent_openssl: reset fd_is_set when setfd with -1 is called

Otherwise we will use old fd after close(2) called on it:
(Traces trimmed, to minimize it)
$ strace -keclose,open,socket,epoll_ctl https-client -url https://libevent.org
socket(PF_INET, SOCK_STREAM|SOCK_NONBLOCK, IPPROTO_IP) = 5
 > /lib/x86_64-linux-gnu/libc-2.19.so(socket+0x7) [0xe6da7]
 > /usr/lib/libevent-2.1.so.4.0.0(evutil_socket_+0x25) [0x27835]
 > /usr/lib/libevent-2.1.so.4.0.0(bufferevent_socket_connect+0xe9) [0x1b1a9]
 > /usr/lib/libevent-2.1.so.4.0.0(bufferevent_socket_connect+0x21f) [0x1b2df]
 > /usr/lib/libevent-2.1.so.4.0.0(evutil_getaddrinfo_async_+0x65) [0x271a5]
 > /usr/lib/libevent-2.1.so.4.0.0(bufferevent_socket_connect_hostname+0x106) [0x1b416]
 > /usr/lib/libevent-2.1.so.4.0.0(evhttp_connection_connect_+0xe7) [0x39f07]
 > /usr/lib/libevent-2.1.so.4.0.0(evhttp_make_request+0xb8) [0x3a218]
epoll_ctl(3, EPOLL_CTL_ADD, 5, {EPOLLIN, {u32=5, u64=5}}) = 0
 > ...
 > /usr/lib/libevent_openssl-2.1.so.4.0.0(_init+0xfdd) [0x2ced]
 > /usr/lib/libevent-2.1.so.4.0.0(bufferevent_setfd+0x3b) [0x16d9b]
 > /usr/lib/libevent-2.1.so.4.0.0(bufferevent_socket_connect+0x75) [0x1b135]
 > /usr/lib/libevent-2.1.so.4.0.0(bufferevent_socket_connect+0x21f) [0x1b2df]
 > /usr/lib/libevent-2.1.so.4.0.0(evutil_getaddrinfo_async_+0x65) [0x271a5]
 > /usr/lib/libevent-2.1.so.4.0.0(bufferevent_socket_connect_hostname+0x106) [0x1b416]
 > /usr/lib/libevent-2.1.so.4.0.0(evhttp_connection_connect_+0xe7) [0x39f07]
 > /usr/lib/libevent-2.1.so.4.0.0(evhttp_make_request+0xb8) [0x3a218]
epoll_ctl(3, EPOLL_CTL_MOD, 5, {EPOLLIN|EPOLLOUT, {u32=5, u64=5}}) = 0
 > ...
 > /usr/lib/libevent_openssl-2.1.so.4.0.0(_init+0xfee) [0x2cfe]
 > /usr/lib/libevent-2.1.so.4.0.0(bufferevent_setfd+0x3b) [0x16d9b]
 > /usr/lib/libevent-2.1.so.4.0.0(bufferevent_socket_connect+0x75) [0x1b135]
 > /usr/lib/libevent-2.1.so.4.0.0(bufferevent_socket_connect+0x21f) [0x1b2df]
 > /usr/lib/libevent-2.1.so.4.0.0(evutil_getaddrinfo_async_+0x65) [0x271a5]
 > /usr/lib/libevent-2.1.so.4.0.0(bufferevent_socket_connect_hostname+0x106) [0x1b416]
 > /usr/lib/libevent-2.1.so.4.0.0(evhttp_connection_connect_+0xe7) [0x39f07]
 > /usr/lib/libevent-2.1.so.4.0.0(evhttp_make_request+0xb8) [0x3a218]
epoll_ctl(3, EPOLL_CTL_MOD, 5, {EPOLLOUT, {u32=5, u64=5}}) = 0
 > ...
 > /usr/lib/libevent_openssl-2.1.so.4.0.0(_init+0xbbc) [0x28cc]
 > /usr/lib/libevent_openssl-2.1.so.4.0.0(_init+0xd96) [0x2aa6]
 > /usr/lib/libevent_openssl-2.1.so.4.0.0(_init+0xeb8) [0x2bc8]
 > /usr/lib/libevent-2.1.so.4.0.0(event_free+0x3fe) [0x1fd1e]
 > /usr/lib/libevent-2.1.so.4.0.0(event_base_loop+0x407) [0x20677]
epoll_ctl(3, EPOLL_CTL_DEL, 5, 7fffa1f841e0) = 0
 > ...
 > /usr/lib/libevent_openssl-2.1.so.4.0.0(_init+0xbc4) [0x28d4]
 > /usr/lib/libevent_openssl-2.1.so.4.0.0(_init+0xd96) [0x2aa6]
 > /usr/lib/libevent_openssl-2.1.so.4.0.0(_init+0xeb8) [0x2bc8]
 > /usr/lib/libevent-2.1.so.4.0.0(event_free+0x3fe) [0x1fd1e]
 > /usr/lib/libevent-2.1.so.4.0.0(event_base_loop+0x407) [0x20677]
close(5)                                = 0
 > /lib/x86_64-linux-gnu/libpthread-2.19.so(__close_nocancel+0x7) [0xeb20]
 > /usr/lib/libevent-2.1.so.4.0.0(evhttp_connection_reset_+0x55) [0x373f5]
 > /usr/lib/libevent-2.1.so.4.0.0(evhttp_connection_connect_+0x1d) [0x39e3d]
 > /usr/lib/libevent-2.1.so.4.0.0(event_free+0x3fe) [0x1fd1e]
 > /usr/lib/libevent-2.1.so.4.0.0(event_base_loop+0x407) [0x20677]
epoll_ctl(3, EPOLL_CTL_ADD, 5, {EPOLLIN, {u32=5, u64=5}}) = -1 EBADF (Bad file descriptor)
) = -1 EBADF (Bad file descriptor)
/src/oss/strace-code/strace: Can't initiate libunwind: No such process
 > ...
 > /usr/lib/libevent_openssl-2.1.so.4.0.0(_init+0xfdd) [0x2ced]
 > /usr/lib/libevent-2.1.so.4.0.0(bufferevent_setfd+0x3b) [0x16d9b]
 > /usr/lib/libevent-2.1.so.4.0.0(evhttp_connection_connect_+0x14c) [0x39f6c]
 > /usr/lib/libevent-2.1.so.4.0.0(event_free+0x3fe) [0x1fd1e]
 > /usr/lib/libevent-2.1.so.4.0.0(event_base_loop+0x407) [0x20677]
/src/oss/strace-code/strace: Exit of unknown pid 28185 seen
[warn] Epoll ADD(1) on fd 5 failed.  Old events were 0; read change was 1 (add); write change was 0 (none); close change was 0 (none): Bad file descriptor
epoll_ctl(3, EPOLL_CTL_ADD, 5, {EPOLLOUT, {u32=5, u64=5}}) = -1 EBADF (Bad file descriptor)
) = -1 EBADF (Bad file descriptor)
/src/oss/strace-code/strace: Can't initiate libunwind: No such process
 > ...
 > /usr/lib/libevent_openssl-2.1.so.4.0.0(_init+0xfee) [0x2cfe]
 > /usr/lib/libevent-2.1.so.4.0.0(bufferevent_setfd+0x3b) [0x16d9b]
 > /usr/lib/libevent-2.1.so.4.0.0(evhttp_connection_connect_+0x14c) [0x39f6c]
 > /usr/lib/libevent-2.1.so.4.0.0(event_free+0x3fe) [0x1fd1e]
 > /usr/lib/libevent-2.1.so.4.0.0(event_base_loop+0x407) [0x20677]
/src/oss/strace-code/strace: Exit of unknown pid 28186 seen
[warn] Epoll ADD(4) on fd 5 failed.  Old events were 0; read change was 0 (none); write change was 1 (add); close change was 0 (none): Bad file descriptor
<getaddrinfo traces trimmed>
close(5)                                = -1 EBADF (Bad file descriptor)
)                                = -1 EBADF (Bad file descriptor)
/src/oss/strace-code/strace: Can't initiate libunwind: No such process
 > /lib/x86_64-linux-gnu/libpthread-2.19.so(__close_nocancel+0x7) [0xeb20]
 > /usr/lib/libevent-2.1.so.4.0.0(evhttp_connection_reset_+0x55) [0x373f5]
 > /usr/lib/libevent-2.1.so.4.0.0(evhttp_connection_fail_+0xc1) [0x3aed1]
 > /usr/lib/libevent-2.1.so.4.0.0(evhttp_connection_fail_+0x4a3) [0x3b2b3]
 > /usr/lib/libevent-2.1.so.4.0.0(bufferevent_enable+0x192) [0x16722]
 > /usr/lib/libevent-2.1.so.4.0.0(event_free+0x5df) [0x1feff]
 > /usr/lib/libevent-2.1.so.4.0.0(event_base_loop+0x407) [0x20677]
/src/oss/strace-code/strace: Exit of unknown pid 28187 seen
some request failed - no idea which one though!
socket error = Bad file descriptor (9)

Before this patch:
$ sample/https-client -retries 1 -url https://libevent.org
[warn] Epoll ADD(1) on fd 6 failed.  Old events were 0; read change was 1 (add); write change was 0 (none); close change was 0 (none): Bad file descriptor
[warn] Epoll ADD(4) on fd 6 failed.  Old events were 0; read change was 0 (none); write change was 1 (add); close change was 0 (none): Bad file descriptor
some request failed - no idea which one though!
socket error = Bad file descriptor (9)

After this patch:
$ sample/https-client -retries 1 -url https://libevent.org
Response line: 0 (null)

Reported-by: gerkenjohannes@web.de
Fix compilation for older OpenSSL versions.

For instance OpenSSL 0.9.7 does not have SSL_set_tlsext_host_name.

Also add the missing EVENT__DISABLE_SAMPLES CMake option.
evdns: fix EVDNS_BASE_DISABLE_WHEN_INACTIVE in case retransmit/retry
evdns: add retry/reissue tests for EVDNS_BASE_DISABLE_WHEN_INACTIVE
evdns: fail ns after we are failing/retrasmitting request

In case we are failing request (evdns_request_timeout_callback()), we
delete timeout_event in request_finished(), while just before calling
request_finished() (for failing request) there was a call to
nameserver_failed(), that add event for timeout_event, IOW we must fail
ns after request because otherwise we will not have timeout_event
actived, and we will waiting forever.

Before this patch the dns/retry_disable_when_inactive will wait forever,
after - OK.
Fix a typo in a doxygen comment. Reported by 亦得.
Merge remote-tracking branch 'origin/patches-2.0'
Merge pull request #108 from JoakimSoderberg/minor_issues

Fix compilation for older OpenSSL versions.
Merge pull request #170 from azat/https-client-retries

https-client: add -retries argument, for connection retries
Merge pull request #171 from azat/bufferevent-openssl-fixes-v4

bufferevent_openssl: reset fd_is_set when setfd with -1 is called
Merge pull request #174 from azat/dns-fail-disable-when-inactive-fix-v3

Dns fail disable when inactive fix v3
Provide support for SO_REUSEPORT through LEV_OPT_REUSABLE_PORT
Merge pull request #179 from pysiak/master

Provide support for SO_REUSEPORT through LEV_OPT_REUSABLE_PORT
Merge branch 'master' of https://github.com/libevent/libevent