1869 Commits

Author SHA1 Message Date
Nick Mathewson
2b44dccaaf Add options to test-ratelim.c to check its results
The new options let you specify a maximum deviation of bandwidth used
from expected bandwidth used, and make test-ratelim.c exit with a
nonzero status when those deviations are violated.

This patch also adds a test-ratelim.sh script to run test-ratelim with
a few sensible options for testing.
2010-05-13 15:40:43 -04:00
Nick Mathewson
218a3c372c Do not check that event_base is set in EVBASE_ACQUIRE_LOCK
In every place that we call EVBASE_ACQUIRE_LOCK, the base is either
set, or must be set, so the test is redundant.
2010-05-13 15:40:43 -04:00
Nick Mathewson
fdfc3fc502 Remove the now-unusable EVTHREAD_LOCK/UNLOCK constants 2010-05-13 15:40:43 -04:00
Nick Mathewson
33bbbed9dd Mark the event_err() functions as __attribute__((noreturn))
This attribute tells gcc (and anything else that understands gcc
attributes) that the functions will never return control, and helps
the optimizer a little.  With luck, it will also tell
less-than-full-program dataflow analysis tools that they don't need to
worry about any code path that involves calling one of these functions
and then returning.

This patch also forces event_exit() to always exit, no matter what the
user-supplied fatal_callback does.  This means that the old unit tests
for the event_err* functions don't work any more, since they assume it
is safe to call event_err* if you've given it a bogus fatal_callback
that doesn't exit.  Instead, we have to make the unit tests fork
before calling event_err(), and have the main unit test process wait
for the event_err() test to exit with a sane exit code.  On unix,
that's trivial.  On windows, let's not bother and just assume that
event_err* works.
2010-05-13 15:39:02 -04:00
Nick Mathewson
dfb75ab207 Test the unlocked-deferred callback case of bufferevents 2010-05-12 15:38:28 -04:00
Nick Mathewson
c5bab56002 Remove the obsolete evthread interfaces
These were added in 2.0.1, and deprecated in 2.0.4 and 2.0.5; we've
promised that they would be removed, and warned whenever they were
invoked.  Users should call evthread_set_lock_callbacks instead...  or
ideally just call evthread_use_windows_threads or
evthread_use_pthreads.
2010-05-11 11:44:07 -04:00
Nick Mathewson
9cb5bc86a9 Bump version to 2.0.5-beta-dev 2010-05-10 14:51:32 -04:00
Nick Mathewson
ad9b7f153d Increment version numbers for 2.0.5-beta release-2.0.5-beta 2010-05-09 00:22:08 -04:00
Nick Mathewson
f6aaf176d2 Add a changelog for 2.0.5-beta 2010-05-09 00:16:35 -04:00
Nick Mathewson
7c519dfd4f Fix some autoconf issues on OpenBSD
Issue 1: autoconf gets accept when a header works properly with cpp
but not with cc.  This was true of the sys/sysctl.h header on
openbsd.  The fix: include sys/param.h (if present) when testing for
sys/sysctl.h

