]> granicus.if.org Git - libevent/log
libevent
14 years agoadd more (currently skipped) add_file tests on win32
Nick Mathewson [Sat, 8 May 2010 20:47:07 +0000 (16:47 -0400)]
add more (currently skipped) add_file tests on win32

14 years agoFix unused-variable warning when building with threads disabled
Nick Mathewson [Sat, 8 May 2010 20:41:01 +0000 (16:41 -0400)]
Fix unused-variable warning when building with threads disabled

14 years agoMake evbuffer_add_file() work on windows
Nick Mathewson [Sat, 8 May 2010 20:34:18 +0000 (16:34 -0400)]
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.

14 years agoImplement regress_make_tempfile on win32 to test evbuffer_add_file
Nick Mathewson [Sat, 8 May 2010 18:49:59 +0000 (14:49 -0400)]
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.)

14 years agoFix some crazy macro mistakes in arc4random.c
Nick Mathewson [Sat, 8 May 2010 19:31:54 +0000 (15:31 -0400)]
Fix some crazy macro mistakes in arc4random.c

14 years agoDetect broken unsetenv at unit-test runtime
Nick Mathewson [Wed, 21 Apr 2010 16:25:29 +0000 (12:25 -0400)]
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.

14 years agoOnly add libevent_core.la to LIBADD on mingw
Nick Mathewson [Thu, 6 May 2010 18:37:23 +0000 (14:37 -0400)]
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.

14 years agoOnly specify -no-undefined on mingw
Nick Mathewson [Thu, 6 May 2010 18:37:23 +0000 (14:37 -0400)]
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.

14 years agoMerge commit 'chrisd/connect-hostname-report-err'
Nick Mathewson [Thu, 6 May 2010 18:16:50 +0000 (14:16 -0400)]
Merge commit 'chrisd/connect-hostname-report-err'

14 years agoStop distributing and installing manpages: they were too inaccurate
Nick Mathewson [Thu, 6 May 2010 17:26:05 +0000 (13:26 -0400)]
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.)

14 years agoRename current_base symbol to event_global_current_base_
Nick Mathewson [Tue, 4 May 2010 17:27:36 +0000 (13:27 -0400)]
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.

14 years agoFix symbol conflict between mm_*() macros and libmm
Nick Mathewson [Tue, 4 May 2010 16:57:40 +0000 (12:57 -0400)]
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

14 years agoTry /proc on Linux as entropy fallback; use sysctl as last resort
Nick Mathewson [Mon, 3 May 2010 17:00:00 +0000 (13:00 -0400)]
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.

14 years agoFix nonstandard TAILQ_FOREACH_REVERSE() definition
Frank Denis [Mon, 3 May 2010 15:37:16 +0000 (11:37 -0400)]
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

14 years agoRefuse null keys in evhttp_parse_query()
Frank Denis [Mon, 3 May 2010 15:29:22 +0000 (11:29 -0400)]
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

14 years agoFix a compile warning introduced in 739e688
Sebastian Hahn [Sun, 2 May 2010 10:51:35 +0000 (12:51 +0200)]
Fix a compile warning introduced in 739e688

14 years agoAllow empty reason line in HTTP status
Pierre Phaneuf [Thu, 29 Apr 2010 04:33:13 +0000 (21:33 -0700)]
Allow empty reason line in HTTP status

14 years agoRemove redundant checks for lock!=NULL before calling EVLOCK_LOCK
Nick Mathewson [Wed, 28 Apr 2010 19:16:32 +0000 (15:16 -0400)]
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?

14 years agoFix compilation when openssl support is disabled
Nick Mathewson [Wed, 28 Apr 2010 18:56:51 +0000 (14:56 -0400)]
Fix compilation when openssl support is disabled

Previously, we'd fail if OpenSSL was present but openssl support was
disabled.  Now we don't.

14 years agoCatch attempts to enable debug_mode too late
Nick Mathewson [Wed, 28 Apr 2010 16:03:08 +0000 (12:03 -0400)]
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.

14 years agoMake debug mode catch mixed ET and non-ET events on an fd
Nick Mathewson [Wed, 28 Apr 2010 15:51:56 +0000 (11:51 -0400)]
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.

