]> granicus.if.org Git - libevent/log
libevent
14 years agoRemove some automake-generated files from version control.
Nick Mathewson [Thu, 17 Jun 2010 14:31:35 +0000 (10:31 -0400)]
Remove some automake-generated files from version control.

14 years agoFix a pedantic gcc 4.4 warning in event2/event.h
Nick Mathewson [Fri, 11 Jun 2010 15:57:13 +0000 (11:57 -0400)]
Fix a pedantic gcc 4.4 warning in event2/event.h

14 years agoFix possible nullptr dereference in evhttp_send_reply_end()
Felix Nawothnig [Sun, 30 May 2010 01:17:48 +0000 (03:17 +0200)]
Fix possible nullptr dereference in evhttp_send_reply_end()

(The existing implementation had sanity-checking code for the case where
 its argument was NULL, but it erroneously dereferenced it before actually
 doing the sanity-check. --nickm)

14 years agoAdd a function to retrieve the other side of a bufferevent pair
Nick Mathewson [Mon, 7 Jun 2010 16:06:43 +0000 (12:06 -0400)]
Add a function to retrieve the other side of a bufferevent pair

14 years agoAdd test for behavior on remote socket close
Nick Mathewson [Thu, 3 Jun 2010 15:25:54 +0000 (11:25 -0400)]
Add test for behavior on remote socket close

On all the backends on this little mac laptop, that behavior is to
report a remote socket close as both EV_READ and EV_WRITE.
Historically, we had problem for some of these behaviors on some
backends, so let's make sure that such behaviors don't come back.

14 years agoFix logic in correcting high values from FIONREAD
Nick Mathewson [Fri, 28 May 2010 19:05:32 +0000 (15:05 -0400)]
Fix logic in correcting high values from FIONREAD

The old logic made sense back when buffer.c was an enormous linear
buffer, but it doesn't make any sense for the chain-based
implementation.

This patch also refactors the ioctl{socket}? call into its own function.

14 years agoClose the file in evutil_read_file whether there's an error or not.
Pierre Phaneuf [Fri, 28 May 2010 02:37:09 +0000 (22:37 -0400)]
Close the file in evutil_read_file whether there's an error or not.

evutil_read_file would close the file if there was an error, but not if things went normally.

