Nick Mathewson [Thu, 9 Sep 2010 20:13:09 +0000 (16:13 -0400)]
Bump to the latest version of tinytest
This lets us do without libevent-specific code in tinytest.c, and
lets us add a feature to skip individual tests from the command
line.
Nick Mathewson [Thu, 9 Sep 2010 20:01:42 +0000 (16:01 -0400)]
Make SSL tests cover enabling/disabling EV_READ.
I want my 80% coverage.
Nick Mathewson [Thu, 9 Sep 2010 19:59:18 +0000 (15:59 -0400)]
Bump version to 2.0.7-rc-dev
Nick Mathewson [Thu, 9 Sep 2010 18:59:27 +0000 (14:59 -0400)]
Make all versioning changes for 2.0.7-rc, and add ChangeLog
Christopher Davis [Thu, 9 Sep 2010 18:36:45 +0000 (14:36 -0400)]
Make event_base_virtual_del() notify the base if needed
Nick Mathewson [Thu, 9 Sep 2010 17:43:31 +0000 (13:43 -0400)]
Add a missing time.h include to test/regress_thread.c
Nick Mathewson [Thu, 9 Sep 2010 17:00:54 +0000 (13:00 -0400)]
Fix an uninitialized-variable warning on windows
Christopher Davis [Thu, 9 Sep 2010 03:33:21 +0000 (20:33 -0700)]
Don't decrement virutal event count twice in connect_complete.
Christopher Davis [Thu, 9 Sep 2010 02:55:13 +0000 (19:55 -0700)]
Fix a few Windows compile warnings.
Nick Mathewson [Wed, 8 Sep 2010 18:53:57 +0000 (14:53 -0400)]
Merge branch 'tests'
Nick Mathewson [Wed, 8 Sep 2010 18:52:37 +0000 (14:52 -0400)]
Merge remote branch 'github/win_notify'
Nick Mathewson [Wed, 8 Sep 2010 18:52:24 +0000 (14:52 -0400)]
Add a missing header for regress_thread.c
Nick Mathewson [Wed, 8 Sep 2010 18:40:51 +0000 (14:40 -0400)]
Implement EVBASE_NEED_NOTIFY on win32
Sebastian Hahn [Wed, 8 Sep 2010 18:29:39 +0000 (20:29 +0200)]
Fix a compile warning in regress_thread.c
Nick Mathewson [Wed, 8 Sep 2010 18:12:12 +0000 (14:12 -0400)]
Merge remote branch 'chrisd/iocp-fixes4'
Conflicts:
test/regress_thread.c
Nick Mathewson [Wed, 8 Sep 2010 18:00:45 +0000 (14:00 -0400)]
Merge branch 'th_notify_fd_reinit'
Nick Mathewson [Wed, 8 Sep 2010 17:29:06 +0000 (13:29 -0400)]
Improve testing of when thread-notification occurs
Nick Mathewson [Wed, 8 Sep 2010 17:22:55 +0000 (13:22 -0400)]
Minimize calls to base_notify implementation functions, thereby avoiding needless syscalls
The trick here is that if we already told the base to wake up, and it
hasn't woken up yet, we don't need to tell it to wake up again. This
should help lots with inherently multithreaded code like IOCP.
Nick Mathewson [Wed, 8 Sep 2010 17:02:58 +0000 (13:02 -0400)]
Avoid needlessly calling evthread_notify_base() when the loop is not running
Also make sure that we always hold the base lock when calling evthread_notify_base.
Nick Mathewson [Wed, 8 Sep 2010 15:39:24 +0000 (11:39 -0400)]
Merge remote branch 'github/globals'
Christopher Davis [Wed, 1 Sep 2010 18:04:57 +0000 (11:04 -0700)]
Only process up to MAX_DEFERRED deferred_cbs at a time.
If threads queue callbacks while event_process_deferred_callbacks is
running, the loop may spin long enough to significantly skew timers.
A unit test stressing this behavior is also in this commit.
Christopher Davis [Sat, 28 Aug 2010 11:07:48 +0000 (04:07 -0700)]
Add event_config_set_num_cpus_hint for tuning thread pools, etc.
Christopher Davis [Sat, 28 Aug 2010 09:44:11 +0000 (02:44 -0700)]
IOCP-related unit test tweaks
Christopher Davis [Tue, 17 Aug 2010 12:02:00 +0000 (05:02 -0700)]
Some IOCP bufferevent tweaks.
- Increment reference count of bufferevents before initiating overlapped
operations to prevent the destructor from being called while operations
are pending. The only portable way of canceling overlapped ops is to
close the socket.
- Translate error codes to WSA* codes.
- Better handling of errors.
- Add an interface to add and del "virtual" events. Because IOCP
bufferevents don't register any events with the base, the event loop
has no way of knowing they exist. This causes the loop to terminate
prematurely. event_base_{add,del}_virtual increment/decrement base's
event count so the loop runs while there are any enabled IOCP
bufferevents.
Christopher Davis [Sat, 28 Aug 2010 09:08:27 +0000 (02:08 -0700)]
Stop IOCP when freeing the event_base.
Christopher Davis [Mon, 16 Aug 2010 08:23:57 +0000 (01:23 -0700)]
IOCP-related evbuffer fixes.
- Prevent evbuffer_{add,prepend}_buffer from moving read-pinned chains.
- Fix evbuffer_drain to handle read-pinned chains better.
- Raise the limit on WSABUFs from two to MAX_WSABUFS for overlapped reads.
Nick Mathewson [Tue, 7 Sep 2010 14:28:15 +0000 (10:28 -0400)]
Fix a few memory leaks in the tests
Nick Mathewson [Mon, 6 Sep 2010 19:47:07 +0000 (15:47 -0400)]
Move the "function to getsockname() on a listener" to regress_testutils
This reverts commit
fab50488fcb741884ccdfa7b83643eac3e5c9cbf.
The function was, on reflection, not important enough to break the feature
freeze, since it's trivial to build on your own.
Nick Mathewson [Mon, 6 Sep 2010 19:40:13 +0000 (15:40 -0400)]
Merge remote branch 'github/sysqueue_include_order'
Shuo Chen [Mon, 6 Sep 2010 14:10:17 +0000 (10:10 -0400)]
Fix event_del(0) instance in bench.c
Nick Mathewson [Sun, 5 Sep 2010 02:02:32 +0000 (22:02 -0400)]
Merge remote branch 'github/win32_posix_underscore'
Nick Mathewson [Sun, 5 Sep 2010 02:00:38 +0000 (22:00 -0400)]
Merge remote branch 'github/cdecl'
Nick Mathewson [Sat, 4 Sep 2010 02:00:25 +0000 (22:00 -0400)]
Fix uninitialized port var in http_delete_test. Last one, I hope.
Nick Mathewson [Sat, 4 Sep 2010 01:03:25 +0000 (21:03 -0400)]
Fix uninitialized variables in http_bad_request_test. (oops)
Nick Mathewson [Fri, 3 Sep 2010 22:48:31 +0000 (18:48 -0400)]
Allow more than one copy of regression tests to run at once
Mostly this was a matter of just removing all the hardwired ports in
the test code. The http/connection_retry test is still a little
screwy, though.
Nick Mathewson [Fri, 3 Sep 2010 20:42:16 +0000 (16:42 -0400)]
Expose a function to add a nameserver by sockaddr
Nick Mathewson [Fri, 3 Sep 2010 20:41:16 +0000 (16:41 -0400)]
Expose a function to getsockname() on a listener's fd.
Nick Mathewson [Fri, 3 Sep 2010 19:12:35 +0000 (15:12 -0400)]
Prefer autoreconf -ivf to manual autogen.sh
Suggested by Ralph Castain
Nick Mathewson [Thu, 2 Sep 2010 17:21:17 +0000 (13:21 -0400)]
Fix pointer-to-__cdecl-function syntax
Nick Mathewson [Thu, 2 Sep 2010 15:10:50 +0000 (11:10 -0400)]
Use the _func() replacements for open, fstat, etc in evutil.c on win32
Remember that in a fit of ANSI C compliance, Microsoft decided to
screw portability by renaming basically all the functions in unistd.h to
get prefixed with an understore.
For some reason, mingw didn't seem to mind, but at least some people's
compilers did: see bug
3044490.
Nick Mathewson [Thu, 2 Sep 2010 16:06:58 +0000 (12:06 -0400)]
Declare signal handler function as "__cdecl" on Windows.
I swear, they must have half a dozen different calling conventions.
(goes to check)
Holy crud. They actually do. There's __cdecl, __stdcall, __fastcall,
"thiscall", "naked" and the obsolete "__pascal", "__fortran", and
"__syscall". And don't forget WINAPI and __far.
Anyways, this should fix
3044488 if I got it right.
Nick Mathewson [Thu, 2 Sep 2010 15:36:44 +0000 (11:36 -0400)]
Move evkeyvalq into a separate header for evhttp_parse_query users
The evhttp_parse_query API is a bit misdesigned; all the other
evkeyvalq stuff is abstract and lets you get away with having a header
stub, but evhttp_parse_query seems to require that you instantiate an
empty evkeyvalq of your own.
Nick Mathewson [Thu, 2 Sep 2010 15:27:57 +0000 (11:27 -0400)]
Declare evkeyvalq and event_list even if event_struct.h comes before sys/queue.h
Fixes bug
3036645 reported by Mihai Draghicioiu
Nick Mathewson [Wed, 1 Sep 2010 20:36:30 +0000 (16:36 -0400)]
Close th_notify_fds and open a new pair on reinit
After a fork, you want subthreads to wake up the event_base in the
child process, not to have the child process and the main process
fight over who wakes up whom.
Related to a problem found by Nicholas Marriott while debugging
3048812.
Nick Mathewson [Wed, 1 Sep 2010 20:03:39 +0000 (16:03 -0400)]
On windows, make lock/thread function tables static
This requires us to have a separate implementation of the lock macros
that indirects to a set of functions. Fortunately, this isn't too
hard to do.
This may be a fix for bug
3042969, where our openssl dll and our
libevent dll each got their own version of the thread stuff.
Nick Mathewson [Wed, 1 Sep 2010 19:56:22 +0000 (15:56 -0400)]
Make defer-internal.h use lock macros, not direct cess to lock fns
Nick Mathewson [Wed, 1 Sep 2010 19:01:39 +0000 (15:01 -0400)]
Stop using global arrays to implement the EVUTIL_ctype functions
These apparently made libtool sad on win32, and the function call
overhead here should be negligable anyway.
Nick Mathewson [Mon, 30 Aug 2010 15:35:06 +0000 (11:35 -0400)]
Fix a bug in our win32 condition implementation
The do ... while loop in our wait code could spin while waiting
because the event object wasn't reset until there were no longer any
events waiting to be woken up. We also want to reset the event object
if the count of events to wake up reaches zero.
Found by Chris Davis. Fixes bug
3053358.
Nick Mathewson [Thu, 26 Aug 2010 19:09:58 +0000 (15:09 -0400)]
Fix an issue with forking and signal socketpairs in select/poll backends
Nicholas Marriott identifies an issue where a signal socketpair
doesn't get recreated if the event backend doesn't set event_reinit.
See bug
3048812
There may be a similar issue with respect to th_notify_fd
Nick Mathewson [Tue, 17 Aug 2010 18:44:12 +0000 (14:44 -0400)]
Rename regress_pthread.c to regress_thread.c
Nick Mathewson [Mon, 23 Aug 2010 16:01:45 +0000 (12:01 -0400)]
Detect events with no ev_base; warn instead of crashing
Nick Mathewson [Mon, 23 Aug 2010 15:48:46 +0000 (11:48 -0400)]
Honor NDEBUG; build without warnings with NDEBUG; make NDEBUG always-off in unit test code
Nick Mathewson [Thu, 19 Aug 2010 18:00:06 +0000 (14:00 -0400)]
Avoid deadlock when activating signals.
Fixes bug
3048812.
Based on patch by Nicholas Marriott.
Nick Mathewson [Thu, 19 Aug 2010 13:38:44 +0000 (09:38 -0400)]
Fix kquue correctness test on x84_64
Apparently, in our configure.in check for a working kqueue, we were
leaving some fields unset that seemed to irritate 64-bit kqueue a lot.
Found by Christopher Layne
Nick Mathewson [Wed, 18 Aug 2010 16:02:25 +0000 (12:02 -0400)]
Fix logic error in win32 TRY_LOCK that caused problems with rate-limiting
Nick Mathewson [Wed, 18 Aug 2010 14:49:12 +0000 (10:49 -0400)]
Set close-on-exec bit for filedescriptors created by dns subsystem.
Based on patch for 1.4 by Ralf Schmitt.
Nick Mathewson [Tue, 17 Aug 2010 17:26:03 +0000 (13:26 -0400)]
Correctly detect failure to delete bufferevent read-timeout event
Gilad Benjamini noted that we check the error code for deleting a
write-timeout event twice, and the read timeout not at all. This
shouldn't be a bit problem, since it's really hard for a delete to
fail on a timeout-only event, but it's worth fixing.
Fixes bug
3046787
Nick Mathewson [Tue, 17 Aug 2010 02:55:45 +0000 (22:55 -0400)]
Add a unit test for conditions
Nick Mathewson [Mon, 16 Aug 2010 16:38:22 +0000 (12:38 -0400)]
Make the regress_pthread.c tests work on windows with current test APIs
Nick Mathewson [Tue, 17 Aug 2010 17:18:18 +0000 (13:18 -0400)]
Use conditions instead of current_event_lock to fix a deadlock.
Avi Bab correctly noted as bug
3044479 the fact that any thread
blocking on current_event_lock will do so while holding
th_base_lock, making it impossible for the currently running event's
callback to call any other functions that require th_base_lock.
This patch switches the current_event_lock code to instead use a
condition variable that we wait on if we're trying to mess with
a currently-executing event, and that we signal when we're done
executing a callback if anybody is waiting on it.
Nick Mathewson [Tue, 17 Aug 2010 17:15:34 +0000 (13:15 -0400)]
Add a condition variable backend, with implementations for pthreads and win32
The interface from the user's POV is similar to the locking
implementation: either provide a structure full of function
pointers, or just call evthread_use_*_threads() and everything will
be okay.
The internal interface is meant to vaguely resemble pthread_cond_*,
which Windows people will better recognize as *ConditionVariable*.
Gilad Benjamini [Fri, 13 Aug 2010 21:19:18 +0000 (17:19 -0400)]
Make definition of WIN32_LEAN_AND_MEAN in event.h conditional.
(Inclusion order might trigger a warning for redefinition on Windows.)
Gilad Benjamini [Fri, 13 Aug 2010 21:08:59 +0000 (17:08 -0400)]
Clean up syntax on TAILQ_ENTRY() usage
Though the C standards allow it, it's apparently possible to get MSVC
upset by saying "struct { int field; } (declarator);" instead of
"struct {int field; } declarator;", so let's just not do that.
Bugfix for
3044492
(commit msg by nickm)
Nick Mathewson [Fri, 13 Aug 2010 15:41:37 +0000 (11:41 -0400)]
Make include/event2/event-config.h not included in source dist
As a generated file, it shouldn't get included in our source
distribution. Apparently there is an automake incant for this:
nobase_ even stacks with nodist_ .
Nick Mathewson [Fri, 13 Aug 2010 15:34:39 +0000 (11:34 -0400)]
Change include order in Makefile.nmake
If there is an event-config.h in include/event2 (either because we
screwed up packaging like in 2.0.6-rc or because we previously tried
building with mingw and we didn't make distclean in the middle), we
want MSVC to find the one one in WIN32-Code/include/event2 first.
Found by Gilad Benjamini.
Nick Mathewson [Wed, 11 Aug 2010 01:05:52 +0000 (21:05 -0400)]
Update the whatsnew-2.0.txt document
Nick Mathewson [Tue, 10 Aug 2010 19:03:14 +0000 (15:03 -0400)]
Document that DNS_NO_SEARCH is an obsolete alias for DNS_QUERY_NO_SEARCH
Nick Mathewson [Tue, 10 Aug 2010 19:02:50 +0000 (15:02 -0400)]
Completely remove the (mostly-removed) obsolete thread functions.
Nick Mathewson [Tue, 10 Aug 2010 15:46:00 +0000 (11:46 -0400)]
Merge branch 'more_pkgconfig'
Nick Mathewson [Tue, 10 Aug 2010 15:11:25 +0000 (11:11 -0400)]
Add pkgconfig files for libevent_{openssl,pthreads}
Nick Mathewson [Mon, 9 Aug 2010 16:08:40 +0000 (12:08 -0400)]
Fix a nasty dangling-event bug when using rate-limiting groups
When we freed a bufferevent that was in a rate-limiting group and
blocked on IO, the process of freeing it caused it to get removed
from the group. But removing the bufferevent from the group made
its limits get removed, which could make it get un-suspended and in
turn cause its events to get re-added. Since we would then
immediately _free_ the events, this would result in dangling
pointers.
Fixes bug
3041007.
Nick Mathewson [Sat, 7 Aug 2010 03:22:01 +0000 (23:22 -0400)]
Increment vesion to 2.0.6-rc-dev
Nick Mathewson [Sat, 7 Aug 2010 01:19:44 +0000 (21:19 -0400)]
Increment versions to 2.0.6-rc
Nick Mathewson [Sat, 7 Aug 2010 01:11:01 +0000 (21:11 -0400)]
Changlog and new acknowledgements for 2.0.6-rc
Nick Mathewson [Wed, 7 Jul 2010 20:45:03 +0000 (16:45 -0400)]
Move event-config.h to include/event2
This change means that all required include files are in event2, and
all files not in event2/* are optional.
Nick Mathewson [Fri, 6 Aug 2010 21:13:27 +0000 (17:13 -0400)]
Fix evdns build with -DUNICODE
It turns out that GetProcAddress always takes its second argument as
a C string, regardless of whether unicode is on or not.
Nick Mathewson [Fri, 6 Aug 2010 20:36:23 +0000 (16:36 -0400)]
Fix unit tests with -DUSE_DEBUG enabled
If you were to enable USE_DEBUG and slog through all 700+ MB of
debugging output, you'd find that one of the unit tests failed,
since it tested the debug logging code, but the string it expected
and the string it logged differed by a tab vs 2 spaces.
Nick Mathewson [Fri, 6 Aug 2010 17:34:51 +0000 (13:34 -0400)]
Make test-changelist count cpu usage right on win32
Nick Mathewson [Fri, 6 Aug 2010 17:03:17 +0000 (13:03 -0400)]
Use AF_INET socketpair to test sendfile on Solaris
Nick Mathewson [Fri, 6 Aug 2010 17:01:32 +0000 (13:01 -0400)]
Turn our socketpair() replacement into its own function
This patch splits the formerly windows-only case of evutil_socketpair()
into an (internal-use-only) function named evutil_ersatz_socketpair(), and
makes it build and work right on non-Windows hosts.
We need this for convenience to test sendfile on solaris, where socketpair
can't give you an AF_INET pair, and sendfile() won't work on AF_UNIX.
Christopher Davis [Fri, 6 Aug 2010 13:33:55 +0000 (09:33 -0400)]
Remember to initialize timeout events for bufferevent_async
Fixes segfaults in unit tests.
Nick Mathewson [Thu, 5 Aug 2010 19:57:30 +0000 (15:57 -0400)]
Increase the tolerance in our unit tests for sloppy clocks.
(Apparently openbsd in virtualbox just doesn't keep very accurate time.)
Nick Mathewson [Thu, 5 Aug 2010 19:51:16 +0000 (15:51 -0400)]
Make tests quieter on local dns resolver failure
Nick Mathewson [Wed, 4 Aug 2010 21:31:28 +0000 (17:31 -0400)]
Merge branch 'openssl_ratelim'
Nick Mathewson [Wed, 4 Aug 2010 19:52:32 +0000 (15:52 -0400)]
Fix an assertion bug in test-ratelim
If the rate limit was low enough, then the echo_conns wouldn't finish
inside the 300 msec we allowed for them to close. Instead, count the
number of connections we have, and keep waiting until they are all
closed.
Nick Mathewson [Wed, 4 Aug 2010 19:51:14 +0000 (15:51 -0400)]
Add option to test-ratelim to test min_share
Nick Mathewson [Wed, 4 Aug 2010 19:44:08 +0000 (15:44 -0400)]
Add an interface to expose min_share in ratelimiting groups
Nick Mathewson [Wed, 4 Aug 2010 18:54:38 +0000 (14:54 -0400)]
Fix rate-limit calculation on openssl bufferevents.
When you're doing rate limiting on an openssl connection, you nearly
always want to limit the number of bytes sent and received over the
wire, not the number of bytes read or written over the secure
transport.
Trond Norbye [Sun, 1 Aug 2010 19:39:48 +0000 (21:39 +0200)]
Fixed compilation of sample/le-proxy.c on win32
Nick Mathewson [Sat, 31 Jul 2010 21:10:04 +0000 (17:10 -0400)]
Build more cleanly with NetBSDs that dislike toupper(char)
To be fair, when char can be signed, if toupper doesn't take negative
characters, toupper(char) is a very bad idea. So let's just use the
nice safe EVUTIL_TOUPPER instead. (It explicitly only upcases ASCII,
but we only use it for identifiers that we know to be ASCII anyway).
Joachim Bauch [Fri, 30 Jul 2010 00:32:40 +0000 (20:32 -0400)]
Fix badly-behaved subtest of dns/bufferevent_connect_hostname
The bufferevent_connect_hostname test was specifying AF_INET, but the
gethostbyname test we were using to see what error to expect was using
PF_UNSPEC, leading to possible divergence of results.
Nick Mathewson [Thu, 29 Jul 2010 22:12:05 +0000 (18:12 -0400)]
Improve error message for failed epoll to make debugging easier.
Nick Mathewson [Mon, 26 Jul 2010 18:48:32 +0000 (14:48 -0400)]
Constify a couple of arguments to evdns_server_request_add_*_reply
Nick Mathewson [Thu, 22 Jul 2010 12:38:08 +0000 (14:38 +0200)]
Replace (unused,always 0) is_tcp argument to evdns_add_server_port*() with flags
Since we weren't using it for anything, and we always failed if it was
set, we're allowed to change the future semantics of setting it.
Nick Mathewson [Wed, 21 Jul 2010 12:33:42 +0000 (14:33 +0200)]
Stop asserting when asked for a (unsupported) TCP dns port. Just return NULL.
Mike Smellie [Mon, 19 Jul 2010 03:31:19 +0000 (15:31 +1200)]
Change bufferevent_openssl::do_write so it doesn't call SSL_write with a 0 length buffer
I was running into a problem when using bufferevent_openssl with a
very simple echo server. My server simply bufferevent_read_buffer 'd
data into an evbuffer and then passed that evbuffer straight to
bufferevent_write_buffer.
The problem was every now and again the write would fail for no
apparent reason. I tracked it down to SSL_write being called with the
amount of data to send being 0.
This patch alters do_write in bufferevent_openssl so that it skips
io_vecs with 0 length.
Nick Mathewson [Mon, 19 Jul 2010 13:14:10 +0000 (15:14 +0200)]
Make test/test.sh call test-changelist
Eventually test-changelist should expand to try more cases, maybe
query the status of the actual changelist somehow, and integrate it
with the rest of the unit tests.
Also, add test-changelist to gitignore.
Nick Mathewson [Mon, 19 Jul 2010 13:03:43 +0000 (15:03 +0200)]
Fix whitespace.
Nick Mathewson [Mon, 19 Jul 2010 12:58:08 +0000 (14:58 +0200)]
Remove unused variables in test/test-changelist.c
Mike Smellie [Mon, 19 Jul 2010 01:44:56 +0000 (13:44 +1200)]
Possible fix to 100% cpu usage with epoll and openssl
I'm running a fairly simple bit of test code using libevent2 with epoll and
openssl bufferevents and I've run into a 100% cpu usage problem.
Looking into it 100% usage was caused by epoll_wait constantly
returning write events on the openssl socket when it shouldn't really have
been looking for write events at all (N_ACTIVE_CALLBACKS() was returning 0
also).
Looking a bit deeper eventbuffer_openssl socket seems to be requesting
that the EV_WRITE event be removed when it should, but the event isn't
actually being removed from epoll.
Continuing to follow this I think I've found a bug in
event_changelist_del.
For evpoll event_del calls event_changelist_del which caches the change
which is then actioned later when evpoll_dispatch is called.
In event_changlist_del there is a check so that if the currently changed
action is an add then the cached action is changed to a no-op rather than a
delete (which makes sense). The problem arises if there are more than
two add or delete operations between calls to dispatch, in this case it's
possible that the delete is turned into a no-op when it shouldn't have
been.
For example starting with the event on, a delete followed by an add and
then another delete results in a no-op when it should have been a delete (I
added a fair bit of debug output that seems to confirm this behaviour).
I've applied a small change that checks the original old_event stored with
the change and only converts the delete to a no-op if the event isn't on in
old_event. This seems to have fixed my problem.