14 years agoRelease locks on bufferevents while executing callbacks
Joachim Bauch [Tue, 27 Apr 2010 17:42:26 +0000 (13:42 -0400)]
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).

14 years agoReport DNS error when lookup fails during bufferevent_socket_connect_hostname.
Christopher Davis [Sat, 24 Apr 2010 07:06:38 +0000 (00:06 -0700)]
Report DNS error when lookup fails during bufferevent_socket_connect_hostname.

14 years agoMerge branch 'rpc_leaks'
Nick Mathewson [Sat, 24 Apr 2010 04:15:15 +0000 (00:15 -0400)]
Merge branch 'rpc_leaks'

14 years agoMerge branch 'arc4seed'
Nick Mathewson [Sat, 24 Apr 2010 04:01:31 +0000 (00:01 -0400)]
Merge branch 'arc4seed'

14 years agoFix a memory leak when unmarshalling RPC object arrays
Nick Mathewson [Sat, 24 Apr 2010 03:55:30 +0000 (23:55 -0400)]
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.

14 years agofix a leak when unpausing evrpc requests
Nick Mathewson [Sat, 24 Apr 2010 03:55:03 +0000 (23:55 -0400)]
fix a leak when unpausing evrpc requests

14 years agoMake http_base_test stop leaking an event_base.
Nick Mathewson [Sat, 24 Apr 2010 03:13:26 +0000 (23:13 -0400)]
Make http_base_test stop leaking an event_base.

14 years agoRemove one last bug in last_with_datap logic. Found with valgrind
Nick Mathewson [Sat, 24 Apr 2010 03:04:20 +0000 (23:04 -0400)]
Remove one last bug in last_with_datap logic. Found with valgrind

14 years agodo not leak the request object on persistent connections
Niels Provos [Sat, 24 Apr 2010 01:59:22 +0000 (18:59 -0700)]
do not leak the request object on persistent connections

14 years agoFix a couple of bugs in the BSD sysctl arc4seed logic
Nick Mathewson [Fri, 23 Apr 2010 20:08:09 +0000 (16:08 -0400)]
Fix a couple of bugs in the BSD sysctl arc4seed logic

Of course, FreeBSD has its own arc4random() implementation, so this should
never actually be needed.  Still, it's good to paint the underside of the
wagon.

14 years agoDocument evutil_secure_rng_init() and evutil_secure_rng_add_bytes()
Nick Mathewson [Thu, 4 Mar 2010 06:14:32 +0000 (01:14 -0500)]
Document evutil_secure_rng_init() and evutil_secure_rng_add_bytes()

14 years agoMake evutil_secure_rng_init() work even with builtin arc4random
Nick Mathewson [Fri, 23 Apr 2010 19:17:10 +0000 (15:17 -0400)]
Make evutil_secure_rng_init() work even with builtin arc4random

14 years agoSeed the RNG using sysctl() as well as /dev/urandom
Nick Mathewson [Thu, 4 Mar 2010 06:13:51 +0000 (01:13 -0500)]
Seed the RNG using sysctl() as well as /dev/urandom

William Ahern points out that if the user has chrooted, they might not
have a working /dev/urandom.  Linux and many of the BSDs, however,
define a sysctl interface to their kernel random number generators.

This patch takes a belt-and-suspenders approach and tries to do use the
sysctl _and_ the /dev/urandom approach if both are present.  When using
the sysctl approach, it tries to bulletproof itself by checking to make
sure that the buffers are actually set by the sysctl calls.

14 years agoMake evdns logging threadsafe
Nick Mathewson [Fri, 23 Apr 2010 18:42:25 +0000 (14:42 -0400)]
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.

14 years agoAdd a comment to explain why evdns_request is now separte from request
Nick Mathewson [Fri, 23 Apr 2010 18:04:03 +0000 (14:04 -0400)]
Add a comment to explain why evdns_request is now separte from request

14 years agoAdd dns/search_cancel unit test.
Christopher Davis [Fri, 23 Apr 2010 04:49:05 +0000 (21:49 -0700)]
Add dns/search_cancel unit test.

