Commit Graph

117 Commits

Author SHA1 Message Date
Carsten Larsen 2811e30d49 Release 1.12.0 2017-04-12 01:21:06 +02:00
Carsten Sonne Larsen 742f56907a AmigaOS changes 2016-03-05 09:59:40 +01:00
Andrew Ayer 11e37a92ef Add ares_set_socket_configure_callback()
This function sets a callback that is invoked after the socket is
created, but before the connection is established.  This is an ideal
time to customize various socket options.
2016-02-09 10:05:04 -08:00
David Drysdale 7972adc5d7 api: Add entrypoints to allow use of per-server ports
Add user-visible entrypoints ares_{get,set}_servers_ports(3), which
take struct ares_addr_port_node rather than struct ares_addr_node.
This structure includes a UDP and TCP port number; if this is set
to zero, the channel-wide port values are used as before.

Similarly, add a new ares_set_servers_ports_csv(3) entrypoint, which
is analogous to ares_set_servers(3) except it doesn't ignore any
specified port information; instead, any per-server specified port
is used as both the UDP and TCP port for that server.

The internal struct ares_addr is extended to hold the UDP/TCP ports,
stored in network order, with the convention that a value of zero
indicates that the channel-wide UDP/TCP port should be used.

For the internal implementation of ares_dup(3), shift to use the
_ports() version of the get/set functions, so port information is
transferred correctly to the new channel.

Update manpages, and add missing ares_set_servers_csv to the lists
while we're at it
2016-02-02 10:13:46 +00:00
David Drysdale f1bcfa1122 api: Allow injection of user-specified malloc/free functions
Add a new ares_library_init_mem() initialization function for the
library which allows the library user to specify their own malloc,
realloc & free equivalents for use library-wide.

Store these function pointers in library-wide global variables,
defaulting to libc's malloc(), realloc() and free().

Change all calls to malloc, realloc and free to use the function pointer
instead.  Also ensure that ares_strdup() is always available
(even if the local environment includes strdup(3)), and change the
library code to always use it.

Convert calls to calloc() to use ares_malloc() + memset
2016-02-02 10:05:07 +00:00
David Drysdale 87ff25049c Mark unhittable lines
Add comments for the benefit of the lcov tool, marking
lines that cannot be hit.  Typically these are fall-back
protection arms that are already covered by earlier checks,
and so it's not worth taking out the unhittable code (in case
someone changes the code between the two places in future).
2016-02-02 10:05:07 +00:00
David Drysdale fa14ba7b11 process_answer: fix things up correctly when removing EDNS option
When a server rejects an EDNS-equipped request, we retry without
the EDNS option.  However, in TCP mode, the 2-byte length prefix was
being calculated wrong -- it was built from the answer length rather than
the length of the original request.

Also, it is theoretically possible that the call to realloc() might change
the data pointed to; to allow for this, qbuf also needs updating.

