evdns.c


Log

Author Commit Date CI Message
Nick Mathewson e2ca403f 2010-01-23T16:23:45 Make it compile under gcc --std=c89.
Nick Mathewson ff3f6cd4 2010-01-22T16:14:49 Check more internal event_add() calls for failure Most of these should be unable to fail, since adding a timeout generally always works. Still, it's better not to try to be "too smart for our own good here." There are some remaining event_add() calls that I didn't add checks for; I've marked those with "XXXX" comments.
Nick Mathewson 8d4aaf90 2010-01-20T12:56:54 Don't use a bind address for nameservers on loopback If the user sets a bind address to use for nameservers, and a nameserver happens to be on 127.0.0.1, the nameserver will generally fail. This patch alters this behavior so that the bind address is only applied when the nameserver is on a non-loopback address.
Nick Mathewson 66c02c78 2010-01-08T04:02:19 Look at the proper /etc/hosts file on windows. This is harder than it might initially seem, since the proper filename depends on what the admin has decided to call the windows system directory, which for all we know might be Q:\tralfamidore\slartibartfast. And of course, this being windows, there are twelve ways to do it, where you can pick a nice one or a portable one, but not a really nice portable one.
Nick Mathewson 72dd6667 2009-12-07T17:21:41 evdns_getaddrinfo() now supports the /etc/hosts file. The regular blocking evutil_getaddrinfo() already supported /etc/hosts by falling back to getaddrinfo() or gethostbyname(). But evdns_getaddrinfo() had no such facility. Now it does. The data structure here isn't very clever. I guess people with huge /etc/hosts files will either need to get out of the 1980s, or submit a patch to this code so that it uses a hashtable instead of a linked list. Includes basic unit tests.
Jardel Weyrich 0546ce11 2009-12-30T05:03:54 Eradicated the last free() call. Let mm_free() take care of deallocation.
Nick Mathewson 1e56a32d 2009-12-29T16:04:16 Make the initial nameserver probe timeout configurable. When we decide that a nameserver is down, we stop sending queries to it, except to periodically probe it to see if it has come back up. Our previous probe sechedule was an ad-hoc and hard-wired "10 seconds, one minute, 5 minues, 15 minutes, 1 hour, 1 hour, 1 hour...". There was nothing wrong with having it be ad-hoc, but making it hard-wired served no good purpose. Now the user can set the initial timeout via a new "initial-probe-timeout:" option; future timeouts back off by a factor of 3 on every failure to a maximum of 1 hour. As a side-benefit, this lets us cut the runtime of the dns/retry test from about 40 seconds to about 3 seconds. Faster unit tests are always a good thing.
Nick Mathewson ee4953f8 2009-12-29T16:03:30 Fix the code that allowed DNS options to not end with : We tried to fix this in 0.2.0.3-alpha, but our fix was buggy.
unknown c51bb3c3 2009-12-21T16:36:40 Fix a few locking issues on windows.
Nick Mathewson 2b7abf03 2009-12-04T13:49:27 Merge commit 'niels/dnscrash'
Yasuoka Masahiko 6c7c5799 2009-12-04T10:44:46 Fix a crash when reading badly formatted resolve.conf; from Yasuoka Masahiko
Nick Mathewson 0cd3bb9f 2009-11-27T17:22:19 Improved optional lock debugging. There were a couple of places in the code where we manually kept lock counts to make sure we never accessed resources without holding a lock, and that we never released a lock we didn't have. The lock-debugging code already puts counts on _every_ lock when lock debugging is enabled, so there is no need to keep these counts around otherwise. This patch rewrites the ASSERT_FOO_LOCKED macros to all use a common EVLOCK_ASSERT_LOCKED(). We also teach the lock debugging code to keep track of who exactly holds each lock, so that EVLOCK_ASSERT_LOCKED() means "locked by this thread."
Zhuang Yuyao 2df1f82b 2009-11-27T16:02:49 Fix an evdns lock violation. Original message: evdns contains a bug related to thread lock. enable thread lock by evthread_use_pthreads() will cause successive evdns_base_resolve_ipv4() (and other resolve functions i think) to hang on EVDNS_LOCK(base) after one or several successful call to evdns_base_resolve_ipv4().
Nick Mathewson 76cd2b70 2009-11-27T16:44:47 Stop passing EVTHREAD_READ and EVTHREAD_WRITE to non-rw locks. Previously, our default lock model kind of assumed that every lock was potentially a read-write lock. This was a poor choice, since read-write locks are far more expensive than regular locks, and so the lock API should only use them when we can actually take advantage of them. Neither our pthreads or win32 lock implementation provided rw locks. Now that we have a way (not currently used!) to indicate that we really want a read-write lock, we shouldn't actually say "lock this for reading" or "lock this for writing" unless we mean it.
Nick Mathewson 347952ff 2009-11-27T15:20:43 Revise the locking API: deprecate the old locking callbacks and add trylock. Previously, there was no good way to request different kinds of lock (say, read/write vs writeonly or recursive vs nonrecursive), or for a lock function to signal failure (which would be important for a trylock mode). This patch revises the lock API to be a bit more useful. The older lock calls are still supported for now. We also add a debugging mode to catch common errors in using the locking APIs.
Nick Mathewson 91fe23fc 2009-11-20T15:46:04 Tolerate code that returns from a fatal_cb. Also, replace more abort() calls with EVUTIL_ASSERT() or event_errx.
Nick Mathewson 767eb70f 2009-11-18T21:16:33 Fix compilation with threading disabled. svn:r1546
Nick Mathewson 86f57420 2009-11-16T22:25:46 Add two implementations of getaddrinfo: one blocking and one nonblocking. The entry points are evutil_getaddrinfo and evdns_getaddrinfo respectively. There are fairly extensive unit tests. I believe this code conforms to RFC3493 pretty closely, but there are probably more issues. It should get tested on more platforms. This code means we can dump the well-intentioned but weirdly-implemented bufferevent_evdns and evutil_resolve code. svn:r1537
Nick Mathewson 72bafc17 2009-11-16T22:23:55 Remove the stupid brokenness where DNS option names needed to end with a colon. svn:r1536
Nick Mathewson 18a8cfac 2009-11-15T19:00:12 Prefer calloc(a,b) to malloc(a*b). via openbsd. svn:r1531
Nick Mathewson e2b2de79 2009-11-15T18:59:48 Use arc4random() for dns transaction ids where available. Patch taken from OpenBSD svn:r1528
Nick Mathewson 784b8773 2009-11-06T21:46:57 We do not work any more without an event-config.h; stop pretending that it is meaningful to check for HAVE_CONFIG_H svn:r1516
Nick Mathewson d2e7e65d 2009-11-05T22:19:09 Move the evdns sample code into the sample directory and fix it not to use any deprecated APIs. svn:r1511
Nick Mathewson 25a5e681 2009-11-05T20:37:19 Build fixes for MSVC svn:r1506
Nick Mathewson 0b9eb1bf 2009-11-03T20:40:48 Add a bufferevent function to resolve a name then connect to it. This function, bufferevent_socket_connect_hostname() can either use evdns to do the resolve, or use a new function (evutil_resolve) that uses getaddrinfo or gethostbyname, like http.c does now. This function is meant to eventually replace the hostname resolution mess in http.c. svn:r1496
Nick Mathewson 2e36dbe1 2009-10-26T20:00:43 Use EVUTIL_ASSERT() consistently instead of assert. svn:r1464
Nick Mathewson e3fd294a 2009-10-16T13:19:57 Spelling fixes in comments and strings. svn:r1445
Nick Mathewson fc83ca3c 2009-10-14T00:46:40 Fix some crash bugs when initializing evdns svn:r1443
Nick Mathewson 213dc2a2 2009-08-03T20:15:32 Fix an annoying evdns crash bug, and add more unit tests for evdns. svn:r1406
Nick Mathewson 621aafd2 2009-07-30T22:11:23 Export sockaddr comparison functionality. svn:r1400
Nick Mathewson 7c20a6ae 2009-07-30T17:01:21 Export an ev_socklen_t. svn:r1391
Nick Mathewson 72ea534f 2009-07-28T19:41:57 Export evutil_str[n]casecmp as evutil_ascii_str[n]casecmp. svn:r1387
Nick Mathewson 5b5b880b 2009-07-28T19:41:39 Various MSVC cleanups from Brodie Thiesfield. svn:r1385
Nick Mathewson 12199fa7 2009-07-28T17:11:03 Fix segfault during failed allocatino of locked evdns base. We need to comb the rest of the code to make sure that we don't blindly wrap functions in LOCK(x), UNLOCK(x) when those functions might contain a FREE(x) in the middle. Rocco Carbone found and reported this bug. svn:r1384
Nick Mathewson b06b2649 2009-07-26T01:29:39 Make "deferred callback queue" independent of event_base. This way, we can more easily have an IOCP bufferevent implementation that does not need an event_base at all. Woot. svn:r1381
Nick Mathewson 670658eb 2009-07-21T18:32:57 Correct the signatures for evdns_configure_windows_nameservers(), now that it is exposed. svn:r1369
Nick Mathewson e83a32df 2009-07-14T19:31:20 Do not define _FORTIFY_SOURCE if the platform GCC already defined it for us. svn:r1346
Nick Mathewson 342ad355 2009-06-30T14:23:18 The truncated bit is in the 3rd byte of a dns reply, not the 4th. [fwd-port] svn:r1332
Nick Mathewson f901f986 2009-06-24T22:40:15 When our IP address changes, do not break all existing dns server sockets. Patch from Christopher Davis svn:r1329
Nick Mathewson 7289d7f8 2009-05-22T18:20:59 Fix a potentially very annoying evdns bug that we found in Tor. Generally speaking, it way better to event_assign() an event when you allocate it than to assign it before every time you event_add it: if it is already event_add()ed, the assign will mess it up so that it doesn't _look_ added, and event_add() will insert a second copy. Later, event_del() will only delete the second copy. Eventually, the event_base will have a dangling pointer to freed memory. Ouch! svn:r1307
Nick Mathewson f11dff2c 2009-05-07T03:45:51 Add and use locale-independent strcasecmp functions. svn:r1280
Nick Mathewson 7b24d72a 2009-05-02T16:22:55 Remove some duplicated includes in evdns.c svn:r1265
Nick Mathewson e865eb93 2009-05-01T00:54:14 More msvc build tweaks. svn:r1262
Nick Mathewson 1ad03264 2009-04-23T18:04:50 Fix win32 compilation issues. svn:r1234
Nick Mathewson 9516df0e 2009-04-23T05:40:06 Fix c89 bugs reported by Cory Stup. Others may remain. I wasn't able to get gcc --std=c89 to build libevent at all, so I don't know what compiler the original reporter is using here. Note that this change requires us to disable the part of our rpc code that uses variadic macros when using a non-gcc compiler. This is a problem if we want our rpc api to be portable. svn:r1231
Nick Mathewson 2d9619d7 2009-04-19T01:59:09 Make dns callbacks run deferred svn:r1205
Nick Mathewson 327165b3 2009-04-19T01:58:54 Add locks to evdns. svn:r1204
Nick Mathewson ac3fc991 2009-04-19T01:58:41 Use new-style headers in evdns.c svn:r1203
Nick Mathewson 684c022a 2009-04-06T20:38:42 Avoid a double event_del() in evdns.c. The bug could occur when a nameserver was marked as up, but then an outstanding probe sent to the nameserver failed. Now, evdns_up() cancels any outstanding probe. svn:r1140
Nick Mathewson d2e9caa6 2009-04-06T20:38:19 Fix evdns_cancel to alert callback and free associated RAM. Also, we add a test to make sure evdns_cancel is working properly. svn:r1139
Nick Mathewson 0f3c0983 2009-04-05T17:50:18 Fix a double-delete on the request timeout event. Port from Tor. svn:r1138
Nick Mathewson d0a9c90e 2009-02-11T17:29:17 Fix some of the crazier indentation and tabbing choices in evdns.c svn:r1120
Nick Mathewson 77c80b8d 2009-02-11T17:24:11 New bind-to option to allow DNS clients to bind to arbitrary ports for their outgoing addresses. svn:r1119
Nick Mathewson acaf65c3 2009-02-11T17:23:32 Make evutil_parse_sockaddr_port give a useful socket-length output. svn:r1118
Nick Mathewson f2a24d6e 2009-02-11T17:22:40 Better comments for some confusing-to-me code. svn:r1117
Nick Mathewson c6f4dc98 2009-02-11T17:21:48 Port some evdns changes over from Tor. svn:r1116
Nick Mathewson cd731b77 2009-02-10T21:40:12 Do not use ctypes functions in cases when we need the "net" locale. This patch adds a new set of EVUTIL_IS* functions to replace use of the ctypes is* functions in all cases where we care about characters' interpretations in net ascii rather than in the locale. For example, when we're working with DNS hostnames, we don't want to do the 0x20 hack on non-ascii characters, even if the host thinks they should be isalpha. svn:r1114
Nick Mathewson 1ed27048 2009-02-10T21:39:56 Stop rolling our own offsetof twice. svn:r1113
Nick Mathewson f04b90e5 2009-02-10T19:43:19 Make a couple of newer evdns functions more bulletproof. svn:r1112
Nick Mathewson 4d92e426 2009-02-02T19:22:27 forward-port: Make evdns_resolve_reverse args const. svn:r1096
Nick Mathewson 52eb4951 2009-01-31T07:31:47 Build with the -fno-strict-aliasing flag on GCC. You do not want to know about the 2 hours I just spent tracking down an evdns bug that only affected me on some platforms to the way we were using sockaddr* and sockaddr_in*. Suffice it to say that I do not think this is the only C99-aliasing-dubiousness in our code, nor that I am smart enough to keep my code correct with the GCC's strict aliasing optimizations in place. svn:r1079
Nick Mathewson 2546ea66 2009-01-31T05:45:26 Do not attempt to pass a va_args to regular snprintf. Hilarity will ensue. Fortunately, 1.4 does not have this bug. svn:r1078
Nick Mathewson e3e696c8 2009-01-28T20:24:12 Use size_t for name length in DNS requests. Not that it matters much. svn:r1066
Nick Mathewson 8889a770 2009-01-27T22:30:46 Replace all use of config.h with event-config.h. svn:r1064
Nick Mathewson 9993137c 2009-01-27T21:10:31 Remove all trailing whitespace in all the source files. svn:r1063
Nick Mathewson 2b1d535e 2009-01-26T17:29:27 Accept evutil_socket_t for evdns_server_ports. svn:r1053
Nick Mathewson 9935d5b0 2009-01-13T21:39:32 Fix win32 compilation. Surprisingly, unit tests pass too. svn:r1002
Nick Mathewson 169321c9 2009-01-13T20:26:37 Rename four internal headers to follow the -internal.h convention. svn:r1000
Nick Mathewson 81ab45ad 2009-01-13T19:20:04 Use new EVUTIL_ERR_*_RETRIABLE macros when we're testing an errno for blocking. Previously, we used inconsistent and incompletely ported ifdefs. (We don't use these macros in platform-specific files like evpoll.c, since they don't need to work on win32.) svn:r995
Nick Mathewson 980bcd68 2009-01-02T21:21:58 Work better with platforms that do not have ipv6 structures, or that do not have sin_len fields, etc. svn:r986
Nick Mathewson 135591ae 2009-01-02T20:46:35 Change the type of nameserver.address from u32 to sockaddr_storage, so that we can handle nameservers at IPv6 addresses. svn:r985
Niels Provos 87be18da 2008-12-25T16:25:37 implement evdns_cancel_request; test one of the new evdns_base functions svn:r980
Nick Mathewson dd731685 2008-12-03T20:09:13 Implement increased DSN-poisoning resistance via the 0x20 hack. svn:r958
Niels Provos 1eeb96aa 2008-11-29T01:12:41 move cirular queue removal into its own function svn:r957
Nick Mathewson de069b99 2008-09-05T16:29:56 On win32, errno is not the last socket error. Worse, WSAGetLastError() is not the last socket error sometimes (i.e., EWOULDBLOCK). Also, strerror() does not handle winsock errors. Therefore, event_err() and event_warn() are completely wrong for windows socket errors. Fix that. svn:r936
Niels Provos a710d817 2008-08-30T23:19:49 Match the query in DNS replies to the query in the request; from Vsevolod Stakhov svn:r930
Niels Provos 12077b4e 2008-07-16T03:47:47 support setting of AA or RD in dns server response svn:r910
Niels Provos 506f3d0c 2008-07-13T20:18:41 fix cname replies svn:r907
Niels Provos 409236a7 2008-07-02T04:39:09 detect CLOCK_MONOTONIC at runtime for evdns svn:r896
Niels Provos 52161b47 2008-06-25T14:56:35 fix a bug in which nameservers would not be added to the correct base in windows. svn:r873
Niels Provos 0bee2ff3 2008-06-25T00:34:24 void function should not return a value svn:r868
Nick Mathewson c6da86ff 2008-05-12T16:44:24 r19709@catbus: nickm | 2008-05-12 12:42:48 -0400 Possible fix for [1960723] snprintf and vsnprintf return values are wrong on win32 svn:r813
Nick Mathewson 6bf1ca78 2008-05-12T00:40:04 r19675@catbus: nickm | 2008-05-11 20:39:39 -0400 Stop pretending that u_char and u_short are standard types that win32 is dumb not to have. In fact, u_char can really just be spelled out, and u_short was usually just a bad way of saying ev_uint16_t. svn:r808
Nick Mathewson 3d60bccc 2008-05-08T14:25:44 r19656@catbus: nickm | 2008-05-08 10:25:08 -0400 forward-port: Remove #include "misc.h"s. svn:r795
Nick Mathewson a26442c5 2008-05-08T14:06:33 r19649@catbus: nickm | 2008-05-08 10:00:14 -0400 Replace gettimeofday() usage with a new evutil_gettimeofday(). This removes all previous need for win32-code/misc.[ch] svn:r792
Nick Mathewson 803dc36a 2008-05-05T19:19:08 r19609@catbus: nickm | 2008-05-05 15:16:52 -0400 Reename evdns-internal struct request to evdns_request, and expose the name. switch new evdns resolve APIs to return evdns_request*. This is a prereq to making evdns requests cancelable. svn:r778
Nick Mathewson 5fbc7f0a 2008-05-02T16:28:25 r15439@tombo: nickm | 2008-05-02 12:28:08 -0400 use event_assign internall; switch uses of event_set to use event_assign instead. svn:r755
Nick Mathewson 49868b61 2008-04-25T01:18:08 r15316@tombo: nickm | 2008-04-24 20:58:36 -0400 Rename internal memory management functions from event_malloc() etc to mm_malloc() etc. svn:r725
Nick Mathewson e688a88a 2008-04-17T17:55:35 r15216@tombo: nickm | 2008-04-17 13:55:05 -0400 Add new thread-safe interfaces to evdns functions. Needs review. svn:r714
Niels Provos 3ef1f504 2008-03-31T00:33:46 do not delete uninitialized timeout event in evdns svn:r697
Nick Mathewson 72105927 2008-02-28T20:57:01 r18490@catbus: nickm | 2008-02-28 15:56:55 -0500 Replace www.google.com with google.com; fix EVDNS_MAIN code. svn:r679
Nick Mathewson 69717730 2008-02-28T20:41:34 r18488@catbus: nickm | 2008-02-28 15:41:27 -0500 Define reentrant in evdns.c so that we get a declaration for strtok_r svn:r678
Nick Mathewson 11230f7e 2008-02-18T20:04:01 r18145@catbus: nickm | 2008-02-18 15:02:20 -0500 Stop using deprecated autoconf code to set integer types; detect actual files to include more thoroughly. This should make us work on solaris 9 again. This should be a backport candidate, if it works. Also, make all libevent code use ev_uint32_t etc, rather than uint_32_t. svn:r649
Niels Provos 506d4dbc 2008-02-17T01:31:31 remove NDEBUG ifdefs from evdns.c svn:r647
Nick Mathewson 7ab26a2c 2007-12-16T18:55:16 r15519@tombo: nickm | 2007-12-16 13:54:12 -0500 Fix for bug 1846282: accept as well-formed DNS replies with questions but no answers. svn:r595
Nick Mathewson 78d0de30 2007-12-06T18:38:50 Fix compile warnings and errors in win32 build. svn:r575
Nick Mathewson 1120f04f 2007-11-25T21:53:06 r16731@catbus: nickm | 2007-11-25 16:52:53 -0500 Replace all fds on non-unix-specific APIs with evutil_socket_t, which is int on unix and intptr_t on win32. svn:r552
Nick Mathewson 7eb250e9 2007-11-25T17:14:19 r14939@tombo: nickm | 2007-11-25 11:59:26 -0500 New function event_set_mem_functions to replace internal calls to malloc, free, etc with a user-supplied functions. svn:r541
Nick Mathewson 4e1ec3e0 2007-11-07T21:01:26 Make all the C files in the libraries compile under MSVC 2005 Express. There are still a few warnings, and probably some subtle issues, but it's better than nothing. svn:r499
Nick Mathewson 45c7ab25 2007-11-07T07:33:36 r16510@catbus: nickm | 2007-11-07 02:29:42 -0500 Try not to shadow local variables or function arguments. svn:r498