]> granicus.if.org Git - libevent/log
libevent
14 years agoUse less memory for each entry in a hashtable
Nick Mathewson [Mon, 25 Jan 2010 18:44:56 +0000 (13:44 -0500)]
Use less memory for each entry in a hashtable

Our hash-table implementation stored a copy of the hash code in each
element.  But as we were using it, all of our hash codes were
ridiculously easy to calculate: most of them were just a matter of a
load and a shift.

This patch lets ht-internal be built in either of two ways: one caches
the hash-code for each element, and one recalculates it each time it's
needed.

This patch also chooses a slightly better hash code for
event_debug_entry.

14 years agoCall event_debug_unassign on internal events
Nick Mathewson [Mon, 25 Jan 2010 18:38:07 +0000 (13:38 -0500)]
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.

14 years agoAdd support for a "debug mode" to try to catch common errors.
Nick Mathewson [Fri, 22 Jan 2010 05:34:37 +0000 (00:34 -0500)]
Add support for a "debug mode" to try to catch common errors.

Right now it only catches cases where we aren't initializing events,
or where we are re-initializing events without deleting them first.
These are however shockingly common.

14 years agoRemove a needless include of rpc_compat.h
Nick Mathewson [Sat, 23 Jan 2010 21:47:54 +0000 (16:47 -0500)]
Remove a needless include of rpc_compat.h

Nothing in evrpc.c was using rpc_compat.h, so it's best to take it
out, especially since it polluted our build process with GCC variadic
macros.

While we're at it, this patch puts an extra restriction on when the
variadic macros in rpc_compat.h are defined.  Not only must GCC be the
compiler, but GCC must not be running in -ansi mode.

14 years agoFix windows and msvc build
Nick Mathewson [Sun, 24 Jan 2010 01:07:05 +0000 (20:07 -0500)]
Fix windows and msvc build

14 years agoMinimize epoll_ctl calls by using changelist
Nick Mathewson [Sat, 16 Jan 2010 20:24:58 +0000 (15:24 -0500)]
Minimize epoll_ctl calls by using changelist

The logic here is a little complex, since epoll_add must used called exactly
when no events were previously set, epoll_mod must be used when any events
were previously set, and epoll_del only called when the removing all events.

14 years agoFix a number of warnings from gcc -pedantic
Nick Mathewson [Sat, 23 Jan 2010 21:38:36 +0000 (16:38 -0500)]
Fix a number of warnings from gcc -pedantic

14 years agoMake it compile under gcc --std=c89.
Nick Mathewson [Sat, 23 Jan 2010 21:23:45 +0000 (16:23 -0500)]
Make it compile under gcc --std=c89.

14 years agoCheck more internal event_add() calls for failure
Nick Mathewson [Fri, 22 Jan 2010 21:14:49 +0000 (16:14 -0500)]
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.

14 years agoDetect setenv/unsetenv; skip main/base_environ test if we can't fake them.
Nick Mathewson [Tue, 29 Dec 2009 21:38:03 +0000 (16:38 -0500)]
Detect setenv/unsetenv; skip main/base_environ test if we can't fake them.

Previously, we assumed that we would have setenv/unsetenv everywhere
but WIN32, where we could fake them with putenv.  This isn't so: some
other non-windows systems lack setenv/unsetenv, and some of them lack
putenv too.

The first part of the solution, then, is to detect setenv/unsetenv/
putenv from configure.in, and to fake setenv/unsetenv with putenv
whenever we have the latter but not one of the former.

But what should we do when we don't even have putenv?  We could do
elaborate tricks to manipulate the environ pointer, but since we're
only doing this for the unit tests, let's just skip the one test in
question that uses setenv/unsetenv.

14 years agoFix compilation of rate-limit code when threading support is disabled
Nick Mathewson [Fri, 22 Jan 2010 05:34:21 +0000 (00:34 -0500)]
Fix compilation of rate-limit code when threading support is disabled

14 years agoRemove some commented-out code in evutil
Nick Mathewson [Thu, 21 Jan 2010 06:51:40 +0000 (01:51 -0500)]
Remove some commented-out code in evutil