14 years agoAssert for valid requests as necessary.
Christopher Davis [Fri, 23 Apr 2010 04:46:05 +0000 (21:46 -0700)]
Assert for valid requests as necessary.

A valid request has an associated handle, and the handle must point
to the request.

14 years agoFree search state when finished searching to avoid an infinite loop.
Christopher Davis [Thu, 22 Apr 2010 05:20:10 +0000 (22:20 -0700)]
Free search state when finished searching to avoid an infinite loop.

14 years agoMove domain search state to evdns_request.
Christopher Davis [Thu, 22 Apr 2010 05:01:59 +0000 (22:01 -0700)]
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.

14 years agoEnsure that evdns_request is a persistent handle.
Christopher Davis [Thu, 22 Apr 2010 04:21:21 +0000 (21:21 -0700)]
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.

14 years agoClean up properly when adding a signal handler fails.
Gilad Benjamini [Wed, 21 Apr 2010 05:15:19 +0000 (01:15 -0400)]
Clean up properly when adding a signal handler fails.

Previously, when a signation() or signal() call failed, we would free
the element we added to sh_old, but not actually clear the pointer.
This would leave a dangling pointer in sh_old that could cause a
crash later.

14 years agoReplace EVUTIL_CLOSESOCKET macro with a function
Sebastian Sjöberg [Wed, 14 Apr 2010 19:42:57 +0000 (15:42 -0400)]
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)

14 years agoAdd ctags/etags files to .gitignore
Nick Mathewson [Wed, 14 Apr 2010 18:41:03 +0000 (14:41 -0400)]
Add ctags/etags files to .gitignore

14 years agoAdd void* arguments to request_new and reply_new evrpc hooks
Shuo Chen [Wed, 14 Apr 2010 18:27:29 +0000 (14:27 -0400)]
Add void* arguments to request_new and reply_new evrpc hooks

This makes evprc setup more extensible, and helps with Shuo Chen's
work on implementing Google protocol buffers rpc on top of Libevent 2
evrpc.

This patch breaks binary compatibility with previous versions of
Libevent, since it changes struct evrpc and the signature of
evrpc_register_generic().  Since all compliant code should be calling
evrpc_register_generic via EVRPC_REGISTER, it shouldn't break source
compatibility.

(Code by Shuo Chen; commit message by Nick)

14 years agoExpose the request and reply members of rpc_req_generic()
Shuo Chen [Wed, 14 Apr 2010 18:23:03 +0000 (14:23 -0400)]
Expose the request and reply members of rpc_req_generic()

This code adds two accessor functions to evprc, and helps integrate
evrpc with Google protocol buffers.

(Code by Shuo Chen; commit message by nickm)

14 years agoInitialize last_with_datap correctly in evbuffer_overlapped
Nick Mathewson [Wed, 14 Apr 2010 04:36:09 +0000 (00:36 -0400)]
Initialize last_with_datap correctly in evbuffer_overlapped

Fixes bug 2985406

14 years agoCreate shared libraries under Windows
Giuseppe Scrivano [Mon, 12 Apr 2010 10:52:31 +0000 (12:52 +0200)]
Create shared libraries under Windows

14 years agoDo not inhibit automake dependencies generation
Giuseppe Scrivano [Mon, 12 Apr 2010 10:50:17 +0000 (12:50 +0200)]
Do not inhibit automake dependencies generation

It fixes make parallel builds.

14 years agoFix compiler warnings under WIN32
Giuseppe Scrivano [Mon, 12 Apr 2010 10:18:57 +0000 (12:18 +0200)]
Fix compiler warnings under WIN32

14 years agoMerge branch 'evbuffer_copyout'
Nick Mathewson [Tue, 13 Apr 2010 05:46:29 +0000 (01:46 -0400)]
Merge branch 'evbuffer_copyout'

14 years agoAdd evbuffer_copyout to copy data from an evbuffer without draining
Nick Mathewson [Tue, 13 Apr 2010 02:24:54 +0000 (22:24 -0400)]
Add evbuffer_copyout to copy data from an evbuffer without draining