14 years agoAdd the libtool-generated /m4/* stuff to .gitignore
Nick Mathewson [Thu, 27 May 2010 05:32:11 +0000 (01:32 -0400)]
Add the libtool-generated /m4/* stuff to .gitignore

14 years agoLet evhttp_send_error infer the right error reasons
Nick Mathewson [Wed, 26 May 2010 16:58:02 +0000 (12:58 -0400)]
Let evhttp_send_error infer the right error reasons

14 years agoFix the default HTTP error template
Felix Nawothnig [Wed, 26 May 2010 16:50:59 +0000 (12:50 -0400)]
Fix the default HTTP error template

The current template...

<HTML><HEAD><TITLE>%s</TITLE>
</HEAD><BODY>
<H1>Method Not Implemented</H1>
Invalid method in request<P>
</BODY></HTML>

is highly confusing. The given title is easily overlooked and the
hard-coded content is just plain wrong in most cases (I really read
this as "the server did not understand the requested HTTP method)

This patch changes the template to include the error reason in the
body as well as in the header, and to infer the proper reason from
the status code whenever the reason argument is NULL.

This patch also removes a redundant evhttp_add_header from
evhttp_send_error; evhttp_send_page already adds a "Connection:
close" header.

14 years agoHave the unit tests report errors from test.sh
Nick Mathewson [Wed, 26 May 2010 17:32:32 +0000 (13:32 -0400)]
Have the unit tests report errors from test.sh

The default behavior of test.sh was to suppress all output from
test/regress, and say nothing but OKAY or FAILED.  This wasn't so good
for getting bugs reported, since lots of people didn't know to set
TEST_OUTPUT_FILE, or re-run ./test/regress on its own.

Now, when you don't specify an output file for test.sh, it runs
regress with the --quiet option.  This option makes the unit tests
only print output on failure, which is what we probably wanted.

14 years agoMake test.sh exit with nonzero status if tests fail
Nick Mathewson [Wed, 26 May 2010 17:31:41 +0000 (13:31 -0400)]
Make test.sh exit with nonzero status if tests fail

This behavior makes "make verify" actually fail when the tests fail,
which is what it's supposed to do.

14 years agoRemove all non-error prints from test/regress.c
Nick Mathewson [Wed, 26 May 2010 17:19:08 +0000 (13:19 -0400)]
Remove all non-error prints from test/regress.c

Now, running ./test/regress --quiet will indeed only inform you
about errors.  Previously, it would also spew extra output.

14 years agoRemove the now-obsolete setup_test() and cleanup_test() functions
Nick Mathewson [Wed, 26 May 2010 17:18:30 +0000 (13:18 -0400)]
Remove the now-obsolete setup_test() and cleanup_test() functions

14 years agoUse generic win32 interfaces, not ASCII-only ones, where possible.
Nick Mathewson [Mon, 24 May 2010 19:24:03 +0000 (15:24 -0400)]
Use generic win32 interfaces, not ASCII-only ones, where possible.

14 years agoMerge branch 'evdns_no_empty_handles'
Nick Mathewson [Wed, 19 May 2010 14:49:49 +0000 (10:49 -0400)]
Merge branch 'evdns_no_empty_handles'

14 years agoRemove some dead assignments
Nick Mathewson [Tue, 18 May 2010 21:28:51 +0000 (17:28 -0400)]
Remove some dead assignments

14 years agoIf no evdns request can be launched, return NULL, not a handle
Nick Mathewson [Tue, 18 May 2010 21:27:06 +0000 (17:27 -0400)]
If no evdns request can be launched, return NULL, not a handle

Some of our evdns code was willing to return an evdns_request with
handle->current_req set to NULL.  Really, those cases should just
return NULL.

14 years agoUse -Wlogical-op on gcc 4.5 or higher
Nick Mathewson [Tue, 18 May 2010 18:05:01 +0000 (14:05 -0400)]
Use -Wlogical-op on gcc 4.5 or higher

It exposed one bug for us (see 8c3452bcb294e07888), and might
prevent more.

14 years agoCorrectly recognize .255 addresses as link-local when looking for interfaces
Nick Mathewson [Tue, 18 May 2010 17:55:32 +0000 (13:55 -0400)]
Correctly recognize .255 addresses as link-local when looking for interfaces

14 years agoAvoid close of uninitialized socket in evbuffer unit test
Nick Mathewson [Mon, 17 May 2010 15:58:07 +0000 (11:58 -0400)]
Avoid close of uninitialized socket in evbuffer unit test

Attempts to fix a crash bug found by Brodie Thiesfield.

14 years agoReplace (safe) use of strcpy with memcpy to appease OpenBSD
Nick Mathewson [Fri, 14 May 2010 18:36:49 +0000 (14:36 -0400)]
Replace (safe) use of strcpy with memcpy to appease OpenBSD

If Libevent uses strcpy, even safely, it seems OpenBSD's linker will
complain every time a library links Libevent.  It's easier just not to
use the old thing, even when it's safe to do so.

14 years agoAdd some missing includes to fix Linux build again
Nick Mathewson [Fri, 14 May 2010 18:30:09 +0000 (14:30 -0400)]
Add some missing includes to fix Linux build again

14 years agoMake test-ratelim clean up after itself better.
Nick Mathewson [Thu, 13 May 2010 19:38:39 +0000 (15:38 -0400)]
Make test-ratelim clean up after itself better.

14 years agoAvoid event_del on uninitialized event in event_base_free
Nick Mathewson [Thu, 13 May 2010 18:59:33 +0000 (14:59 -0400)]
Avoid event_del on uninitialized event in event_base_free

This was mostly harmless, since the event was cleared with calloc, but
still it's not a correct thing to do.

14 years agoAdd options to test-ratelim.c to check its results
Nick Mathewson [Thu, 13 May 2010 16:01:30 +0000 (12:01 -0400)]
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.

14 years agoDo not check that event_base is set in EVBASE_ACQUIRE_LOCK
Nick Mathewson [Thu, 13 May 2010 15:24:07 +0000 (11:24 -0400)]
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.

14 years agoRemove the now-unusable EVTHREAD_LOCK/UNLOCK constants
Nick Mathewson [Thu, 13 May 2010 15:23:12 +0000 (11:23 -0400)]
Remove the now-unusable EVTHREAD_LOCK/UNLOCK constants

14 years agoMark the event_err() functions as __attribute__((noreturn))
Nick Mathewson [Thu, 13 May 2010 14:57:30 +0000 (10:57 -0400)]
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.

14 years agoTest the unlocked-deferred callback case of bufferevents
Nick Mathewson [Wed, 12 May 2010 19:38:28 +0000 (15:38 -0400)]
Test the unlocked-deferred callback case of bufferevents

14 years agoRemove the obsolete evthread interfaces
Nick Mathewson [Tue, 11 May 2010 15:44:07 +0000 (11:44 -0400)]
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.

14 years agoBump version to 2.0.5-beta-dev
Nick Mathewson [Mon, 10 May 2010 18:51:32 +0000 (14:51 -0400)]
Bump version to 2.0.5-beta-dev

14 years agoIncrement version numbers for 2.0.5-beta release-2.0.5-beta
Nick Mathewson [Sun, 9 May 2010 04:22:08 +0000 (00:22 -0400)]
Increment version numbers for 2.0.5-beta

14 years agoAdd a changelog for 2.0.5-beta
Nick Mathewson [Sun, 9 May 2010 04:16:35 +0000 (00:16 -0400)]
Add a changelog for 2.0.5-beta

14 years agoFix some autoconf issues on OpenBSD
Nick Mathewson [Sun, 9 May 2010 03:29:29 +0000 (23:29 -0400)]
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.

14 years agoDefine _REENTRANT as needed on Solaris, elsewhere
Nick Mathewson [Sun, 9 May 2010 02:21:52 +0000 (22:21 -0400)]
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.

14 years agoFix test.sh on freebsd
Nick Mathewson [Sat, 8 May 2010 23:56:25 +0000 (19:56 -0400)]
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!

14 years agoMake test.sh support mingw/msys on win32
Nick Mathewson [Sat, 8 May 2010 22:00:26 +0000 (18:00 -0400)]
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

14 years agoFix whitespace in evutil.c
Nick Mathewson [Sat, 8 May 2010 23:36:05 +0000 (19:36 -0400)]
Fix whitespace in evutil.c

14 years agoFix another nasty solaris getaddrinfo() behavior
Nick Mathewson [Sat, 8 May 2010 23:16:47 +0000 (19:16 -0400)]
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.

14 years agoFix getaddrinfo with protocol unset on Solaris 9. Found by Dagobert Michelsen
Nick Mathewson [Wed, 21 Apr 2010 15:57:55 +0000 (11:57 -0400)]
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

14 years agoNumerous opensolaris compilation fixes
Nick Mathewson [Sat, 8 May 2010 22:09:27 +0000 (18:09 -0400)]
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

14 years agoMake test for bufferevent_connect_hostname system-neutral
Nick Mathewson [Sat, 8 May 2010 23:11:50 +0000 (19:11 -0400)]
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"

14 years agoMake unit test for add_file able to tell "error" from "done"
Nick Mathewson [Sat, 8 May 2010 23:09:09 +0000 (19:09 -0400)]
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.

14 years agoFix bench_http build on win32.
Nick Mathewson [Sat, 8 May 2010 21:15:52 +0000 (17:15 -0400)]
Fix bench_http build on win32.

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.