1550 Commits

Author SHA1 Message Date
Nick Mathewson
384d124581 Fix bench_http build on win32. 2010-05-08 17:15:52 -04:00
Nick Mathewson
05de45d63f add more (currently skipped) add_file tests on win32 2010-05-08 16:47:17 -04:00
Nick Mathewson
ad811cdc2b Fix unused-variable warning when building with threads disabled 2010-05-08 16:41:01 -04:00
Nick Mathewson
dcdae6b743 Make evbuffer_add_file() work on windows
Right now only the add_file() mode is supported, when it would be
nicer to have mmap support.  Perhaps for Libevent 2.1.x.
2010-05-08 16:34:18 -04:00
Nick Mathewson
b4f12a17aa Implement regress_make_tempfile on win32 to test evbuffer_add_file
(Conclusion: evbuffer_add_file is broken on win32, since it
uses recv on a file.)
2010-05-08 16:14:20 -04:00
Nick Mathewson
90d4225137 Fix some crazy macro mistakes in arc4random.c 2010-05-08 15:31:54 -04:00
Nick Mathewson
f37cd4c227 Detect broken unsetenv at unit-test runtime
If we have an unsetenv function that doesn't work, we can't run the
main/base_environ unit test, so we should skip it.
2010-05-08 14:36:59 -04:00
Nick Mathewson
fdc629736e Only add libevent_core.la to LIBADD on mingw
Chris Davis reports that this is also necessary to fix building with
shared libraries on OSX for him.  Should fix bug 2997775.

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

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

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

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

Reported by Gernot Tenchio.  Fixes sf bug 2996541
2010-05-04 12:57:40 -04:00
Nick Mathewson
20fda296c5 Try /proc on Linux as entropy fallback; use sysctl as last resort
It turns out that the happy fun Linux kernel is deprecating sysctl,
and using sysctl to fetch entropy will spew messages in the kernel
logs.  Let's not do that.  Instead, let's call sysctl for our
entropy only when all other means fail.

Additionally, let's add another means, and try
/proc/sys/kernel/random/uuid if /dev/urandom fails.
2010-05-03 13:00:00 -04:00
Frank Denis
71afc52580 Fix nonstandard TAILQ_FOREACH_REVERSE() definition
Every current BSD system providing TAILQ_* macros define
TAILQ_FOREACH_REVERSE in this order:

TAILQ_FOREACH_REVERSE(var, head, field, headname)

However, libevent defines it in another order:

TAILQ_FOREACH_REVERSE(var, head, headname, field)

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

-Frank.

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

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

-Frank

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

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

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

The new code adds a static function to handle the array resizing.
2010-04-23 23:55:30 -04:00
Nick Mathewson
94ee1251cb fix a leak when unpausing evrpc requests 2010-04-23 23:55:03 -04:00
Nick Mathewson
96730d3191 Make http_base_test stop leaking an event_base. 2010-04-23 23:13:26 -04:00
Nick Mathewson
d49b92a835 Remove one last bug in last_with_datap logic. Found with valgrind 2010-04-23 23:04:20 -04:00
Niels Provos
9d8edf2ff5 do not leak the request object on persistent connections 2010-04-23 18:59:22 -07:00
Nick Mathewson
a47a4b7e7e 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.
2010-04-23 16:08:09 -04:00
Nick Mathewson
a5bf43abb0 Document evutil_secure_rng_init() and evutil_secure_rng_add_bytes() 2010-04-23 15:46:09 -04:00
Nick Mathewson
f980716707 Make evutil_secure_rng_init() work even with builtin arc4random 2010-04-23 15:46:05 -04:00
Nick Mathewson
71fc3eb08b 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.
2010-04-23 15:46:04 -04:00
Nick Mathewson
b1c795007f Make evdns logging threadsafe
The old logging code was littered with places where we stored messages in
static char[] fields.  This is fine in a single-threaded program, but if you
ever tried to log evdns messages from two threads at once, you'd hit a race.

This patch also refactors evdns's debug_ntop function into a more useful
evutil_sockaddr_port_format() function, with unit tests.
2010-04-23 14:42:25 -04:00
Nick Mathewson
ceefbe8730 Add a comment to explain why evdns_request is now separte from request 2010-04-23 14:04:03 -04:00
Christopher Davis
39b870b8a0 Add dns/search_cancel unit test. 2010-04-22 21:49:05 -07:00
Christopher Davis
67072f3c3b Assert for valid requests as necessary.
A valid request has an associated handle, and the handle must point
to the request.
2010-04-22 21:46:05 -07:00
Christopher Davis
a62584000a Free search state when finished searching to avoid an infinite loop. 2010-04-21 22:20:10 -07:00
Christopher Davis
beaa14a46f 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.
2010-04-21 22:01:59 -07:00
Christopher Davis
15bb82d690 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.
2010-04-21 21:21:21 -07:00
Gilad Benjamini
b84b598eae 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.
2010-04-21 01:20:25 -04:00
Sebastian Sjöberg
899c1dcc98 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)
2010-04-14 15:42:57 -04:00
Nick Mathewson
0861d1708b Add ctags/etags files to .gitignore 2010-04-14 14:41:03 -04:00
Shuo Chen
755fbf16c3 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)
2010-04-14 14:27:29 -04:00
Shuo Chen
07edf784fa 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)
2010-04-14 14:23:03 -04:00
Nick Mathewson
a0983b67f9 Initialize last_with_datap correctly in evbuffer_overlapped
Fixes bug 2985406
2010-04-14 01:17:24 -04:00
Giuseppe Scrivano
3cbca8661f Create shared libraries under Windows 2010-04-13 02:01:04 -04:00
Giuseppe Scrivano
10c4c90450 Do not inhibit automake dependencies generation
It fixes make parallel builds.
2010-04-13 02:01:04 -04:00