Issue 2: Somehow, autoconf's macro generation code is messed up on
some versions of openbsd (including mine, and other people's too) so
that instead of SIZEOF_VOID_P, it makes SIZEOF_VOID__.
evutil/util.h now works around that.
2010-05-08 23:31:35 -04:00
Nick Mathewson
c1cd32a156 Define _REENTRANT as needed on Solaris, elsewhere
It turns out that _REENTRANT isn't only needed to make certain
functions visible; we also need it to make pthreads work properly
some places (like Solaris, where forgetting _REENTRANT basically
means that all threads are sharing the same errno).  Fortunately,
our ACX_PTHREAD() configure macro already gives us a PTHREAD_CFLAG
variable, so all we have to do is use it.
2010-05-08 22:21:52 -04:00
Nick Mathewson
3d9e05b174 Fix test.sh on freebsd
It turns out that in all conformant shells, "unset FOO" removes FOO
both from the shell's variables and from the exported environment.
(I've tested this on msys, opensolaris, linux, osx, and freebsd.)

And in nearly every shell I can find, "unset FOO; export FOO" does
the same as unset FOO... except in my FreeBSD VM, where the "export
FOO" sets the exported value of FOO equal to "".  This broke test.sh
for us.

The fix is simple: remove the needless exports!
2010-05-08 19:56:25 -04:00
Nick Mathewson
0ee6f6ce80 Make test.sh support mingw/msys on win32
This required:
   - Adding another WIN32 section in test.sh
   - not running "touch /dev/null"
   - calling WSAStartup in all the test binaries
   - Fixing a dumb windows-only bug in test-time.c
2010-05-08 19:38:30 -04:00
Nick Mathewson
935e1504b1 Fix whitespace in evutil.c 2010-05-08 19:36:05 -04:00
Nick Mathewson
3557071698 Fix another nasty solaris getaddrinfo() behavior
Everybody else thinks that when you getaddrinfo() on an ip address
and don't specify the protocol and the socktype, it should give you
multiple answers , one for each protocol/socktype implementation.

OpenSolaris takes a funny view of RFC3493, and leaves the results set
to 0.

This patch post-processes the getaddrinfo() results for consistency.
2010-05-08 19:34:10 -04:00
Nick Mathewson
2cf2a286e4 Fix getaddrinfo with protocol unset on Solaris 9. Found by Dagobert Michelsen
Apparently when you call Solaris 9's getaddrinfo(), it likes to leave
ai_protocol unset in the result. This is no way to behave, if I'm
reading RFC3493 right.

This patch makes us check for a getaddrinfo() that's broken in this way,
and work around it by trying to infer socktype and protocol from one
another.

Partial bugfix for 2987542
2010-05-08 19:34:09 -04:00
Nick Mathewson
c44de06c76 Numerous opensolaris compilation fixes
For future note, opensolaris doesn't have sys/sysctl.h, doesn't like
comparing iov_buf to a chain_space_ptr without a cast, and is (predictably)
unforgiving of dumb syntax errors.

Also, we had accidentally broken the devpoll backend test in configure.in
2010-05-08 19:34:09 -04:00
Nick Mathewson
f89168e7ea Make test for bufferevent_connect_hostname system-neutral
Previously, the be5_outcome field for the dns error would be set to
something dependent on our system resolver.  It turns out that you
can't rely on nameservers to really give you an NEXIST answer for
xyz.example.com nowadays: too many of them are annoyingly broken and
like to redirect you to their locked-in portals.  This patch changes
the bufferevent_connect_hostname test so that it makes sure that the
dns_error of be5_outcome is "whatever you would get from resolving
the target hostname"
2010-05-08 19:15:35 -04:00
Nick Mathewson
88a543fc19 Make unit test for add_file able to tell "error" from "done"
Importantly, we don't actually want to call evbuffer_write() when
the buffer is empty.  This makes it an error to ever get a -1 return
value from evbuffer_add_file(), which makes it safe for us to test
the return value.
2010-05-08 19:15:35 -04:00
Nick Mathewson
384d124581 Fix bench_http build on win32. 2010-05-08 17:15:52 -04:00
Nick Mathewson
05de45d63f add more (currently skipped) add_file tests on win32 2010-05-08 16:47:17 -04:00
Nick Mathewson
ad811cdc2b Fix unused-variable warning when building with threads disabled 2010-05-08 16:41:01 -04:00
Nick Mathewson
dcdae6b743 Make evbuffer_add_file() work on windows
Right now only the add_file() mode is supported, when it would be
nicer to have mmap support.  Perhaps for Libevent 2.1.x.
2010-05-08 16:34:18 -04:00
Nick Mathewson
b4f12a17aa Implement regress_make_tempfile on win32 to test evbuffer_add_file
(Conclusion: evbuffer_add_file is broken on win32, since it
uses recv on a file.)
2010-05-08 16:14:20 -04:00
Nick Mathewson
90d4225137 Fix some crazy macro mistakes in arc4random.c 2010-05-08 15:31:54 -04:00
Nick Mathewson
f37cd4c227 Detect broken unsetenv at unit-test runtime
If we have an unsetenv function that doesn't work, we can't run the
main/base_environ unit test, so we should skip it.
2010-05-08 14:36:59 -04:00
Nick Mathewson
fdc629736e Only add libevent_core.la to LIBADD on mingw
Chris Davis reports that this is also necessary to fix building with
shared libraries on OSX for him.  Should fix bug 2997775.

There is probably a better fix for the issues solved by commit
3cbca8661f, but for now, we're trying to get a beta out the door.
2010-05-08 14:21:48 -04:00
Nick Mathewson
25433b96dc Only specify -no-undefined on mingw
It turns out that commit 3cbca8661f broke building with shared
libraries on OSX.  Since -no-undefined is only necessary on platforms
like win32, only use it there.

There may be a better fix for this.  Should fix bug 2997775.
2010-05-06 14:37:23 -04:00
Nick Mathewson
a62c843340 Merge commit 'chrisd/connect-hostname-report-err' 2010-05-06 14:16:50 -04:00
Nick Mathewson
7731ec8828 Stop distributing and installing manpages: they were too inaccurate
It would be great to have the manpages come back some time, perhaps
from a refactoring of my asciidoc book, but for now the existing
manpages were the single worst, most incomplete, and most misleading
libevent documentation we had.  (Less misleading: the doxygen output,
the header files, and my reference book.)
2010-05-06 13:26:05 -04:00
Nick Mathewson
c16e68448c Rename current_base symbol to event_global_current_base_
The "current_base" symbol was never actually declared in an exported
header; it's hideously deprecated, and it was the one remaining
exported symbol (fwict) that was prefixed with neither ev nor
bufferevent nor _ev nor _bufferevent.

codesearch.google.com turns up no actual attempts to use our
current_base from outside libevent.
2010-05-04 13:27:36 -04:00
Nick Mathewson
99e50e90bd Fix symbol conflict between mm_*() macros and libmm
Our mm_malloc, mm_calloc, etc functions were all exported, since C
hasn't got a nice portable way to say "we want to use this function
inside our library but not export it to others".  But they apparently
conflict with anything else that calls its symbols mm_*, as libmm does.

This patch renames the mm_*() functions to event_mm_*_(, and defines
maros in mm_internal so that all the code we have that uses mm_*()
will still work.  New code should also prefer the mm_*() macro names.

Reported by Gernot Tenchio.  Fixes sf bug 2996541
2010-05-04 12:57:40 -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
Frank Denis
71afc52580 Fix nonstandard TAILQ_FOREACH_REVERSE() definition
Every current BSD system providing TAILQ_* macros define
TAILQ_FOREACH_REVERSE in this order:

TAILQ_FOREACH_REVERSE(var, head, field, headname)

However, libevent defines it in another order:

TAILQ_FOREACH_REVERSE(var, head, headname, field)

Here's a trivial patch to have libevent compatible with stock queue.h headers.

-Frank.

[From sourceforge patch 2995179. codesearch.google.com confirms that
the only people defining TAILQ_FOREACH_REVERSE our way are people
using it in a compatibility header like us.  Did we copy this from
OpenSSH or something?]

-Nick
2010-05-03 11:40:09 -04:00
Frank Denis
953e2290fc Refuse null keys in evhttp_parse_query()
evhttp_parse_query() currently accepts empty keys, that don't make any
sense.

-Frank

[From sourceforge patch 2995183]
-Nick
2010-05-03 11:39:40 -04:00
Sebastian Hahn
bd1ed5f3c5 Fix a compile warning introduced in 739e688 2010-05-02 12:52:06 +02:00
Pierre Phaneuf
739e688275 Allow empty reason line in HTTP status 2010-04-28 21:33:13 -07:00
Nick Mathewson
50ec59f4a6 Remove redundant checks for lock!=NULL before calling EVLOCK_LOCK
The EVLOCK_LOCK and EVLOCK_UNLOCK macros already check to make sure
that the lock is present before messing with it, so there's no point
in checking the lock before calling them.

A good compiler should be able to simplify code like
  if (lock) {
     if (lock)
        acquire(lock);
  }
, but why count on it?
2010-04-28 15:16:32 -04:00
Nick Mathewson
40c301b76c Fix compilation when openssl support is disabled
Previously, we'd fail if OpenSSL was present but openssl support was
disabled.  Now we don't.
2010-04-28 14:56:51 -04:00
Nick Mathewson
9ecf0d486d Catch attempts to enable debug_mode too late
Debug mode needs to be enabled before any event is setup or any
event_base is created.  Otherwise, we will not have recorded when events
were first setup or added, and so it will look like a bug later when we
delete or free them.

I have already confused myself because of this requirement, so let's
make Libevent catch it for the next poor forgetful developer like me.
2010-04-28 12:20:23 -04:00
Nick Mathewson
cb6707405c Make debug mode catch mixed ET and non-ET events on an fd
Of the backends that support edge-triggered IO, most (all?) do not
support attempts to mix edge-triggered and level-triggered IO on the
same FD.  With debugging mode enabled, we now detect and refuse attempts
to add a level-triggered IO event to an fd that already has an
edge-triggered IO event, and vice versa.
2010-04-28 12:20:18 -04:00
Joachim Bauch
a5208fe422 Release locks on bufferevents while executing callbacks
This fixes a dead lock for me where bufferevents in different event
loops use each other and access their input/output buffers (proxy-like
scenario).
2010-04-27 14:24:38 -04:00
Christopher Davis
0ef407065e Report DNS error when lookup fails during bufferevent_socket_connect_hostname. 2010-04-24 00:06:38 -07:00
Nick Mathewson
25c442e582 Merge branch 'rpc_leaks' 2010-04-24 00:15:15 -04:00
Nick Mathewson
601a3ff98c Merge branch 'arc4seed' 2010-04-24 00:01:31 -04:00
Nick Mathewson
f6ab2a2811 Fix a memory leak when unmarshalling RPC object arrays
The old code would use type_var_add() for its side-effect of expanding the
array, then leak the new object that was added to the array.

The new code adds a static function to handle the array resizing.
2010-04-23 23:55:30 -04:00
Nick Mathewson
94ee1251cb fix a leak when unpausing evrpc requests 2010-04-23 23:55:03 -04:00
Nick Mathewson
96730d3191 Make http_base_test stop leaking an event_base. 2010-04-23 23:13:26 -04:00
Nick Mathewson
d49b92a835 Remove one last bug in last_with_datap logic. Found with valgrind 2010-04-23 23:04:20 -04:00
Niels Provos
9d8edf2ff5 do not leak the request object on persistent connections 2010-04-23 18:59:22 -07:00