14 years agoDon't use a bind address for nameservers on loopback
Nick Mathewson [Wed, 20 Jan 2010 17:56:54 +0000 (12:56 -0500)]
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.

14 years agoFunctions to access more fields of struct event.
Nick Mathewson [Tue, 19 Jan 2010 19:01:36 +0000 (14:01 -0500)]
Functions to access more fields of struct event.

Once event_assign() or event_new() had been called, there was no way
to get at a copy of the event's callback, callback argument, or
configured events.  This patch adds an accessor function for each, and
an all-fields accessor for code that wants to re-assign one field of
an event.

This patch also adds a function to return sizeof(struct event), so
that code with intense RAM needs can still retain ABI compatibility
between versions of Libevent without having to heap-allocate every
struct event individually.

The code here was first proposed by Pavel Pisa.

14 years agoAdd a LICENSE file so people can find our license easily
Nick Mathewson [Tue, 19 Jan 2010 18:55:53 +0000 (13:55 -0500)]
Add a LICENSE file so people can find our license easily

For what it's worth, we are aware that "Copyright $YEAR $NAME" is
sufficient notice of copyright on software under US law and
Internationally, and saying Copyright (c) $YEAR $NAME is a bit nutty.
The character sequence (c) has never been ruled to have the same force
in US law as the actual copyright symbol, and that neither of these
US-specific symbols adds anything of value beyond saying "Copyright"
since the Berne convention took effect in the US back in 1989.

Similarly, saying "all rights reserved" doesn't do anything magical
unless your software goes in a time-warp back to when the Buenos Aires
Convention was the general rule.  (And what will they run it on back
then?)  And what would even lead you to say "All Rights Reserved" when
you're explicitly granting most of those rights to anybody receiving
the work in accordance with the 3-clause BSD license?

But still the FOSS community retains these ritual notations out of a
kind of cargo-cult lawyering.  Who knows?  Perhaps one day, if we
write our copyright notices ineptly enough, John Frum will come and
give us a DFSG-compatible license that everybody can get behind.

(Also, I am not a lawyer.  The above should not be taken as legal
advice.  -- Nick)

14 years agoAdd a forgotten header (changelist-internal.h)
Nick Mathewson [Fri, 15 Jan 2010 15:26:25 +0000 (10:26 -0500)]
Add a forgotten header (changelist-internal.h)

14 years agoMerge commit 'niels/http_dns'
Nick Mathewson [Fri, 15 Jan 2010 04:28:16 +0000 (23:28 -0500)]
Merge commit 'niels/http_dns'

14 years agoforgot to add void to test function
Niels Provos [Fri, 15 Jan 2010 01:39:54 +0000 (17:39 -0800)]
forgot to add void to test function

14 years agoadd a test for evhttp_connection_base_new with a dns_base
Niels Provos [Fri, 15 Jan 2010 01:05:00 +0000 (17:05 -0800)]
add a test for evhttp_connection_base_new with a dns_base

14 years agomove dns utility functions into a separate file so that we can use them for http...
Niels Provos [Fri, 15 Jan 2010 00:53:25 +0000 (16:53 -0800)]
move dns utility functions into a separate file so that we can use them for http testing

14 years agodo not use a function to assign the evdns base; instead assign it via evhttp_connecti...
Niels Provos [Thu, 14 Jan 2010 23:42:07 +0000 (15:42 -0800)]
do not use a function to assign the evdns base; instead assign it via evhttp_connection_base_new() which is a new function introduced in 2.0

14 years agoRemove kqueue->pend_changes.
Nick Mathewson [Thu, 14 Jan 2010 22:04:08 +0000 (17:04 -0500)]
Remove kqueue->pend_changes.

Since we're no longer writing directly to it from add/del, we don't
need to worry about it changing as kq_dispatch releases the lock.  We
would make it a local variable, except that we wouldn't want to malloc
and free it all the time.

