1457 Commits

Author SHA1 Message Date
Nick Mathewson
e5cf98795e Clean up formatting: remove trailing spaces 2010-02-18 17:46:56 -05:00
Nick Mathewson
e5bbd40ad7 Clean up formatting: use tabs, not 8-spaces, to indent. 2010-02-18 17:44:09 -05:00
Nick Mathewson
8fdf09c09d Clean up formatting: Disallow space-before-tab. 2010-02-18 17:08:50 -05:00
Nick Mathewson
7515de91fe When connect() succeeds immediately, don't invoke the callback immediately.
We need this to get unit tests to pass on freebsd.
2010-02-18 14:50:44 -05:00
Nick Mathewson
b72be50d7a Add some headers to fix freebsd compilation 2010-02-18 13:52:04 -05:00
Nick Mathewson
1ba6bed89a Add the "compile" script to gitignore. 2010-02-18 13:50:15 -05:00
Nick Mathewson
48a29b6816 Add a unit test for secure rng.
Mostly, this is just to make sure our arc4random_buf() implementation isn't
dumb.
2010-02-18 01:43:37 -05:00
Nick Mathewson
ff2a134d6e Fix getpid() usage on Windows
On Windows, getpid() is _getpid(), and requires that we first include
<process.h>.  arc4random.c previously didn't know that.

Actually, I question whether arc4random needs to do its getpid() tricks
on Windows.  They exist only so that we remember to re-seed the ARC4
cipher whenever we fork... but Windows has no fork(), so I think we're
in the clear.
2010-02-18 00:54:44 -05:00
Nick Mathewson
cb52838fc5 When working without a current event base, don't try to use IOCP listeners
This fixes a bug turned up with the http unit tests, where we create
the evhttp object using an implicit (NULL) event_base.  This failed
pretty badly when we tried to use IOCP-based listeners.  We could
hunt for the current base from inside listener.c in the future, or
get the iocp base some other way, but for now this is probably the safest
solution.
2010-02-18 00:27:35 -05:00
Nick Mathewson
32c6f1bacd Construct Windows locks using InitializeCriticalSectionAndSpinCount
Previously we were using InitializeCriticalSection, which creates a
lock that blocks immediately on contention and waits to be
rescheduled.  This is inefficient; it's better to wait for a little
while before telling the US to reschedule us, in case the lock becomes
available again really soon (since most locks mostly do).

Good pthreads implementations do this automatically.  On Windows,
though, we need to call this magic function, and we need to pick the
spin count ourselves.
2010-02-18 00:27:13 -05:00
Nick Mathewson
ca46d25b01 Merge branch 'arc4random' 2010-02-17 23:02:28 -05:00
Nick Mathewson
e15e1e9486 Add the arc4random.c license to the LICENSE file. 2010-02-17 22:54:43 -05:00
Nick Mathewson
7116bf2314 Fix two unlocked reads in evbuffer.
Some initializers (in evbuffer_read and evbuffer_commit) were reading
the last and/or previous_to_last fields without grabbing the evbuffer
lock.

This may fix a hard-to-trigger race condition or two.
2010-02-15 21:11:41 -05:00
Nick Mathewson
aae7db5256 Update event-config.h version number to match configure.in 2010-02-15 17:53:24 -05:00
Nick Mathewson
60753da0e9 Merge commit 'niels/http_close_connection' 2010-02-15 17:07:26 -05:00
Nick Mathewson
63e868e69f Increment the submicro version number.
We've changed a couple of APIs introduced in 2.0.1-alpha, so it
behooves us to give high-needs apps (like Tor) a way to tell we've
done this.