(Both these fixes were actually included in a patchset sent on the mailing
list in Oct 2012, but were included with other functional changes that
didn't get merged:
http://c-ares.haxx.se/mail/c-ares-archive-2012-10/0004.shtml)
2016-01-24 09:05:40 +00:00
Daniel Stenberg ab78ef369d read_tcp_data: don't try to use NULL pointer after malloc failure
CID 56884, pointed out by Coverity. We really should make this function
return an error code so that a malloc() failure can return back a major
failure.
2016-01-18 13:12:38 +01:00
Daniel Stenberg 51dae48ecf configure_socket: explicitly ignore return code
CID 56889 in Coverity pointed out the return code from setsocknonblock()
is ignored, and this added typecast to (void) makes it explicit.
2016-01-18 13:08:17 +01:00
Guenter Knauf c8ec633bf5 Fixed warning 'type specifier missing'. 2013-08-31 22:40:22 +02:00
Daniel Stenberg efdd616118 timeoffset: made static and private
ares__timeoffset() was only used once within this single source file
2013-08-27 13:06:57 +02:00
Daniel Stenberg 30c9031afa timeadd: make static
ares__timeadd() was only ever used from within the same source
2013-08-27 13:02:35 +02:00
Daniel Stenberg 3217c7eef2 ares__swap_lists: make private and static
... since there's only one user, make it static within ares_process.c
2013-02-13 14:58:04 +01:00
Yang Tse 0c677f578e setup_once.h: refactor inclusion of <unistd.h> and <sys/socket.h>
Inclusion of these two header files now done in setup_once.h
2012-12-14 18:36:59 +01:00
Yang Tse a1035276c1 Header inclusion clean-up
Remove header inclusions already done in setup_once.h
2012-12-14 18:25:56 +01:00
hpopescu@ixiacom.com 90364defb0 Added new feature (rfc2671) 2012-08-17 00:54:47 +02:00
Daniel Stenberg e447bc5c60 code police: fix indents, < 80 columns, reflowed comments 2012-07-26 20:03:20 +02:00
Gisle Vanem 4d91235900 read_udp_packets: bail out loop on bad sockets
I can see that recvfrom() in ares_process.c many times is called with
'udp_socket' == ARES_SOCKET_BAD. The code takes care not to call
recv/recvfrom with ARES_SOCKET_BAD in the outer-loop. So should the
inner-loop.
2012-06-30 23:44:00 +02:00
Yang Tse 38b69b7269 Kill compiler warning 2012-06-14 21:19:48 +02:00
Yang Tse 66e91438c5 ares_process.c: fix compiler warning 2011-09-06 02:20:43 +02:00
Yang Tse 5ef8f5ead2 compiler warning: fix
Fix compiler warning: variable was set but never used

Fix compiler warning: clobber ignored
2011-05-25 11:19:10 +02:00
David Stuart 6518b56a5e IPv6-on-windows: find DNS servers correctly 2011-05-17 11:53:13 +02:00
Yang Tse 8c503ddf79 System's errno.h inclusion cleanup.
System's errno.h is conditionally included from setup_once.h
2011-03-22 14:02:23 +01:00
Daniel Stenberg 366cd6d54d advance_tcp_send_queue: avoid NULL ptr dereference
If given a too large 'num_bytes' value, it would cause a NULL ptr
dereference. Instead the code will now break out of the loop at the end
of the list.
2010-12-27 13:10:48 +01:00
Yang Tse 10ae9e4ec2 Fix GCC 4 compiler warning 'dereferencing type-punned pointer might break strict-aliasing rules'. 2010-11-14 04:42:10 +01:00
Yang Tse 4ab5eb6631 Revert commit 494274e653 2010-11-13 14:06:44 +01:00
Yang Tse 494274e653 Fix GCC 4 compiler warning 'dereferencing type-punned pointer might break strict-aliasing rules'. 2010-11-12 19:00:29 +01:00
Yang Tse 747981be8e Revert following commits:
07bc7ea795
  3392a50ea3
  9912637d32

The purpose of the whole patch was to silence a compiler warning triggered
with GCC 4 on file ares_process.c  The specific compiler warning was
'dereferencing type-punned pointer might break strict-aliasing rules'.

A simpler patch will follow to equally silence the warning.
2010-11-12 18:53:58 +01:00
Ben Greear 9912637d32 sock-addr-storage: Detect and deal with lack of .ss_family member.
AIX, at least, does not have sockaddr_storage.ss_family member.
Detect this in the configure logic and use proper #ifdefs in the
ares_process logic.

Signed-off-by: Ben Greear <greearb@candelatech.com>
Tested-by: Tor Arntsen <tor@spacetec.no>
2010-08-04 07:42:01 -07:00
Ben Greear 3392a50ea3 typo: Fix compile bug for platforms that don't have sockaddr_storage.
Bug was introduced by me in previous commit.

Signed-off-by: Ben Greear <greearb@candelatech.com>
2010-07-31 12:21:08 -07:00
Ben Greear 07bc7ea795 Fix aliasing warning in gcc 4.4.4 (at least).
Should be no functional change, though the code gets a bit
ugglier.

Signed-off-by: Ben Greear <greearb@candelatech.com>
2010-07-31 07:11:27 -07:00
Ben Greear 3e33e2c2ba ipv6: Fix some build issues related to the local-bind feature.
Signed-off-by: Ben Greear <greearb@candelatech.com>
2010-07-29 22:31:56 -07:00
Ben Greear e3b04e5a47 local-bind: Support binding to local interface/IPs
Add 3 new functions to set the local binding for the out-going
socket connection, and add ares_set_servers_csv() to set a
list of servers at once as a comma-separated string.

Signed-off-by: Ben Greear <greearb@candelatech.com>
2010-07-18 23:58:39 +02:00
Daniel Stenberg 63627fa5ab remove all $Id$ lines 2010-03-27 19:42:02 +01:00
Peter Pentchev a83d892bb2 Fix a couple of typos and grammar nits. 2010-03-25 13:00:17 +01:00
Yang Tse 8fe746fcf2 Added IPv6 name servers support 2010-03-05 20:01:47 +00:00
Daniel Stenberg 8b6f71ce95 - Tommie Gannert pointed out a silly bug in ares_process_fd() since it didn't
check for broken connections like ares_process() did. Based on that, I
  merged the two functions into a single generic one with two front-ends.
2010-01-28 22:03:48 +00:00
Yang Tse 58d9b0c1bd - Fix configure_socket() to use ares_socket_t instead of int data type. 2009-12-29 02:04:17 +00:00
Yang Tse 10461d1414 Make usage of calloc()'s arguments consistent with rest of code base 2009-11-18 10:33:54 +00:00
Yang Tse a82a8fbf82 Renamed c-ares setup.h to ares_setup.h 2009-11-02 11:55:53 +00:00
Yang Tse f34c2a879b sclose() function-like macro definition used to close a socket,
now solely based on HAVE_CLOSESOCKET and HAVE_CLOSESOCKET_CAMEL
config file preprocessor definitions.
2009-06-19 00:41:03 +00:00
Yang Tse 3a55bbebf1 Use build-time configured ares_socklen_t instead of socklen_t 2009-05-02 02:36:47 +00:00
Yang Tse 737707bf4b fix compiler warning: implicit conversion shortens 64-bit value into a 32-bit value 2009-04-14 12:53:53 +00:00
Phil Blundell 977de8c778 - ares__send_query() now varies the retry timeout pseudo-randomly to avoid
packet storms when several queries were started at the same time.
2009-01-13 11:51:04 +00:00
Daniel Stenberg f61fa37f40 Gregor Jasny provided the patch that introduces ares_set_socket_callback(),
and I edited it to also get duped by ares_dup().
2008-12-04 12:53:03 +00:00
Dan Fandrich 36a6a6e175 Only set TCP_NODELAY when it exists 2008-11-28 22:07:40 +00:00
Yang Tse 65cafbe109 Refactor configure script detection of functions used to set sockets into
non-blocking mode, and decouple function detection from function capability.
2008-11-13 18:56:56 +00:00
Daniel Stenberg 1a1b4eb4f2 - Carlo Contavalli added support for the glibc "rotate" option, as documented
in man resolv.conf:

  causes round robin selection of nameservers from among those listed.  This
  has the effect of spreading the query load among all listed servers, rather
  than having all clients try the first listed server first every time.

  You can enable it with ARES_OPT_ROTATE
2008-11-01 18:35:19 +00:00
Yang Tse 64c82d0853 Charles Hardin patch:
- handles the EINPROGRESS for UDP connects
- uses closesocket instead of close on some paths that were noticed
2008-10-21 01:58:23 +00:00
Yang Tse f214b583f5 adjust inclusion of "nameser.h" 2008-09-17 01:02:57 +00:00