14 years agoMake kqueue use changelists.
Nick Mathewson [Thu, 14 Jan 2010 21:31:05 +0000 (16:31 -0500)]
Make kqueue use changelists.

This fixes a bug in kqueue identified by Charles Kerr and various
Transmission users, where adding and deleting an event in succession
would make the event get reported, even if we didn't actually want to
see it.

Of course, this also makes the array of changes passed to kevent
smaller, which could help performance.

14 years agoChangelist code to defer event changes until just before dispatch
Nick Mathewson [Thu, 14 Jan 2010 21:30:40 +0000 (16:30 -0500)]
Changelist code to defer event changes until just before dispatch

This is necessary or useful for a few reasons:

    1) Sometimes applications will add and delete the same event more
       than once between calls to dispatch.  Processing these changes
       immediately is needless, and potentially expensive (especially
       if we're on a system that makes one syscall per changed event).

       Yes, this actually happens in practice for nonpathological
       code, such as in cases where the user's callback conditionally
       re-adds a non-persistent event, or where draining a buffer
       turns off writing and invokes a user callback which adds more
       data which in turn re-enabled writing.

    2) Sometimes we can coalesce multiple changes on the same fd into
       a single syscall if we know about them in advance.  For
       example, epoll can do an add and a delete at the same time, but
       only if we have found out about both of them before we tell
       epoll.

    3) Sometimes adding an event that we immediately delete can cause
       unintended consequences: in kqueue, this makes pending events
       get reported spuriously.

14 years agoAllow http connections to use evdns for hostname looksups.
Nick Mathewson [Wed, 30 Dec 2009 05:11:27 +0000 (00:11 -0500)]
Allow http connections to use evdns for hostname looksups.

This was as simple as using bufferevent_connect_hostname instead of
calling connect() ourself, which already knows how to use an
evdns_base if it gets one.

Untangling the bind code might be a little trickier.

14 years agoMore unit tests for getaddrinfo_async: v4timeout and cancel.
Nick Mathewson [Thu, 14 Jan 2010 19:46:16 +0000 (14:46 -0500)]
More unit tests for getaddrinfo_async: v4timeout and cancel.

One covers the case where the v4 request times out but the v6 request
doesn't.  The other makes sure that cancelling a request actually works.

14 years agoFix test.sh on shells without echo -n
Nick Mathewson [Tue, 12 Jan 2010 20:58:36 +0000 (15:58 -0500)]
Fix test.sh on shells without echo -n

Some systems have a version of /bin/sh whose builtin echo doesn't
support the -n option used in test/test.sh.  /bin/echo, however,
usually does.  This patch makes us use /bin/echo for echo -n whenever
it is present.

Also, our use of echo -n really only made sense when suppressing all
test output.  Since test output isn't suppressed when logging to a
file, this pach makes us stop using echo -n when logging to a file.

14 years agoAdd a comment on evthread_enable_lock_debuging.
Nick Mathewson [Tue, 12 Jan 2010 01:47:36 +0000 (20:47 -0500)]
Add a comment on evthread_enable_lock_debuging.

14 years agoAdd unit-test for bad_request bug fixed in 1.4 recently.
Pavel Plesov [Tue, 12 Jan 2010 00:04:11 +0000 (19:04 -0500)]
Add unit-test for bad_request bug fixed in 1.4 recently.

This is a partial forward-port from 4fd2dd9d83a000b6.  There's no need
to forward-port the bugfix, since the test passes with http.c as-is.
I believe we fixed this while we were porting evhttp to bufferevent.
--nickm

14 years agoComestic changes in evconnlistener_new(), new_accepting_socket(), accepted_socket_inv...
Jardel Weyrich [Wed, 30 Dec 2009 21:24:39 +0000 (19:24 -0200)]
Comestic changes in evconnlistener_new(), new_accepting_socket(), accepted_socket_invoke_user_cb() and iocp_listener_enable().