Sensible apps will just say "is it 2.0.3-alpha or 2.0.4-alpha" and
ignore the existence of 2.0.3-alpha-dev, which is just as it should
be.
2010-02-15 16:45:19 -05:00
Niels Provos
2f782af35b validate close cb on server when client connection closes 2010-02-13 17:04:17 -08:00
Niels Provos
e8a9782c1d clean up terminate_chunked test 2010-02-13 16:59:37 -08:00
Nick Mathewson
4ec8fea68e Make RNG work when we have arc4random() but not arc4random_buf() 2010-02-13 00:11:44 -05:00
Nick Mathewson
3fe60fdf47 Use off_t for the length parameter of evbuffer_add_file 2010-02-12 23:40:13 -05:00
Nick Mathewson
d4de062efc Add an arc4random implementation for use by evdns
Previously, evdns was at the mercy of the user for providing a good
entropy source; without one, it would be vulnerable to various
active attacks.

This patch adds a port of OpenBSD's arc4random() calls to Libevent
[port by Chris Davis], and wraps it up a little bit so we can use it
more safely.
2010-02-11 12:53:32 -05:00
Nick Mathewson
1dd7e6dc3a Remove the 'flags' argument from evdns_base_set_option()
The 'flags' argument made sense when passed to
evdns_(base_)?parse_resolv_conf when it said which parts of the
resolv.conf file to obey.  But for evdns_set_option(), it was really
silly, since you wouldn't be calling evdns_set_option() unless you
actually wanted to set the option.  Its meaning was basically, "set
this to DNS_OPTIONS_ALL unless you want a funny surprise."

evdns_base_set_option was new in 2.0.1-alpha, so we aren't committed
to keeping it source-compatible.
2010-02-05 13:55:12 -05:00
Nick Mathewson
6810bdb101 Always use our own gai_strerror() replacement.
This is necessary if we have any errors that the platform gai_strerror()
doesn't know how to handle.
2010-02-05 13:55:12 -05:00
Nick Mathewson
c18490e642 Add a check to make soure our EVUTIL_AI flags do not conflict with the native ones 2010-02-05 01:09:01 -05:00
Nick Mathewson
cfe7a9ff4c Merge remote branch 'niels/http_chunk' 2010-02-04 10:15:39 -05:00
Nick Mathewson
a7a943106c Fix some additional -DUNICODE issues on win32.
Brodie's patch didn't catch the ones that were new since 1.4.
2010-02-03 23:49:22 -05:00
Brodie Thiesfield
000a33ec83 Make Libevent 1.4.12 build on win32 with Unicode enabled.
This patch fixes calls to the win32 api to explicitly call the char* versions
of the functions. This fixes build failures when libevent is built with the
UNICODE define.
2010-02-03 23:31:44 -05:00
Niels Provos
397818011b make evhttp_send() safe against terminated connections, too 2010-02-03 16:54:18 -08:00
Nick Mathewson
e2d15d81c3 Merge remote branch 'niels/http_chunk' 2010-02-03 17:52:55 -05:00
Niels Provos
93d7369106 do not fail while sending on http connections the client closed.
when sending chunked requests via multiple calls to evhttp_send_reply_chunk,
the client may close the connection before the server is done sending. this
used to cause a crash.

we introduce a new function evhttp_request_get_connection() that allows the
server to determine if the request is still associated with a connection.
If it's not, evhttp_request_free() needs to be called explicitly or the user
can call evhttp_send_reply_end() which just frees the request, too.
2010-02-03 14:34:56 -08:00
Nick Mathewson
60742d581b Add the rest of the integer limits, and add a test for them. 2010-02-03 17:01:45 -05:00
Nick Mathewson
8f65467848 Merge remote branch 'github/http_listener'
Conflicts:
	http.c
2010-02-03 16:25:34 -05:00
Nick Mathewson
85047a6983 Functions to view and manipulate rate-limiting buckets.
We need these for Tor, and other projects probably need them too.  Uses
include:
    - Checking whether bandwidth is mostly-used, and only taking some
      actions when there's plenty of bandwidth.
    - Deducting some non-bufferevent activities from a rate-limit group.
