2643 Commits

Author SHA1 Message Date
Nick Mathewson
ddd69d391e EVENT_BASE_FLAG_PRECISE_TIMER indicates we want fine timer precision
There are a bunch of backends that can give us a reasonably good
monotonic timer quickly, or a very precise monotonic timer less
quickly.  For example, Linux has CLOCK_MONOTONIC_COARSE (1msec
precision), which is over twice as fast as CLOCK_MONOTONIC.  Since
epoll only lets you wait with 1msec precision,
CLOCK_MONOTONIC_COARSE is a clear win.

On Windows, you've got GetTickCount{,64}() which is fast, and
QueryPerformanceCounter, which is precise but slow.

Note that even in the cases where the underlying timer claims to
have nanosecond resolution, we're still not exposing that via
Libevent.

Note also that "Precision" isn't the same as "Resolution" or
"Accuracy".  A timer's precision is the smallest change that the
clock will register; a timer's resolution is the fineness of its
underlying representation; a timer's accuracy is how much it drifts
with respect to "Real Time", whatever that means.  (Terms and
definitions from PEP 418.)
2012-04-17 13:04:02 -04:00
Nick Mathewson
1fbef7d538 Move use_monotonic and friends into event_base
The use_monotonic field used to be a static field set up at library
setup.  Unfortunately, this makes it hard to give the user a way to
make speed/accuracy tradeoffs about time.  Moving it into event_base
should let the clock implementation become configurable.
2012-04-17 12:44:39 -04:00
Nick Mathewson
b62b31f1f1 Work-around a stupid gcov-breaking bug in OSX 10.6
This only affects the unit tests.

Fix found at http://rachelbythebay.com/w/2011/07/12/forkcrash/
2012-04-11 21:33:51 -04:00
Nick Mathewson
53a07fe2f9 Replace pipe-based notification with EVFILT_USER where possible
Sufficiently recent kqueue implementations have an EVFILT_USER filter
that we can use to wake up an event base from another thread.  When
it's supported, we now use this mechanism rather than our old
(pipe-based) mechanism.  This should save some time and complications
on newer OSX and freebsds.
2012-04-11 16:14:09 -04:00
Nick Mathewson
9bf866f5d1 Merge remote-tracking branch 'github/21_mach_time' 2012-04-09 19:49:58 -04:00
Nick Mathewson
cb653a0027 Do not track use_monotonic field when is no monotonic clock 2012-04-09 18:29:30 -04:00
Nick Mathewson
b8fd6f918b Use mach_absolute_time() for monotonic clock support on OSX. 2012-04-09 18:29:30 -04:00
Nick Mathewson
a969f7e706 Merge pull request #50 from rosslagerwall/simplify-test
Simplify test.sh code significantly.
2012-04-09 08:40:45 -07:00
Nick Mathewson
0af23d5911 Merge branch '21_weakrand' 2012-04-09 11:33:08 -04:00
Nick Mathewson
3aa44159c5 Tweak the new evutil_weakrand_() code
Make its state actually get seeded.

Document it more thoroughly.

Turn its state into a structure.

Fix a bug in evutil_weakrand_range_() where it could return the top of
the range.

Change its return type to ev_int32_t.

Add a quick unit test to make sure that the value of
evutil_weakrand_range_() is in range.
2012-04-09 11:30:46 -04:00
Nicholas Marriott
e86af4b7e5 Change evutil_weakrand_() to avoid platform random()
This change allows us to avoid perturbing the platform's random(), and
to avoid hitting locks on random() in the platform's libc.

evutil_weakrand_() is, well, weak, so we choose here an algorithm that
favors speed over a number of other possibly desirable properties.
We're using a linear congruential generator, and taking our parameters
from those shared by the OpenBSD random() implementation, and
Glibc's fastest random() implementation.

The low bits of a LCG of modulus 2^32 are (notoriously) less random
than the higher bits.  So to generate a random value in a range, using
the % operator is no good; we ought to divide.  We add an
evutil_weakrand_range_() function to do that.

This code also changes the interface of evutil_weakrand_() so that it
now manipulates an explicit seed, rather than having the seed in a
static variable.  This change enables us to use existing locks to
achieve thread-safety, rather than having to rely on an additional lock.

(Patch by Nicholas Marriott; commit message by Nick Mathewson.)
2012-04-09 10:46:32 -04:00
Ross Lagerwall
9b856fd594 Simplify test.sh code significantly.
Also make it easier to add new tests/backends.
2012-04-07 17:32:00 +02:00
Nick Mathewson
d9a5515336 Increment the version to 2.1.1-alpha-dev 2012-04-03 20:30:54 -04:00
Nick Mathewson
6f2337dd0e Merge remote-tracking branch 'origin/patches-2.0' release-2.1.1-alpha 2012-04-03 18:39:30 -04:00
Nick Mathewson
d1a03b2ff1 Backport: provide EVENT_LOG_* names, and deprecate _EVENT_LOG_*
This is a partial backport of cb9da0bf and a backport of c9635349.

Because C doesn't like us to declare identifiers starting with an
underscore, Libevent 2.1 has renamed every such identifier.  The
only change that affects a public API is that the _EVENT_LOG_*
macros have been renamed to start with EVENT_LOG instead.  The old
names are still present, but deprecated.