14 years agoImproved error handling in evconnlistener_new_async(). Also keeping the fd open becau...
Jardel Weyrich [Wed, 30 Dec 2009 21:22:23 +0000 (19:22 -0200)]
Improved error handling in evconnlistener_new_async(). Also keeping the fd open because it is not opened by this function, so the caller is responsible for closing it. Additionally, since evconnlistener_new_bind() creates a socket and passes it to the function above, it required error checking to close the same socket.

14 years agoFixed a fd leak in start_accepting(), plus cosmetic changes
Jardel Weyrich [Wed, 30 Dec 2009 21:09:14 +0000 (19:09 -0200)]
Fixed a fd leak in start_accepting(), plus cosmetic changes

14 years agoFixed a memory leak on windows threads implementation. The CRITICAL_SECTION was not...
Jardel Weyrich [Fri, 1 Jan 2010 06:13:05 +0000 (04:13 -0200)]
Fixed a memory leak on windows threads implementation. The CRITICAL_SECTION was not being free'd in evthread_win32_lock_free().

14 years agoLook at the proper /etc/hosts file on windows.
Nick Mathewson [Fri, 8 Jan 2010 09:02:19 +0000 (04:02 -0500)]
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.

14 years agoevdns_getaddrinfo() now supports the /etc/hosts file.
Nick Mathewson [Mon, 7 Dec 2009 22:21:41 +0000 (17:21 -0500)]
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.

14 years agoRefactor code from evdns into a new internal "read a file" function.
Nick Mathewson [Mon, 7 Dec 2009 22:21:13 +0000 (17:21 -0500)]
Refactor code from evdns into a new internal "read a file" function.

14 years agoEnable branch-prediction hints with EVUTIL_UNLIKELY.
Nick Mathewson [Wed, 6 Jan 2010 23:41:46 +0000 (18:41 -0500)]
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.

14 years agoFix byte counts when mixing deferred and non-deferred evbuffer callbacks.
Nick Mathewson [Wed, 6 Jan 2010 23:42:59 +0000 (18:42 -0500)]
Fix byte counts when mixing deferred and non-deferred evbuffer callbacks.

This patch finishes 390e0561, which was somehow committed in a half-finished
state.  It solves a failing unit test on windows.

14 years agoMerge branch 'ratelimit'
Nick Mathewson [Wed, 6 Jan 2010 22:59:44 +0000 (17:59 -0500)]
Merge branch 'ratelimit'

Conflicts:
bufferevent_async.c

14 years agoEradicated the last free() call. Let mm_free() take care of deallocation.
Jardel Weyrich [Wed, 30 Dec 2009 07:03:54 +0000 (05:03 -0200)]
Eradicated the last free() call. Let mm_free() take care of deallocation.

14 years agoFix compilation of rate-limiting code on win32.
Nick Mathewson [Wed, 30 Dec 2009 19:29:56 +0000 (14:29 -0500)]
Fix compilation of rate-limiting code on win32.

14 years agoFix test-ratelim compilation on Linux.
Nick Mathewson [Wed, 30 Dec 2009 18:50:52 +0000 (13:50 -0500)]
Fix test-ratelim compilation on Linux.

I'd forgotten to include time.h, and to link against libm.

14 years agoNever believe that we have pthreads on win32, even if gcc thinks we do.
Nick Mathewson [Wed, 30 Dec 2009 16:58:36 +0000 (11:58 -0500)]
Never believe that we have pthreads on win32, even if gcc thinks we do.

Apparently some newer versions of mingw provide a fake pthreads api to
let applications work even if they don't know about windows threading.
That's nice, but we aren't one of those.

15 years agoFix crash bugs when a bufferevent's eventcb is not set.
Nick Mathewson [Wed, 30 Dec 2009 00:50:03 +0000 (19:50 -0500)]
Fix crash bugs when a bufferevent's eventcb is not set.

In many places throughout the code, we called _bufferevent_run_eventcb
without checking whether the eventcb was actually set.  This would
work fine when the bufferevent's callbacks were deferred, but
otherwise the code would segfault.  Strangely, we always remembered to
check before calling the _bufferevent_run_{read,write}cb functions.

