182 Commits

Author SHA1 Message Date
Nick Mathewson
ee4953f89e 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.
2009-12-29 16:03:30 -05:00
unknown
c51bb3c342 Fix a few locking issues on windows. 2009-12-21 16:36:40 -05:00
Nick Mathewson
2b7abf038f Merge commit 'niels/dnscrash' 2009-12-04 13:49:27 -05:00
Yasuoka Masahiko
6c7c5799a4 Fix a crash when reading badly formatted resolve.conf; from Yasuoka Masahiko 2009-12-04 10:44:46 -08:00
Nick Mathewson
0cd3bb9f3a 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."
2009-11-27 17:36:51 -05:00
Zhuang Yuyao
2df1f82bfa 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().
2009-11-27 17:36:51 -05:00
Nick Mathewson
76cd2b70bb 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.
2009-11-27 17:36:51 -05:00
Nick Mathewson
347952ffe0 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.
2009-11-27 17:36:24 -05:00
Nick Mathewson
91fe23fc08 Tolerate code that returns from a fatal_cb.
Also, replace more abort() calls with EVUTIL_ASSERT() or event_errx.
2009-11-20 15:46:04 -05:00
Nick Mathewson
767eb70f50 Fix compilation with threading disabled.
svn:r1546
2009-11-18 21:16:33 +00:00
Nick Mathewson
86f5742015 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
2009-11-16 22:25:46 +00:00
Nick Mathewson
72bafc175a Remove the stupid brokenness where DNS option names needed to end with a
colon.

svn:r1536
2009-11-16 22:23:55 +00:00
Nick Mathewson
18a8cfac39 Prefer calloc(a,b) to malloc(a*b). via openbsd.
svn:r1531
2009-11-15 19:00:12 +00:00
Nick Mathewson
e2b2de79bf Use arc4random() for dns transaction ids where available. Patch taken from OpenBSD
svn:r1528
2009-11-15 18:59:48 +00:00
Nick Mathewson
784b8773a4 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
2009-11-06 21:46:57 +00:00
Nick Mathewson
d2e7e65d21 Move the evdns sample code into the sample directory and fix it not to use any deprecated APIs.
svn:r1511
2009-11-05 22:19:09 +00:00
Nick Mathewson
25a5e6819d Build fixes for MSVC
svn:r1506
2009-11-05 20:37:19 +00:00
Nick Mathewson
0b9eb1bffb 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
2009-11-03 20:40:48 +00:00
Nick Mathewson
2e36dbe1a6 Use EVUTIL_ASSERT() consistently instead of assert.
svn:r1464
2009-10-26 20:00:43 +00:00
Nick Mathewson
e3fd294a6d Spelling fixes in comments and strings.
svn:r1445
2009-10-16 13:19:57 +00:00
Nick Mathewson
fc83ca3c70 Fix some crash bugs when initializing evdns
svn:r1443
2009-10-14 00:46:40 +00:00
Nick Mathewson
213dc2a2ef Fix an annoying evdns crash bug, and add more unit tests for evdns.
svn:r1406
2009-08-03 20:15:32 +00:00
Nick Mathewson
621aafd27a Export sockaddr comparison functionality.
svn:r1400
2009-07-30 22:11:23 +00:00
Nick Mathewson
7c20a6ae52 Export an ev_socklen_t.
svn:r1391
2009-07-30 17:01:21 +00:00
Nick Mathewson
72ea534f8e Export evutil_str[n]casecmp as evutil_ascii_str[n]casecmp.
svn:r1387
2009-07-28 19:41:57 +00:00
Nick Mathewson
5b5b880be7 Various MSVC cleanups from Brodie Thiesfield.
svn:r1385
2009-07-28 19:41:39 +00:00
Nick Mathewson
12199fa7a5 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
2009-07-28 17:11:03 +00:00
Nick Mathewson
b06b2649b4 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
2009-07-26 01:29:39 +00:00
Nick Mathewson
670658ebd7 Correct the signatures for evdns_configure_windows_nameservers(), now that it is exposed.
svn:r1369
2009-07-21 18:32:57 +00:00
Nick Mathewson
e83a32dfe1 Do not define _FORTIFY_SOURCE if the platform GCC already defined it for us.
svn:r1346
2009-07-14 19:31:20 +00:00
Nick Mathewson
342ad3550b The truncated bit is in the 3rd byte of a dns reply, not the 4th. [fwd-port]
svn:r1332
2009-06-30 14:23:18 +00:00
Nick Mathewson
f901f9867c When our IP address changes, do not break all existing dns server sockets. Patch from Christopher Davis
svn:r1329
2009-06-24 22:40:15 +00:00
Nick Mathewson
7289d7f800 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
2009-05-22 18:20:59 +00:00
Nick Mathewson
f11dff2c7a Add and use locale-independent strcasecmp functions.
svn:r1280
2009-05-07 03:45:51 +00:00
Nick Mathewson
7b24d72ad6 Remove some duplicated includes in evdns.c
svn:r1265
2009-05-02 16:22:55 +00:00
Nick Mathewson
e865eb938c More msvc build tweaks.
svn:r1262
2009-05-01 00:54:14 +00:00
Nick Mathewson
1ad0326440 Fix win32 compilation issues.
svn:r1234
2009-04-23 18:04:50 +00:00
Nick Mathewson
9516df0e2e 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
2009-04-23 05:40:06 +00:00
Nick Mathewson
2d9619d78f Make dns callbacks run deferred
svn:r1205
2009-04-19 01:59:09 +00:00
Nick Mathewson
327165b339 Add locks to evdns.
svn:r1204
2009-04-19 01:58:54 +00:00
Nick Mathewson
ac3fc9913a Use new-style headers in evdns.c
svn:r1203
2009-04-19 01:58:41 +00:00
Nick Mathewson
684c022a21 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
2009-04-06 20:38:42 +00:00
Nick Mathewson
d2e9caa6fc 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
2009-04-06 20:38:19 +00:00
Nick Mathewson
0f3c0983c0 Fix a double-delete on the request timeout event. Port from Tor.
svn:r1138
2009-04-05 17:50:18 +00:00
Nick Mathewson
d0a9c90e93 Fix some of the crazier indentation and tabbing choices in evdns.c
svn:r1120
2009-02-11 17:29:17 +00:00
Nick Mathewson
77c80b8dcf New bind-to option to allow DNS clients to bind to arbitrary ports for their outgoing addresses.
svn:r1119
2009-02-11 17:24:11 +00:00
Nick Mathewson
acaf65c359 Make evutil_parse_sockaddr_port give a useful socket-length output.
svn:r1118
2009-02-11 17:23:32 +00:00
Nick Mathewson
f2a24d6e58 Better comments for some confusing-to-me code.
svn:r1117
2009-02-11 17:22:40 +00:00
Nick Mathewson
c6f4dc987c Port some evdns changes over from Tor.
svn:r1116
2009-02-11 17:21:48 +00:00
Nick Mathewson
cd731b77d7 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
2009-02-10 21:40:12 +00:00