The evbuffer_remove() function copies data from the front of an
evbuffer into an array of char, and removes the data from the buffer.
This function behaves the same, but does not remove the data.  This
behavior can be handy for lots of protocols, where you want the
evbuffer to accumulate data until a complete record has arrived.

Lots of people have asked for a function more or less like this, and
though it isn't too hard to code one from evbuffer_peek(), it is
apparently annoying to do it in every app you write.  The
evbuffer_peek() function is significantly faster, but it requires that
the user be able to handle data in separate extents.

This patch also reimplements evbufer_remove() as evbuffer_copyout()
followed by evbuffer_drain().  I am reasonably confident that this
won't be a performance hit: the memcpy() overhead should dominate the
cost of walking the list an extra time.

14 years agoMerge branch 'safetimevalms'
Christopher Davis [Sat, 10 Apr 2010 18:26:53 +0000 (11:26 -0700)]
Merge branch 'safetimevalms'

14 years agoAlways round up when there's a fractional number of msecs.
Christopher Davis [Sat, 10 Apr 2010 02:16:09 +0000 (19:16 -0700)]
Always round up when there's a fractional number of msecs.

14 years agoLimit the maximum number of events on each socket to 65535
Nick Mathewson [Fri, 9 Apr 2010 23:16:49 +0000 (19:16 -0400)]
Limit the maximum number of events on each socket to 65535

This lets us use less RAM for the evmap_io structure, which in turn
can let us have fewer cache misses for evmap operations.

14 years agoMerge branch 'comment'
Nick Mathewson [Fri, 9 Apr 2010 23:14:25 +0000 (19:14 -0400)]
Merge branch 'comment'

14 years agoAdd a few more evmap/changelist comments
Nick Mathewson [Fri, 9 Apr 2010 17:32:08 +0000 (13:32 -0400)]
Add a few more evmap/changelist comments

14 years agoTest another case of evbuffer_prepend
Nick Mathewson [Fri, 9 Apr 2010 21:19:39 +0000 (17:19 -0400)]
Test another case of evbuffer_prepend

14 years agoAdd more unit tests for evbuffer_expand
Nick Mathewson [Fri, 9 Apr 2010 20:40:53 +0000 (16:40 -0400)]
Add more unit tests for evbuffer_expand

14 years agoUnit-test every evbuffer_add_file() implementation.
Nick Mathewson [Fri, 9 Apr 2010 19:28:26 +0000 (15:28 -0400)]
Unit-test every evbuffer_add_file() implementation.

Previously, we'd only test the default one, even if the others were still
compiled in.

14 years agoClean up a mistake in pointer manipulation in evbuffer_remove
Christopher Davis [Fri, 2 Apr 2010 23:08:32 +0000 (19:08 -0400)]
Clean up a mistake in pointer manipulation in evbuffer_remove

14 years agoAdd evutil_tv_to_msec for safe conversion of timevals to milliseconds.
Christopher Davis [Thu, 1 Apr 2010 03:30:55 +0000 (20:30 -0700)]
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.

14 years agoRewrite evbuffer_expand and its users
Nick Mathewson [Tue, 30 Mar 2010 20:47:37 +0000 (16:47 -0400)]
Rewrite evbuffer_expand and its users

The previous evbuffer_expand was not only incorrect; it was
inefficient too.  On all questions of time vs memory tradeoffs, it
chose to burn time in order to avoid wasting memory.  The new code
tries to be a little more balanced: it only resizes an existing chain
when doing so doesn't require too much copying, and when failing to do
so would waste a lot of the chain's space.

This patch also rewrites evbuffer_chain_insert to work properly with
last_with_datap, and adds a few convenience functions to buffer.c.

14 years agoFix a memory leak when appending/prepending to a buffer with unused space.
Nick Mathewson [Wed, 31 Mar 2010 16:03:43 +0000 (12:03 -0400)]
Fix a memory leak when appending/prepending to a buffer with unused space.

14 years agoMake the no_iovecs case of write_atmost compile
Nick Mathewson [Sat, 27 Mar 2010 04:09:25 +0000 (00:09 -0400)]
Make the no_iovecs case of write_atmost compile