To prevent similar errors in the future, all of
_buferevent_run_{read,write,event}cb now check to make sure the
callback is actually set before invoking or deferring the callback.
This patch also removes the now-redundant checks for {read,write}cb.

15 years agoWhitespace fixes in test.sh
Nick Mathewson [Tue, 29 Dec 2009 23:11:52 +0000 (18:11 -0500)]
Whitespace fixes in test.sh

15 years agoAllow test.sh to be run as ./test/test.sh
Nick Mathewson [Tue, 29 Dec 2009 23:07:51 +0000 (18:07 -0500)]
Allow test.sh to be run as ./test/test.sh

15 years agoAllow the user to redirect the verbose output of test/test.sh to a file
Nick Mathewson [Tue, 29 Dec 2009 22:59:55 +0000 (17:59 -0500)]
Allow the user to redirect the verbose output of test/test.sh to a file

By default, the test.sh script still suppresses the output of all the
tests it invokes.  Now, however, you can have that output written to
a file specified in the TEST_OUTPUT_FILE shell variable.

15 years agoMake the initial nameserver probe timeout configurable.
Nick Mathewson [Tue, 29 Dec 2009 21:04:16 +0000 (16:04 -0500)]
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.

15 years agoFix the code that allowed DNS options to not end with :
Nick Mathewson [Tue, 29 Dec 2009 21:03:30 +0000 (16:03 -0500)]
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.

15 years agoIntroduced evutil_make_socket_closeonexec() to preserve fd flags for F_SETFD.
Jardel Weyrich [Tue, 29 Dec 2009 18:21:26 +0000 (16:21 -0200)]
Introduced evutil_make_socket_closeonexec() to preserve fd flags for F_SETFD.

Use this to eliminate the various macros that called F_SETFD throughout
the code.

15 years agoAdjusted fcntl() retval comparison on evutil_make_socket_nonblocking().
Jardel Weyrich [Tue, 29 Dec 2009 18:19:24 +0000 (16:19 -0200)]
Adjusted fcntl() retval comparison on evutil_make_socket_nonblocking().

Apparently, a successful return value on F_SETFL is "anything but
-1".

15 years agoDo not make bufferevent_setfd implicitly disable EV_READ and EV_WRITE.
Nick Mathewson [Thu, 24 Dec 2009 22:47:14 +0000 (17:47 -0500)]
Do not make bufferevent_setfd implicitly disable EV_READ and EV_WRITE.

This obviates the need for BEV_SUSPEND_CONNECTING, and good riddance.

15 years agoTesting code for bufferevent rate-limiting.
Nick Mathewson [Wed, 23 Dec 2009 12:54:13 +0000 (07:54 -0500)]
Testing code for bufferevent rate-limiting.

This is not part of the regression tests, since running it necessarily
takes a while.  There is a new test-ratelim test; run it with '-h'
for an argument to see its options.

15 years agoRate-limiting for bufferevents; group and individual limits are supported.
Nick Mathewson [Fri, 27 Nov 2009 18:16:54 +0000 (13:16 -0500)]
Rate-limiting for bufferevents; group and individual limits are supported.

The fairness algorithms are not the best, not every bufferevent type
is supported, and some of the locking tricks here are simply absurd.
Still, this code should be a good first step.

15 years agoExpose our cached gettimeofday value with a new interface
Nick Mathewson [Mon, 28 Dec 2009 06:40:37 +0000 (01:40 -0500)]
Expose our cached gettimeofday value with a new interface

I've got a two use case that wants this for a fairly sensible purpose:
one external and on internal.

15 years agoImprove readability of evutil_unparse_protoname()
Jardel Weyrich [Mon, 28 Dec 2009 21:03:47 +0000 (16:03 -0500)]
Improve readability of evutil_unparse_protoname()

15 years agoFix a bogus free in evutil_new_addrinfo()
Jardel Weyrich [Mon, 28 Dec 2009 21:01:59 +0000 (16:01 -0500)]
Fix a bogus free in evutil_new_addrinfo()

