kc3-lang/libevent/evdns.c

Branch :


Log

Author Commit Date CI Message
749128b2 2010-09-04 22:02:32 Merge remote branch 'github/win32_posix_underscore'
19521436 2010-09-03 16:42:16 Expose a function to add a nameserver by sockaddr
e50c0fcc 2010-09-02 11:10:50 Use the _func() replacements for open, fstat, etc in evutil.c on win32 Remember that in a fit of ANSI C compliance, Microsoft decided to screw portability by renaming basically all the functions in unistd.h to get prefixed with an understore. For some reason, mingw didn't seem to mind, but at least some people's compilers did: see bug 3044490.
d0b88433 2010-08-18 10:49:12 Set close-on-exec bit for filedescriptors created by dns subsystem. Based on patch for 1.4 by Ralf Schmitt.
ec347b92 2010-07-07 16:45:03 Move event-config.h to include/event2 This change means that all required include files are in event2, and all files not in event2/* are optional.
5fa30d2b 2010-08-06 17:13:27 Fix evdns build with -DUNICODE It turns out that GetProcAddress always takes its second argument as a C string, regardless of whether unicode is on or not.
cc2379d2 2010-07-26 14:48:32 Constify a couple of arguments to evdns_server_request_add_*_reply
e1c1167c 2010-07-22 14:38:08 Replace (unused,always 0) is_tcp argument to evdns_add_server_port*() with flags Since we weren't using it for anything, and we always failed if it was set, we're allowed to change the future semantics of setting it.
7e87a599 2010-07-21 14:33:42 Stop asserting when asked for a (unsupported) TCP dns port. Just return NULL.
899b0a39 2010-05-24 15:24:03 Use generic win32 interfaces, not ASCII-only ones, where possible.
b14f151b 2010-05-18 17:27:06 If no evdns request can be launched, return NULL, not a handle Some of our evdns code was willing to return an evdns_request with handle->current_req set to NULL. Really, those cases should just return NULL.
b1c79500 2010-04-23 14:42:25 Make evdns logging threadsafe The old logging code was littered with places where we stored messages in static char[] fields. This is fine in a single-threaded program, but if you ever tried to log evdns messages from two threads at once, you'd hit a race. This patch also refactors evdns's debug_ntop function into a more useful evutil_sockaddr_port_format() function, with unit tests.
ceefbe87 2010-04-23 14:04:03 Add a comment to explain why evdns_request is now separte from request
67072f3c 2010-04-22 21:46:05 Assert for valid requests as necessary. A valid request has an associated handle, and the handle must point to the request.
a6258400 2010-04-21 22:20:10 Free search state when finished searching to avoid an infinite loop.
beaa14a4 2010-04-21 22:01:59 Move domain search state to evdns_request. It doesn't seem to make sense to copy the state to each new request in the search.
15bb82d6 2010-04-21 21:21:21 Ensure that evdns_request is a persistent handle. When searching is enabled, evdns may make multiple requests before calling the user callback with the result. This is a problem because the same evdns_request handle is not retained for each search request, so the user cannot reliably cancel the request. This patch attempts to ensure that evdns_request persists accross search requests.
899c1dcc 2010-04-14 15:42:57 Replace EVUTIL_CLOSESOCKET macro with a function The EVUTIL_CLOSESOCKET() macro required you to include unistd.h in your source for POSIX. We might as well turn it into a function: an extra function call is going to be cheap in comparison with the system call. We retain the EVUTIL_CLOSESOCKET() macro as an alias for the new evutil_closesocket() function. (commit message from email by Nick and Sebastian)
859af677 2010-03-13 00:53:54 Free evdns_base->req_heads on evdns_base_free It looks like when we moved from one big inflight-requests list to an n-heads structure, we didn't make evdns_base_free() free the array of heads. This patch should fix that. Found with valgrind
b2f2be6e 2010-03-10 16:25:16 Make evdns use the regular logging system by default Once, for reasons that made sense at the time, we had evdns.c use its own logging subsystem with two levels, "warn" and "debug". This leads to problems, since setting a log handler for Libevent wouldn't actually trap these messages, since they weren't on by default, and since some of the warns should really be msgs. This patch changes the default behavior of evdns.c to log to event_(debugx,warnx,msgx) by default, and adds a new (internal-use-only) log level of EVDNS_LOG_MSG. Programs that set a evdns logging function will see no change. Programs that don't will now see evdns warnings reported like other warnings.
2c2618d8 2010-03-05 13:00:15 more whitespace normalization
4faeaea9 2010-02-19 03:39:50 Clean up formatting: function/keyword spacing consistency. - Keywords always have a space before a paren. Functions never do. - No more than 3 blank lines in a row.
e5bbd40a 2010-02-18 17:41:15 Clean up formatting: use tabs, not 8-spaces, to indent.
d4de062e 2010-02-10 17:19:18 Add an arc4random implementation for use by evdns Previously, evdns was at the mercy of the user for providing a good entropy source; without one, it would be vulnerable to various active attacks. This patch adds a port of OpenBSD's arc4random() calls to Libevent [port by Chris Davis], and wraps it up a little bit so we can use it more safely.
1dd7e6dc 2010-02-05 01:16:23 Remove the 'flags' argument from evdns_base_set_option() The 'flags' argument made sense when passed to evdns_(base_)?parse_resolv_conf when it said which parts of the resolv.conf file to obey. But for evdns_set_option(), it was really silly, since you wouldn't be calling evdns_set_option() unless you actually wanted to set the option. Its meaning was basically, "set this to DNS_OPTIONS_ALL unless you want a funny surprise." evdns_base_set_option was new in 2.0.1-alpha, so we aren't committed to keeping it source-compatible.
a7a94310 2010-02-03 23:49:22 Fix some additional -DUNICODE issues on win32. Brodie's patch didn't catch the ones that were new since 1.4.
000a33ec 2010-02-03 23:27:40 Make Libevent 1.4.12 build on win32 with Unicode enabled. This patch fixes calls to the win32 api to explicitly call the char* versions of the functions. This fixes build failures when libevent is built with the UNICODE define.
da6135e3 2010-02-03 02:09:19 Reduce windows header includes in our own headers. It turns out that absolutely everything that was including windows.h was doing so needlessly; our headers don't need it, so we should just include winsock2.h (since that's where struct timeval is defined). Pre-2.0 code will use the old headers, which include windows.h for them, so we aren't breaking source compatibility with 1.4. This solves the bug where we were leaving WIN32_LEAN_AND_MEAN defined, in roughly the same way that buying an automobile solves the question of what to give your coachman for boxing day.
439aea0d 2010-01-25 14:07:01 Try to untangle the logic in server_port_flush(). The logic that prevented the first loop in this function from being infinite was rather confusing and hard to follow. It seems to confuse some automatic analysis tools as well as me. Let's try to replace it with something more comprehensible.
a19b4a05 2010-01-25 13:38:07 Call event_debug_unassign on internal events I don't expect that many users will be so religious about calling unassign, but we need to be so that it's at least possible to use debug mode without eating memory.
e2ca403f 2010-01-23 16:23:45 Make it compile under gcc --std=c89.
ff3f6cd4 2010-01-22 16: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.
8d4aaf90 2010-01-20 12: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.
66c02c78 2010-01-08 04: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.
72dd6667 2009-12-07 17: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.
0546ce11 2009-12-30 05:03:54 Eradicated the last free() call. Let mm_free() take care of deallocation.
1e56a32d 2009-12-29 16: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.
ee4953f8 2009-12-29 16: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.
c51bb3c3 2009-12-21 16:36:40 Fix a few locking issues on windows.
2b7abf03 2009-12-04 13:49:27 Merge commit 'niels/dnscrash'
6c7c5799 2009-12-04 10:44:46 Fix a crash when reading badly formatted resolve.conf; from Yasuoka Masahiko
0cd3bb9f 2009-11-27 17: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."
2df1f82b 2009-11-27 16: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().
76cd2b70 2009-11-27 16: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.
347952ff 2009-11-27 15: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.
91fe23fc 2009-11-20 15:46:04 Tolerate code that returns from a fatal_cb. Also, replace more abort() calls with EVUTIL_ASSERT() or event_errx.
767eb70f 2009-11-18 21:16:33 Fix compilation with threading disabled. svn:r1546
86f57420 2009-11-16 22: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
72bafc17 2009-11-16 22:23:55 Remove the stupid brokenness where DNS option names needed to end with a colon. svn:r1536
18a8cfac 2009-11-15 19:00:12 Prefer calloc(a,b) to malloc(a*b). via openbsd. svn:r1531
e2b2de79 2009-11-15 18:59:48 Use arc4random() for dns transaction ids where available. Patch taken from OpenBSD svn:r1528
784b8773 2009-11-06 21: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
d2e7e65d 2009-11-05 22:19:09 Move the evdns sample code into the sample directory and fix it not to use any deprecated APIs. svn:r1511
25a5e681 2009-11-05 20:37:19 Build fixes for MSVC svn:r1506
0b9eb1bf 2009-11-03 20: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
2e36dbe1 2009-10-26 20:00:43 Use EVUTIL_ASSERT() consistently instead of assert. svn:r1464
e3fd294a 2009-10-16 13:19:57 Spelling fixes in comments and strings. svn:r1445
fc83ca3c 2009-10-14 00:46:40 Fix some crash bugs when initializing evdns svn:r1443
213dc2a2 2009-08-03 20:15:32 Fix an annoying evdns crash bug, and add more unit tests for evdns. svn:r1406
621aafd2 2009-07-30 22:11:23 Export sockaddr comparison functionality. svn:r1400
7c20a6ae 2009-07-30 17:01:21 Export an ev_socklen_t. svn:r1391
72ea534f 2009-07-28 19:41:57 Export evutil_str[n]casecmp as evutil_ascii_str[n]casecmp. svn:r1387
5b5b880b 2009-07-28 19:41:39 Various MSVC cleanups from Brodie Thiesfield. svn:r1385
12199fa7 2009-07-28 17: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
b06b2649 2009-07-26 01: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
670658eb 2009-07-21 18:32:57 Correct the signatures for evdns_configure_windows_nameservers(), now that it is exposed. svn:r1369
e83a32df 2009-07-14 19:31:20 Do not define _FORTIFY_SOURCE if the platform GCC already defined it for us. svn:r1346
342ad355 2009-06-30 14:23:18 The truncated bit is in the 3rd byte of a dns reply, not the 4th. [fwd-port] svn:r1332
f901f986 2009-06-24 22:40:15 When our IP address changes, do not break all existing dns server sockets. Patch from Christopher Davis svn:r1329
7289d7f8 2009-05-22 18: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
f11dff2c 2009-05-07 03:45:51 Add and use locale-independent strcasecmp functions. svn:r1280
7b24d72a 2009-05-02 16:22:55 Remove some duplicated includes in evdns.c svn:r1265
e865eb93 2009-05-01 00:54:14 More msvc build tweaks. svn:r1262
1ad03264 2009-04-23 18:04:50 Fix win32 compilation issues. svn:r1234
9516df0e 2009-04-23 05: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
2d9619d7 2009-04-19 01:59:09 Make dns callbacks run deferred svn:r1205
327165b3 2009-04-19 01:58:54 Add locks to evdns. svn:r1204
ac3fc991 2009-04-19 01:58:41 Use new-style headers in evdns.c svn:r1203
684c022a 2009-04-06 20: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
d2e9caa6 2009-04-06 20: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
0f3c0983 2009-04-05 17:50:18 Fix a double-delete on the request timeout event. Port from Tor. svn:r1138
d0a9c90e 2009-02-11 17:29:17 Fix some of the crazier indentation and tabbing choices in evdns.c svn:r1120
77c80b8d 2009-02-11 17:24:11 New bind-to option to allow DNS clients to bind to arbitrary ports for their outgoing addresses. svn:r1119
acaf65c3 2009-02-11 17:23:32 Make evutil_parse_sockaddr_port give a useful socket-length output. svn:r1118
f2a24d6e 2009-02-11 17:22:40 Better comments for some confusing-to-me code. svn:r1117
c6f4dc98 2009-02-11 17:21:48 Port some evdns changes over from Tor. svn:r1116
cd731b77 2009-02-10 21: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
1ed27048 2009-02-10 21:39:56 Stop rolling our own offsetof twice. svn:r1113
f04b90e5 2009-02-10 19:43:19 Make a couple of newer evdns functions more bulletproof. svn:r1112
4d92e426 2009-02-02 19:22:27 forward-port: Make evdns_resolve_reverse args const. svn:r1096
52eb4951 2009-01-31 07: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
2546ea66 2009-01-31 05: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
e3e696c8 2009-01-28 20:24:12 Use size_t for name length in DNS requests. Not that it matters much. svn:r1066
8889a770 2009-01-27 22:30:46 Replace all use of config.h with event-config.h. svn:r1064
9993137c 2009-01-27 21:10:31 Remove all trailing whitespace in all the source files. svn:r1063
2b1d535e 2009-01-26 17:29:27 Accept evutil_socket_t for evdns_server_ports. svn:r1053
9935d5b0 2009-01-13 21:39:32 Fix win32 compilation. Surprisingly, unit tests pass too. svn:r1002
169321c9 2009-01-13 20:26:37 Rename four internal headers to follow the -internal.h convention. svn:r1000
81ab45ad 2009-01-13 19: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
980bcd68 2009-01-02 21:21:58 Work better with platforms that do not have ipv6 structures, or that do not have sin_len fields, etc. svn:r986