97 Commits

Author SHA1 Message Date
Nick Mathewson
b647e0bc94 Merge remote branch 'kev009/21_ac_use_system_extensions' 2011-01-07 12:31:30 -05:00
Kevin Bowling
0915ca0aa6 Include evconfig-private.h in internal files for great good. 2011-01-02 08:43:45 -07:00
Nick Mathewson
cb8059d2d3 Fix compilation on Windows with NDEBUG
Dongsheng Song reports that when building on windows with NDEBUG, you
run into an attempt to do EVUTIL_ASSERT(x) where x is a bitfield,
which turns into _EVUTIL_NIL_CONDITION(x), which takes sizeof(x),
which is illegal.  This patch fixes _EVUTIL_NIL_CONDITION to work on
bitfields too.
2011-01-02 00:56:01 -05:00
Evan Jones
b63ab1776b EVUTIL_ASSERT: Use sizeof() to avoid "unused variable" warnings. 2010-12-14 00:14:07 -05:00
Nick Mathewson
145f221e8f Define symbolic constants to use in place of SHUT_RD etc 2010-10-05 13:06:32 -04:00
Nick Mathewson
d49b5e3326 Do not search outside of the system directory for windows DLLs
Hardens against some attacks.
2010-09-27 15:45:34 -04:00
Nick Mathewson
1fdec20f8f Stop using global arrays to implement the EVUTIL_ctype functions
These apparently made libtool sad on win32, and the function call
overhead here should be negligable anyway.
2010-09-01 15:01:39 -04:00
Nick Mathewson
743f866539 Honor NDEBUG; build without warnings with NDEBUG; make NDEBUG always-off in unit test code 2010-08-23 11:49:06 -04:00
Nick Mathewson
ec347b9225 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.
2010-08-06 20:21:27 -04:00
Nick Mathewson
57b30cd7cc Turn our socketpair() replacement into its own function
This patch splits the formerly windows-only case of evutil_socketpair()
into an (internal-use-only) function named evutil_ersatz_socketpair(), and
makes it build and work right on non-Windows hosts.

We need this for convenience to test sendfile on solaris, where socketpair
can't give you an AF_INET pair, and sendfile() won't work on AF_UNIX.
2010-08-06 13:01:32 -04:00
Nick Mathewson
20fda296c5 Try /proc on Linux as entropy fallback; use sysctl as last resort
It turns out that the happy fun Linux kernel is deprecating sysctl,
and using sysctl to fetch entropy will spew messages in the kernel
logs.  Let's not do that.  Instead, let's call sysctl for our
entropy only when all other means fail.

Additionally, let's add another means, and try
/proc/sys/kernel/random/uuid if /dev/urandom fails.
2010-05-03 13:00:00 -04:00
Nick Mathewson
b1c795007f 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.
2010-04-23 14:42:25 -04:00
Christopher Davis
850c3ff232 Add evutil_tv_to_msec for safe conversion of timevals to milliseconds.
This is useful for backends that require their timeout values be in
milliseconds.
2010-03-31 23:38:34 -07:00
Nick Mathewson
2c2618d858 more whitespace normalization 2010-03-05 13:00:15 -05:00
Nick Mathewson
17efc1cdfa Update all our copyright notices to say "2010" 2010-03-04 01:38:48 -05:00
Niels Provos
7bc48bfd3a deal with connect() failing immediately 2010-02-27 18:59:06 -08:00
Nick Mathewson
e5bbd40ad7 Clean up formatting: use tabs, not 8-spaces, to indent. 2010-02-18 17:44:09 -05:00
Nick Mathewson
8fdf09c09d Clean up formatting: Disallow space-before-tab. 2010-02-18 17:08:50 -05:00
Nick Mathewson
aba1fff33a Add EV_*_MAX macros to event2/util.h to expose limits for ev_* types. 2010-02-03 14:37:42 -05:00
Nick Mathewson
918e9c5e72 Fix a number of warnings from gcc -pedantic 2010-01-23 16:38:36 -05:00
Nick Mathewson
8d4aaf9086 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.
2010-01-20 12:56:54 -05:00
Nick Mathewson
0f7144fd8b Refactor code from evdns into a new internal "read a file" function. 2010-01-08 19:36:35 -05:00
Nick Mathewson
eaaf27f1f7 Enable branch-prediction hints with EVUTIL_UNLIKELY.
This had been accidentally disabled.  Since it seems to work with GCC, I'm
turning it back on when GCC is present.
2010-01-06 18:50:19 -05:00
Nick Mathewson
165d30e31a Fix compilation of rate-limiting code on win32. 2009-12-30 14:29:56 -05: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
629a613398 When running set[ug]id, don't check the environment.
Idea from OpenBSD, but made a bit more generic to handle uncivilized lands
that do not define issetugid.