15 years agoFix an fd leak in evconnlistener_new_bind().
Jardel Weyrich [Mon, 28 Dec 2009 21:01:12 +0000 (16:01 -0500)]
Fix an fd leak in evconnlistener_new_bind().

15 years agoMake evutil_make_socket_nonblocking() leave any other flags alone.
Jardel Weyrich [Mon, 28 Dec 2009 21:00:05 +0000 (16:00 -0500)]
Make evutil_make_socket_nonblocking() leave any other flags alone.

Fixes bug 2922121

15 years agoFix compilation of devpoll.c by adding missing thread includes.
Dagobert Michelsen [Mon, 28 Dec 2009 20:53:01 +0000 (15:53 -0500)]
Fix compilation of devpoll.c by adding missing thread includes.

(Bug 2922156)

15 years agoReplace some cases of uint32_t with ev_uint32_t.
Nick Mathewson [Wed, 23 Dec 2009 12:53:19 +0000 (07:53 -0500)]
Replace some cases of uint32_t with ev_uint32_t.

Spotted by Roman Puls.

15 years agoDo not ignore bufferevent_enable(EV_READ) before bufferevent_connect().
Nick Mathewson [Wed, 23 Dec 2009 12:48:43 +0000 (07:48 -0500)]
Do not ignore bufferevent_enable(EV_READ) before bufferevent_connect().

Previously, we weren't remembering that we wanted to re-add the read
event once the connect was finished.  Now we are.

15 years agoFix up behavior of never-defered callbacks a little
Nick Mathewson [Tue, 22 Dec 2009 20:52:02 +0000 (15:52 -0500)]
Fix up behavior of never-defered callbacks a little

15 years agoSimplify the read high-watermark checking.
Nick Mathewson [Tue, 22 Dec 2009 20:51:39 +0000 (15:51 -0500)]
Simplify the read high-watermark checking.

15 years agoRemove the contents of WIN32-Prj as unmaintained.
Nick Mathewson [Tue, 22 Dec 2009 17:03:46 +0000 (12:03 -0500)]
Remove the contents of WIN32-Prj as unmaintained.

Makefile.nmake is now the preferred way to build with MSVC; the
project files haven't worked properly in ages.

15 years agoUse evutil_socket_t, not int, when logging socket errors.
Nick Mathewson [Tue, 22 Dec 2009 05:58:52 +0000 (00:58 -0500)]
Use evutil_socket_t, not int, when logging socket errors.

15 years agoFix a few locking issues on windows.
unknown [Mon, 21 Dec 2009 21:36:40 +0000 (16:36 -0500)]
Fix a few locking issues on windows.

15 years agoSet all instances of the version number correctly.
Nick Mathewson [Sat, 19 Dec 2009 04:37:50 +0000 (23:37 -0500)]
Set all instances of the version number correctly.

Note that we've made two subtle mistakes: we are supposed to suffix
any non-released version with "-dev", and we're supposed to use the
last byte of the numeric version to indicate whether we have done this.

For example, when 2.0.4-alpha is released, its numeric versin will be
0x 02 00 04 00.  As soon as we tag it, we will change the version in
the git repository to 2.0.4-alpha-dev, whose numeric version will be
0x 02 00 04 01 or something.

15 years agoDrop install-sh from our git repo: a mismatched version could break "make dist"
Nick Mathewson [Fri, 18 Dec 2009 22:04:37 +0000 (17:04 -0500)]
Drop install-sh from our git repo: a mismatched version could break "make dist"

15 years agoFix a segfault when freeing SSL bufferevents in an unusual order
Joachim Bauch [Fri, 18 Dec 2009 21:24:41 +0000 (16:24 -0500)]
Fix a segfault when freeing SSL bufferevents in an unusual order

Have container bufferevents hold a reference to their underlying bufferevents.

(Commit message and minor revisions by nickm.)

15 years agoFix a segfault when writing a very fragmented evbuffer onto an SSL
Joachim Bauch [Thu, 17 Dec 2009 17:38:46 +0000 (12:38 -0500)]
Fix a segfault when writing a very fragmented evbuffer onto an SSL