2010-02-03 15:12:04 -05:00
Nick Mathewson
aba1fff33a Add EV_*_MAX macros to event2/util.h to expose limits for ev_* types. 2010-02-03 14:37:42 -05:00
Nick Mathewson
da6135e356 Reduce windows header includes in our own headers.
It turns out that absolutely everything that was including
windows.h was doing so needlessly; our headers don't need it,
so we should just include winsock2.h (since that's where
struct timeval is defined).

Pre-2.0 code will use the old headers, which include windows.h
for them, so we aren't breaking source compatibility with 1.4.

This solves the bug where we were leaving WIN32_LEAN_AND_MEAN
defined, in roughly the same way that buying an automobile
solves the question of what to give your coachman for boxing
day.
2010-02-03 02:09:19 -05:00
Nick Mathewson
27c9a40f15 Fix a dumb typo in ev_intptr_t definitions.
We said "#define ev_uintptr_t" twice instead of ever saying
"#define ev_intptr_t".
2010-02-03 02:08:08 -05:00
Nick Mathewson
e244a2ea74 Add the msvc-generated .lib files to .gitignore. 2010-02-03 01:26:59 -05:00
Nick Mathewson
6c21c895d9 Remove EVUTIL_CHECK_FMT.
This was never supposed to be an exposed API, so its name should have been
more like _EVUTIL_CHECK_FMT.  But it was only used in one place, so let's
just eliminate it.
2010-02-03 01:22:44 -05:00
Nick Mathewson
f6b269498a Deprecate EVENT_FD and EVENT_SIGNAL.
These are old aliases for event_get_fd and event_get_signal, and they
haven't been the preferred way of doing things since 2.0.1-alpha.

For a while, we made them use struct event if it was included, but call
event_get_(fd|signal) if it wasn't.  This was entirely too cute.
2010-02-03 01:16:47 -05:00
Nick Mathewson
d38a7a1931 const-ify a few more functions in event.h 2010-02-02 15:44:10 -05:00
Nick Mathewson
f4190bfb85 Update time-test.c to use event2
time-test.c wasn't crazy, but it used some old interfaces.

There are probably more cleanups and explanations to do beyond the
ones here.
2010-01-27 01:47:36 -05:00
Nick Mathewson
d60a1bd50c Clarify status of example programs
(That is, add comments to say that dns-example and le-proxy are recent and
ugly; event-test is old and ugly.)
2010-01-27 01:46:41 -05:00
Nick Mathewson
becb9f9cd3 Add a new "hello world" sample program 2010-01-27 01:46:23 -05:00
Nick Mathewson
137f2c602f Try to fix a warning in hash_debug_entry
Apparently some 64-bit platforms don't like it when you say

   unsigned hash(void *p)
   {
      return (unsigned)p;
   }

even if you really honestly don't want the high bits of p.  Perhaps
they will tolerate it if I say the equivalent of

   unsigned hash(void *p)
   {
      return (unsigned) (uintptr_t) p;
   }
2010-01-26 12:08:34 -05:00
Nick Mathewson
cef61a2f1b Use ev_[u]intptr_t types in place of [u]intptr_t 2010-01-26 12:08:17 -05:00
Nick Mathewson
1fa4c81c71 Add ev_[u]intptr_t to include/event2/util.h
We already emulate most of the other useful bits of stdint.h, and
we seem to have started to use uintptr_t in a few places throughout
the code.  Let's make sure we can continue to do so even on backwards
platforms that don't do C99.
2010-01-26 12:06:41 -05:00
Nick Mathewson
439aea0d07 Try to untangle the logic in server_port_flush().
The logic that prevented the first loop in this function from being
infinite was rather confusing and hard to follow.  It seems to confuse
some automatic analysis tools as well as me.  Let's try to replace it
with something more comprehensible.
2010-01-25 14:07:01 -05:00
Nick Mathewson
361da8f202 Note a missing ratelim function 2010-01-25 13:54:14 -05:00
Nick Mathewson
a66e947b8b 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.
2010-01-25 13:53:17 -05:00
Nick Mathewson
a19b4a05e6 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.
2010-01-25 13:53:17 -05:00