svn:r1530
2009-11-15 18:59:59 +00:00
Nick Mathewson
47bad8abb7 Implement size limits on HTTP header length and body length.
Patch from Constantine Verutin, simplified a little.

svn:r1500
2009-11-04 20:17:32 +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
8283b2f0dc Fix a major parenthesis bug in EVUTIL_UPCAST.
Fortunately, this didn't hurt anything previously, since we had no actual users of the macro where the offset of the base type wasn't 0.

svn:r1488
2009-11-02 19:30:25 +00:00
Nick Mathewson
37c3456d70 Add an EVUTIL_ASSERT() to replace our calls to assert().
The big difference here is that EVUTIL_ASSERT() passes its message on
via event_errx() before aborting, so that the application has a prayer
of noticing and recording it.

svn:r1463
2009-10-26 20:00:08 +00:00
Nick Mathewson
25af695441 When a bufferevent_connect() call fails, give the client an error callback.
Patch from Christopher Davis.

svn:r1444
2009-10-14 00:46:47 +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
709c21c48c Bufferevent support for openssl.
This code adds a new Bufferevent type that is only compiled when the
openssl library is present.  It supports using an SSL object and an
event alert mechanism, which can either be an fd or an underlying
bufferevent.

There is still more work to do: the unit tests are incomplete, and we
need to support flush and shutdown much better.  Sometimes events are
generated needlessly: this will hose performance.

There's a new encrypting proxy in sample/le-proxy.c.

This code has only been tested on OSX, and nowhere else.

svn:r1382
2009-07-28 04:03:57 +00:00
Nick Mathewson
0b22ca1929 Use ev_ssize_t in place of ssize_t *everywhere*.
svn:r1309
2009-05-22 19:11:48 +00:00
Nick Mathewson
f11dff2c7a Add and use locale-independent strcasecmp functions.
svn:r1280
2009-05-07 03:45:51 +00:00
Nick Mathewson
b2e8fd0e41 Apparently MSVC lacks a ssize_t. Define an ev_ssize_t for headers, and make ssize_t work elsewhere.
svn:r1261
2009-04-30 23:56:53 +00:00
Nick Mathewson
ebf294559e Compilation fixes for vc++ 2008 express. Not the end of them.
svn:r1260
2009-04-30 23:49:15 +00:00
Nick Mathewson
838d0a81c3 Document many internal functions and pieces of code.
svn:r1181
2009-04-17 06:55:08 +00:00
Nick Mathewson
0b47b125cf Add a new EVUTIL_UPCAST macro so that I do not need to keep figuring out the right offsetof magic over and over.
svn:r1160
2009-04-12 22:02:54 +00:00
Nick Mathewson
bbd6a332e1 reindent macros in util-internal.h
svn:r1159
2009-04-12 22:02:12 +00:00
Nick Mathewson
661b5eea09 Actually, move EVUTIL_NIL_STMT to util-internal.h
svn:r1135
2009-04-05 04:10:05 +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
Nick Mathewson
7dd362b158 Have util-internal.h define socklen_t if we need it, and include it appropriately. This fixes win32 compilation.
svn:r1070
2009-01-29 15:09:24 +00:00
Nick Mathewson
b85b710cf5 Update copyright statements to reflect the facts that:
a) this is 2009
b) niels and nick have been comaintainers for a while
c) saying "all rights reserved" when you then go on to explicitly
   disclaim some rights is sheer cargo-cultism.

svn:r1065
2009-01-27 22:34:36 +00:00
Nick Mathewson
9935d5b01e Fix win32 compilation. Surprisingly, unit tests pass too.
svn:r1002
2009-01-13 21:39:32 +00:00
Nick Mathewson
574d320217 There is no WSAEAGAIN. There is only Zuul^WSAEWOULDBLOCK.
svn:r1001
2009-01-13 20:50:34 +00:00
Nick Mathewson
5ebd23ad74 New EVUTIL_ERR_*_RETRIABLE macros to tell if an errno blocked or failed.
svn:r994
2009-01-13 19:19:50 +00:00