Fixes bug 2916328.

15 years agoUpdate sample/signal-test.c to use newer APIs and not leak.
Evan Jones [Tue, 8 Dec 2009 22:02:24 +0000 (17:02 -0500)]
Update sample/signal-test.c to use newer APIs and not leak.

15 years agoOnly define _GNU_SOURCE if it is not already defined.
Joachim Bauch [Tue, 8 Dec 2009 20:38:34 +0000 (15:38 -0500)]
Only define _GNU_SOURCE if it is not already defined.

15 years agoFix compile on Snow Leopard with gcc warnings enabled
Sebastian Hahn [Sun, 6 Dec 2009 01:59:19 +0000 (02:59 +0100)]
Fix compile on Snow Leopard with gcc warnings enabled

15 years agoFix a snow leopard compile warning in the unit tests.
Nick Mathewson [Fri, 4 Dec 2009 21:37:43 +0000 (16:37 -0500)]
Fix a snow leopard compile warning in the unit tests.

Reported by Sebastian Hahn.

15 years agoRefactor our 'suspend operation' logic on bufferevents.
Nick Mathewson [Mon, 23 Nov 2009 23:34:32 +0000 (18:34 -0500)]
Refactor our 'suspend operation' logic on bufferevents.

There are lots of things we do internally in bufferevents to indicate
"the user would like this operation to happen, but we aren't going to
try until some other condition goes away."  Our logic here has gotten
entirely too complicated.

This patch tries to fix that by adding the idea of 'suspend flags' for
read and write.  To say "don't bother reading or writing until
condition X no longer holds," bufferevent_suspend_read/write(bev,
BEV_SUSPEND_X).  When X no longer holds, call
bufferevent_unsuspend_read/write(bev, BEV_SUSPEND_X).

Right now, only the read-watermark logic uses this.

15 years agoAdd the abilitity to mark some buffer callbacks as never-deferred.
Nick Mathewson [Mon, 23 Nov 2009 20:53:24 +0000 (15:53 -0500)]
Add the abilitity to mark some buffer callbacks as never-deferred.

15 years agoNew EVTHREAD_TRY_LOCK function to try to grab a lock.
Nick Mathewson [Sat, 28 Nov 2009 16:31:39 +0000 (11:31 -0500)]
New EVTHREAD_TRY_LOCK function to try to grab a lock.

15 years agoMerge commit 'niels/dnscrash'
Nick Mathewson [Fri, 4 Dec 2009 18:49:27 +0000 (13:49 -0500)]
Merge commit 'niels/dnscrash'

15 years agoFix a crash when reading badly formatted resolve.conf; from Yasuoka Masahiko
Yasuoka Masahiko [Fri, 4 Dec 2009 18:44:46 +0000 (10:44 -0800)]
Fix a crash when reading badly formatted resolve.conf; from Yasuoka Masahiko

15 years agoUpdate nmake makefile to build evthread.c
unknown [Wed, 2 Dec 2009 06:24:37 +0000 (01:24 -0500)]
Update nmake makefile to build evthread.c

15 years agoFix regress_iocp.c usage of old lock allocation macros.
unknown [Wed, 2 Dec 2009 06:22:07 +0000 (01:22 -0500)]
Fix regress_iocp.c usage of old lock allocation macros.

15 years agoFix up evthread compilation on windows
Roman Puls [Wed, 2 Dec 2009 06:15:15 +0000 (01:15 -0500)]
Fix up evthread compilation on windows

15 years agoValgrind fix: Clear struct kevent before checking for OSX bug.
William Ahern [Sun, 29 Nov 2009 15:20:46 +0000 (10:20 -0500)]
Valgrind fix: Clear struct kevent before checking for OSX bug.

William's original commit message:

   Valgrind complains on startup because kq_init passes to kevent only
   a partially initialized structure. The code doesn't expect kevent
   to look at .fflags, .udata, or .data, I suppose, because it merely
   tickles the kernel looking for an error response. But perhaps
   that's unwarranted chuminess (notwithstanding that it's checking
   for an OS X bug), and needless noise nonetheless.