Apparently nobody had tested it before on a system that had sendfile.
Why would you have sendfile and not writev?  Perhaps you're trying to
test the no-iovecs code to make sure it still works.

14 years agoTurn the increasingly complex *_CHAIN() macros into functions
Nick Mathewson [Tue, 30 Mar 2010 16:48:56 +0000 (12:48 -0400)]
Turn the increasingly complex *_CHAIN() macros into functions

14 years agoReplace last_with_data with a slightly smarter version
Nick Mathewson [Sat, 27 Mar 2010 03:18:40 +0000 (23:18 -0400)]
Replace last_with_data with a slightly smarter version

To implement evbuffer_expand() properly, you need to be able to
replace the last chunk that has data, which means that we need to keep
track of the the next pointer pointing to the last_with_data chunk,
not the last_with_data chunk itself.

14 years agoFix critical bug in evbuffer_write when writev is not available
Nick Mathewson [Wed, 31 Mar 2010 16:29:26 +0000 (12:29 -0400)]
Fix critical bug in evbuffer_write when writev is not available

evbuffer_pullup() returns NULL if you try to pull up more bytes than
are there.  But evbuffer_write_atmost would sometimes ask for more
bytes to be pulled up than it had, get a NULL, and fail.

14 years agoMake evbuffer_prepend handle empty buffers better
Nick Mathewson [Fri, 26 Mar 2010 18:51:39 +0000 (14:51 -0400)]
Make evbuffer_prepend handle empty buffers better

If the first chunk of a buffer is empty, and we're told to prepend to
the buffer, we should be willing to use the entire first chunk.
Instead, we were dependent on the value of chunk->misalign.

14 years agoDo not use evbuffer_expand() to add the first chain to a buffer
Nick Mathewson [Fri, 26 Mar 2010 18:50:45 +0000 (14:50 -0400)]
Do not use evbuffer_expand() to add the first chain to a buffer