I'm doing this backport because it represents the deprecation of a
Libevent 2.0 interface, and folks should have the opportunity to
write code that isn't deprecated and works with both 2.0 and 2.1.
2012-04-03 18:31:08 -04:00
Nick Mathewson
3ef4b3532f Merge remote-tracking branch 'origin/patches-2.0' 2012-04-03 17:27:07 -04:00
Nick Mathewson
88b4f0bb0d fix some typos in the 2.1 changelog 2012-04-03 17:26:25 -04:00
Nick Mathewson
3faaad49c4 Bump the version to Libevent 2.1.1-alpha 2012-04-03 17:26:12 -04:00
Nick Mathewson
f775521c31 Fix the website URL in the readme 2012-04-03 17:25:36 -04:00
Nick Mathewson
2dedff36e1 Try to finalize changelog situation for 2.1.1-alpha 2012-04-03 16:50:54 -04:00
Nick Mathewson
ba696dce0b Merge remote-tracking branch 'vm/21_fix_nmake_build' 2012-04-03 16:35:36 -04:00
Nick Mathewson
2bb8f2dd78 Add pending names to the README; add more entries to the changelog 2012-04-03 16:35:26 -04:00
Nick Mathewson
bcf5258533 Include ws2tcpip.h from util.h to get EAI_* definitions.
This is necessary on msvc, to get the EVUTIL_EAI_* values defined properly
2012-04-03 16:24:18 -04:00
Nick Mathewson
2449e0c508 Fix some compilation warnings with msvc 2012-04-03 16:15:49 -04:00
Nick Mathewson
07cb57042d Oops; fix a merge conflict that got committed into event2/event-config.h. Now msvc builds work again. 2012-04-03 16:08:23 -04:00
Nick Mathewson
6c95c6c8a2 Decrease MAX_REQUESTS in test-fdleak
We've got to do this because doing otherwise seems to freak out
windows XP.
2012-04-03 15:44:21 -04:00
Nick Mathewson
14eb28a312 Include util-internal.h earlier in test-dumpevents to fix solaris build
See 95e2455cdbf840b for rationale.
2012-04-03 15:41:12 -04:00
Nick Mathewson
e78baf4a01 Fix compilation with mm-replacement disabled. 2012-04-03 14:54:39 -04:00
Nick Mathewson
13dad99c2f make event_base_get_running_event build with threads disabled. 2012-04-03 14:53:00 -04:00
Nick Mathewson
55e8dc1ba2 Make check-dumpevents work with out-of-tree builds 2012-04-03 14:51:51 -04:00
Nick Mathewson
f7b8200ca7 Make check-dumpevents.py actually get included in the tarballs 2012-04-03 12:36:51 -04:00
Nick Mathewson
93defa2ffc Merge remote-tracking branch 'origin/patches-2.0' 2012-04-03 09:52:40 -04:00
Sebastian Hahn
4a6fd43313 Configure with gcc older than 2.95
I don't know why people use such ancient gcc versions, but the fix seems
straightforward enough to maybe just do it.
2012-04-03 05:37:31 +02:00
Nick Mathewson
e780d4e16c Merge remote-tracking branch 'origin/patches-2.0' 2012-04-02 18:14:26 -04:00
Nick Mathewson
78d67b2973 Missing ) in bufferevent_ratelim.c comment. Found by rransom 2012-04-02 18:13:53 -04:00
Nick Mathewson
4c7ee6b0c9 Add missing ) to changelog; spotted by rransom 2012-04-02 18:12:44 -04:00
Nick Mathewson
620f4a7c8f Add a missing name to the readme. 2012-04-02 17:31:31 -04:00
Nick Mathewson
e08a88d702 Merge branch '21_http_test_timing' 2012-04-01 01:01:50 -04:00
Nick Mathewson
fc23af45d1 Increase duration and tolerance on http/connection_retry test
This takes its runtime back up a little again, but not so high as it
was before.  It appears to address the heisenbug issues of github
nmathewson/libevent issue #49.  So far.
2012-04-01 00:21:55 -04:00
Nick Mathewson
dcab134708 Merge remote-tracking branch 'origin/patches-2.0' 2012-03-30 10:29:08 -04:00
Nick Mathewson
336dcaeaef Fix a compilation error with MSVC 2005 due to use of mode_t
MSVC apparently doesn't have a mode_t defined, though mingw does.

Found by Savg He.
2012-03-30 10:26:50 -04:00
Nick Mathewson
09cbc3dcfb Temporarily disable event_queue_reinsert_timeout
Apparently, now that we have tests for it in main/common_timeout, we
can now see that it sometimes breaks referential integrity somehow.
Since I'd like to get 2.1.1-alpha out the door soon, I'm turning it
off for now.
2012-03-26 23:28:21 -04:00
Nick Mathewson
55e991b27c Make libevent_global_shutdown() idempotent
Two calls to libevent_global_shutdown on your exit path shouldn't
result in a crash.
2012-03-26 17:35:21 -04:00
Nick Mathewson
43d5389c80 Updates for whatsnew-2.1.txt 2012-03-26 14:23:01 -04:00
Nick Mathewson
7f62f4ab2e Merge pull request #48 from rosslagerwall/py-version
Require python version
2012-03-26 11:21:51 -07:00
Ross Lagerwall
029a3db354 Require at least Python 2.4 for check-dumpevents.py. 2012-03-26 20:12:45 +02:00
Nick Mathewson
d8a7853ed0 Merge remote-tracking branch 'origin/patches-2.0' 2012-03-25 18:56:34 -04:00
Nick Mathewson
98e9119fab Fix a typo in the bufferevent documentation 2012-03-25 18:56:15 -04:00
Nick Mathewson
c24f91ad97 Test more bufferevent_ratelim features 2012-03-25 18:55:31 -04:00
Nick Mathewson
c5732fddb0 Add event_base_get_running_event() to get the event* whose cb we are in 2012-03-25 18:54:40 -04:00