15 years agoImproved optional lock debugging.
Nick Mathewson [Fri, 27 Nov 2009 22:22:19 +0000 (17:22 -0500)]
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."

15 years agoFix an evdns lock violation.
Zhuang Yuyao [Fri, 27 Nov 2009 21:02:49 +0000 (16:02 -0500)]
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().

15 years agoFix a locking bug in event_base_loop()
Nick Mathewson [Fri, 27 Nov 2009 21:00:59 +0000 (16:00 -0500)]
Fix a locking bug in event_base_loop()

We previously were releasing the lock when we exited the main loop
in some ways, but not in others.

15 years agoFix two use-after-free bugs in unit tests spoted by lock debugging
Nick Mathewson [Fri, 27 Nov 2009 20:24:32 +0000 (15:24 -0500)]
Fix two use-after-free bugs in unit tests spoted by lock debugging

15 years agoStop passing EVTHREAD_READ and EVTHREAD_WRITE to non-rw locks.
Nick Mathewson [Fri, 27 Nov 2009 21:44:47 +0000 (16:44 -0500)]
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.

15 years agoRevise the locking API: deprecate the old locking callbacks and add trylock.
Nick Mathewson [Fri, 27 Nov 2009 20:20:43 +0000 (15:20 -0500)]
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.

15 years agoFix memory-leak of signal handler array with kqueue.
Nick Mathewson [Sat, 21 Nov 2009 06:11:49 +0000 (01:11 -0500)]
Fix memory-leak of signal handler array with kqueue.

It turns out that kqueue_dealloc wasn't calling evsig_dealloc()
(because it doesn't use the main signal handler logic) so the sh_old
array was leaking.

This patch also introduces a fix in evsig_dealloc() where we set
the sh_old array to NULL when we free it, so that main/fork can pass.

15 years agoParenthesize macro arguments more aggressively
Nick Mathewson [Fri, 20 Nov 2009 21:50:55 +0000 (16:50 -0500)]
Parenthesize macro arguments more aggressively

15 years agoAdd a warning about the use of event_initialized.
Nick Mathewson [Fri, 20 Nov 2009 21:38:01 +0000 (16:38 -0500)]
Add a warning about the use of event_initialized.

15 years agoTolerate code that returns from a fatal_cb.
Nick Mathewson [Fri, 20 Nov 2009 20:46:04 +0000 (15:46 -0500)]
Tolerate code that returns from a fatal_cb.

Also, replace more abort() calls with EVUTIL_ASSERT() or event_errx.

15 years agoAdd stub header for 2.0.4-alpha changelog.
Nick Mathewson [Fri, 20 Nov 2009 17:56:29 +0000 (12:56 -0500)]
Add stub header for 2.0.4-alpha changelog.

15 years agoAdd more people who wrote patches to the acknowledgments
Nick Mathewson [Fri, 20 Nov 2009 17:46:00 +0000 (12:46 -0500)]
Add more people who wrote patches to the acknowledgments

The names came from grepping ChangeLog for 'patch/code from/by'.

15 years agoImprove the README with more information and links.
Nick Mathewson [Fri, 20 Nov 2009 17:37:47 +0000 (12:37 -0500)]
Improve the README with more information and links.

(Also, try to test out the new commit script.)

15 years agoAdd a .gitignore file.
Nick Mathewson [Fri, 20 Nov 2009 17:17:14 +0000 (12:17 -0500)]
Add a .gitignore file.

.gitignore plays the same role in Git as the svn:ignore property does in
subversion.

15 years agocall it 2.0.3-alpha
Niels Provos [Fri, 20 Nov 2009 00:18:35 +0000 (00:18 +0000)]
call it 2.0.3-alpha

svn:r1556

15 years agoRemove most calls to event_err() in http and deal with memory errors instead release-2.0.3-alpha
Niels Provos [Thu, 19 Nov 2009 23:08:50 +0000 (23:08 +0000)]
Remove most calls to event_err() in http and deal with memory errors instead

svn:r1555