(It's a big function, and using it this way is overkill.)

14 years agoIncrease MIN_BUFFER_SIZE to 512 (1024 on 64-bit)
Nick Mathewson [Fri, 26 Mar 2010 18:30:14 +0000 (14:30 -0400)]
Increase MIN_BUFFER_SIZE to 512 (1024 on 64-bit)

This constant decides the smallest (and typical) size of each evbuffer
chain.  Since this number includes sizeof(evbuffer_chain) overhead,
the old value (256) was just too low: on 64-bit platforms, it would
spend nearly 20% of the allocations on overhead.  The new values mean
that we'll be spending closer to 5% of evbuffer allocations on overhead.

It would be nice to get this number even lower if we can.

14 years agoFix a free(NULL) in minheap-internal.h
Nick Mathewson [Fri, 26 Mar 2010 18:20:10 +0000 (14:20 -0400)]
Fix a free(NULL) in minheap-internal.h

14 years agoFix minheap code to use replacement malloc functions
Nick Mathewson [Fri, 26 Mar 2010 17:56:01 +0000 (13:56 -0400)]
Fix minheap code to use replacement malloc functions

minheap-internal.h still had an extra realloc and an extra free that
needed to be replaced with mm_realloc and mm_free().

14 years agoRemove a needless min_heap_shift_up_() call
Nick Mathewson [Fri, 26 Mar 2010 17:46:29 +0000 (13:46 -0400)]
Remove a needless min_heap_shift_up_() call

Previously, every call to min_heap_shift_down_() would invoke
min_heap_shift_up_() at the end.  This used to be necessary in the
first version of the minheap code, since min_heap_erase() would call
min_heap_shift_down_() unconditionally.  But when patch 8b7a3b36763
from Marko Kreen fixed min_heap_erase() to be more sensible, we left
the weird behavior of min_heap_shift_down_() in place.

Fortunately, "cui" noticed this and reported it on Niels's blog.

14 years agoMake evutil_signal_active() match declaration.
Patrick Galbraith [Tue, 23 Mar 2010 20:04:59 +0000 (16:04 -0400)]
Make evutil_signal_active() match declaration.

14 years agoNever test for select() on windows
Trond Norbye [Tue, 23 Mar 2010 17:27:10 +0000 (13:27 -0400)]
Never test for select() on windows

On 64-bit windows, configure actually _finds_ select when it tests for
it, and due to the ordering of the io implementations in event.c it is
chosen over the win32select implementation.

This modification skips the test for select on win32 (we don't want
that anyway, because Windows has its own), causing my windows box to
get the win32select implementation.

(edited by Nick)

14 years agoMerge branch 'build'
Nick Mathewson [Mon, 22 Mar 2010 17:37:39 +0000 (13:37 -0400)]
Merge branch 'build'

14 years agoUse dist_bin_SCRIPTS, not EXTRA_DIST, to distribute scripts
Nick Mathewson [Mon, 22 Mar 2010 17:27:47 +0000 (13:27 -0400)]
Use dist_bin_SCRIPTS, not EXTRA_DIST, to distribute scripts

14 years agoFix infrequent memory leak in bufferevent_init_common().
Jardel Weyrich [Fri, 12 Mar 2010 09:04:56 +0000 (06:04 -0300)]
Fix infrequent memory leak in bufferevent_init_common().

14 years agoDetect and refuse reentrant event_base_loop() calls
Nick Mathewson [Sun, 21 Mar 2010 17:28:48 +0000 (13:28 -0400)]
Detect and refuse reentrant event_base_loop() calls

Calling event_base_loop on a base from inside a callback invoked by
that same base, or from two threads at once, has long been a way to
get exceedingly hard-to-diagnose errors.  This patch adds code to
detect such reentrant invocatinos, and exit quickly with a warning
that should explain what went wrong.

14 years agoFunctions to track the total bytes sent over a rate limit group.
Nick Mathewson [Sun, 21 Mar 2010 17:16:31 +0000 (13:16 -0400)]
Functions to track the total bytes sent over a rate limit group.

14 years agoMake 'main/many_events' test 70 fds, not 64.
Nick Mathewson [Tue, 16 Mar 2010 17:37:15 +0000 (13:37 -0400)]
Make 'main/many_events' test 70 fds, not 64.

This is mainly intended to ensure that we don't get hung up on
the 64-handle limit that lots of O(n) Windows functions (but FWICT
not select) like to enforce.

14 years agoSet mem_offset for every bufferevent type
Nick Mathewson [Sat, 13 Mar 2010 06:06:57 +0000 (01:06 -0500)]
Set mem_offset for every bufferevent type

14 years agoAvoid an (untriggerable so far) crash bug in bufferevent_free()
Nick Mathewson [Sat, 13 Mar 2010 06:04:30 +0000 (01:04 -0500)]
Avoid an (untriggerable so far) crash bug in bufferevent_free()

We were saying
     mm_free(bufev - bufev->be_ops->mem_offset);
when we should have said
     mm_free(((char*)bufev) - bufev->be_ops->mem_offset);

In other words, if mem_offset had ever been nonzero, then instead of
backing up mem_offset bytes to find the thing we were supposed to free, we
would have backed up mem_offset*sizeof(struct bufferevent) bytes, and freed
something completely crazy.

Spotted thanks to a conversation with Jardel Weyrich

14 years agoFix some memory leaks in the unit tests
Nick Mathewson [Sat, 13 Mar 2010 05:55:39 +0000 (00:55 -0500)]
Fix some memory leaks in the unit tests

These don't matter except inasmuch as they give real memory leaks
a place to hide.

Found with valgrind

14 years agoFree evdns_base->req_heads on evdns_base_free
Nick Mathewson [Sat, 13 Mar 2010 05:53:54 +0000 (00:53 -0500)]
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

14 years agoFix a write of uninitialized RAM in regression tests
Nick Mathewson [Sat, 13 Mar 2010 01:38:25 +0000 (20:38 -0500)]
Fix a write of uninitialized RAM in regression tests

Not actually harmful, but not something we should be doing.

Found by valgrind.

14 years agoDo not close(-1) when freeing an uninitialized socket bufferevent
Nick Mathewson [Fri, 12 Mar 2010 23:36:18 +0000 (18:36 -0500)]
Do not close(-1) when freeing an uninitialized socket bufferevent

14 years agoAvoid a spurious close(-1) on Linux
Nick Mathewson [Fri, 12 Mar 2010 23:35:15 +0000 (18:35 -0500)]
Avoid a spurious close(-1) on Linux

On Linux, we use only one fd to do main-thread signaling (since we have
eventfd()), so we don't need to close th_notify_fd[1] as we would if we were
using a socketpair.

14 years agoFix a possible double-free bug in SSL bufferevents with CLOSE_ON_FREE
Nick Mathewson [Sat, 13 Mar 2010 05:23:06 +0000 (00:23 -0500)]
Fix a possible double-free bug in SSL bufferevents with CLOSE_ON_FREE

With CLOSE_ON_FREE set, we were telling the BIO to free the bufferevent when
it was closed, and also freeing it ourselves.

14 years agoFix an obnoxious typo in the bufferevent_timeout_filter test
Nick Mathewson [Sat, 13 Mar 2010 05:29:15 +0000 (00:29 -0500)]
Fix an obnoxious typo in the bufferevent_timeout_filter test

We were using the same bufferevent as the child of two filtering parents,
orphaning another.  This made one get freed twice, and the other not at all.

Possible fix for bug 2963306 spotted by Doug Cuthbertson.

14 years agoImprove robustness for refcounting
Nick Mathewson [Sat, 13 Mar 2010 04:00:49 +0000 (23:00 -0500)]
Improve robustness for refcounting

Document that we do intend to double-decref underlying bufferevents under
some circumstances.  Check to make sure that we don't decref past 0.

14 years agoGive a better warning for bad automake versions.
Nick Mathewson [Fri, 12 Mar 2010 19:37:54 +0000 (14:37 -0500)]
Give a better warning for bad automake versions.

If you tried to build with automake-1.6 or earlier, we would
previously spit out pages and pages of garbage output.  Now, automake
should just say "Hey, I'm not new enough for this."

14 years agoRemove an orphaned RELEASE flag in Makefile.am
Nick Mathewson [Fri, 12 Mar 2010 19:21:52 +0000 (14:21 -0500)]
Remove an orphaned RELEASE flag in Makefile.am

14 years agoSwitch to using AM conditionals in place of AC_LIBOBJ
Nick Mathewson [Fri, 12 Mar 2010 19:16:30 +0000 (14:16 -0500)]
Switch to using AM conditionals in place of AC_LIBOBJ

AC_LIBOBJ is really only meant for defining missing library functions,
not conditional code compilation.  Sticking our conditionally compiled
modules in SYS_SRC should make stuff easier to maintain.

14 years agoRemove redundant stuff from EXTRA_DIST
Nick Mathewson [Fri, 12 Mar 2010 18:22:47 +0000 (13:22 -0500)]
Remove redundant stuff from EXTRA_DIST

To a first approximation, sources that are mentioned anywhere in an
automake file don't need to get mentioned in EXTRA_DIST.

14 years agoSupport the standard 'make check' target in place of 'make verify'
Nick Mathewson [Fri, 12 Mar 2010 18:09:28 +0000 (13:09 -0500)]
Support the standard 'make check' target in place of 'make verify'

Based on patch 2816088 from Zack Weinberg

14 years agoMerge branch 'evbuffer_insert_point'
Nick Mathewson [Fri, 12 Mar 2010 17:26:06 +0000 (12:26 -0500)]
Merge branch 'evbuffer_insert_point'

14 years agoFunctions to manipulate existing rate limiting groups.
Nick Mathewson [Fri, 12 Mar 2010 05:46:39 +0000 (00:46 -0500)]
Functions to manipulate existing rate limiting groups.

This patch adds a function to change the current rate limit of a rate
limiting group, and another to free an empty rate limiting group.

14 years agoTry to comment some of the event code more
Nick Mathewson [Thu, 11 Mar 2010 05:38:46 +0000 (00:38 -0500)]
Try to comment some of the event code more