2452 Commits

Author SHA1 Message Date
Nick Mathewson
2c4b5de16a Restore fast-path event_reinit() for slower backends
We used to use the needs_reinit flag in struct eventop to indicate
whether an event backend had shared state across a fork(), and
therefore would require us to construct a new event backend.  But
when we realized that the signal notification fds and the thread
notification fds would always be shared across forks, we stopped
looking at it.

This patch restores the old behavior so that poll, select, and
win32select don't need to do a linear scan over all pending
fds/signals when they do a reinit.  Their life is hard enough
already.
2012-01-27 14:30:41 -05:00
Nick Mathewson
272033efe5 Make event_reinit() more robust and maintainable
Previously, event_reinit required a bunch of really dubious hacks,
and violated a lot of abstraction barriers to mess around with lists
of internal events and "pretend" to re-add them.

The new (and fairly well commented!) implementation tries to be much
smarter, by isolating the changes as much as possible to the backend
state, and minimizing the amount of abstraction violations.

Specifically, we now use event_del() to remove events we want to
remove, rather than futzing around with queues in event_reinit().
To avoid bogus calls to evsel->del(), we temporarily replace evsel
with a null-object stub.

Also, we now push the responsibility for calling evsel->add() down
into the evmap code, so that we don't actually need to unlink and
re-link all of our events.
2012-01-27 13:54:05 -05:00
Nick Mathewson
4b7baec668 Merge remote-tracking branch 'origin/patches-2.0' 2012-01-26 16:56:33 -05:00
Nick Mathewson
9f9e259fda Better workaround for Linux 3.2 edge-triggered epoll bug
On further investigation, it appears that this problem is limited to
AF_UNIX sockets, so let's just do the test on AF_INET sockets.
2012-01-26 15:04:24 -05:00
Nick Mathewson
2c6b3246fd Merge remote-tracking branch 'origin/patches-2.0' 2012-01-24 17:18:52 -05:00
Nate R
c94a5f2a2c Do a memberwise comparison of threading function tables
Doing a memcmp risks comparing uninitialized padding bytes at the
end of the structure.
2012-01-24 17:15:50 -05:00
Nick Mathewson
95e2455cdb When including an -internal.h header outside the main tree, do so early
Some of our unit tests and sample code need functions and structures
defined in an -internal.h header.  But that can freak out OpenSolaris,
where stdio.h wants to define _FILE_OFFSET_BITS unless it's already
defined, and then evconfig-internal.h defines it.  Regular users
should never ever use our -internal.h headers, so the solution is
to make sure that if we're going to use them ourselves, we do so
before system headers.
2012-01-24 16:08:00 -05:00
Nick Mathewson
b9f7e5fd19 Allow more slop in deferred_cb_skew test; freebsd needs it 2012-01-24 15:58:11 -05:00
Nick Mathewson
ea30a4358c Merge remote-tracking branch 'origin/patches-2.0' 2012-01-24 15:30:51 -05:00
Nick Mathewson
3aa0e8a905 Remove a couple of now-unused variables 2012-01-24 15:30:31 -05:00
Nick Mathewson
438d4ff2bd Make event_base integrity check work on windows 2012-01-24 15:29:39 -05:00
Nick Mathewson
edc6d7d7fa Start writing a changelog for 2.0.17-stable 2012-01-24 15:09:04 -05:00
Nick Mathewson
b77b43fcdf Use test_timeval_diff_eq more consistently 2012-01-24 14:59:37 -05:00
Nick Mathewson
67a1763bc4 Make regression tests run over 3x faster.
This was mainly a matter of reducing timeouts and delays, paying
special attention to every test that took longer than a second to
finish.

We could do better here; IMO anything over .7 sec is probably too
long, but it's a big win as it is.

Remember, interactive computing is a big win over batch processing:
anything that makes you get up and walk away from the terminal might
as well be making you carry your punch cards over to the mainframe.
2012-01-24 14:48:04 -05:00
Nick Mathewson
350a3c400f New evhttp function to adjust initial retry timeout 2012-01-24 14:48:02 -05:00
Nick Mathewson
ab14f7c140 Reduce the timeout in the main/fork test.
There was no reason for it to be so long, except for the lack of a usleep
2012-01-24 14:47:30 -05:00
Nick Mathewson
f25d9d32b1 Add an (internal) usleep function for use by unit tests 2012-01-24 11:42:26 -05:00
Nick Mathewson
18653fcae7 Merge remote-tracking branch 'origin/patches-2.0' 2012-01-24 11:17:06 -05:00
Nick Mathewson
5408ff3b89 Oops:remove an accidentally committed "sleep(1)" in a unit test 2012-01-24 11:16:26 -05:00
Nick Mathewson
10996a1a0b Merge remote-tracking branch 'origin/patches-2.0' 2012-01-24 11:04:56 -05:00
Nick Mathewson
dab91877bc Workaround in the unit tests for an apparent epoll bug in Linux 3.2 2012-01-24 11:04:19 -05:00
Nick Mathewson
fe0afabb59 Merge remote-tracking branch 'origin/patches-2.0'
Conflicts:
	event.c

Edits required in:
        evmap.c
2012-01-24 10:29:31 -05:00
Nick Mathewson
3f18ad1b5f Fix a fd leak in event_reinit()
We were supposed to be closing the ev_signal_pair sockets.
2012-01-23 18:15:44 -05:00
Nick Mathewson
6e41cdc16b Fix a list corruption bug when using event_reinit() with signals present
While re-adding all the events, event_reinit() could add a signal
event, which could then cause evsig_add() to add the
base->sig.ev_signal event.  Later on its merry path through
base->eventqueue, event_reinit() would find that same event and give
it to event_io_add a second time.  This would make the ev_io_next
list for that fd become circular.  Ouch!
2012-01-23 17:59:16 -05:00
Nick Mathewson
3312b02036 Check event_base correctness at end of each unit test 2012-01-23 17:43:35 -05:00
Nick Mathewson
40a3c52d05 Fix compilation of windows evutil_check_ifaddrs 2012-01-22 22:27:16 -05:00
Nick Mathewson
27737d55ae Add function to check referential integrity of an event_base 2012-01-21 12:55:15 -05:00
Nick Mathewson
5683e2b1a8 Merge remote-tracking branch 'github/linked_list'
Conflicts:
	include/event2/event_struct.h
2012-01-20 16:31:20 -05:00
Nick Mathewson
677f23cc22 Merge remote-tracking branch 'origin/patches-2.0' 2012-01-20 11:40:39 -05:00
Catalin Patulea
790f6b3b10 Force strict validation of HTTP version in response.
This sometimes accepted invalid versions like 'ICY' (n = 0, major = undefined, sometimes > 1).
2012-01-20 11:37:38 -05:00
Nick Mathewson
a86a0c0463 Merge remote-tracking branch 'origin/patches-2.0' 2012-01-16 14:47:05 -05:00
Nick Mathewson
7206e8cdd4 Suppress a gcc warning from ignoring fwrite return in http-sample.c
Found by Steve Snyder
2012-01-16 14:45:31 -05:00
Nick Mathewson
26e85fcce4 Merge remote-tracking branch 'origin/patches-2.0' 2012-01-09 16:54:19 -05:00
Nick Mathewson
cba48c7d46 Fix a race condition in the dns/bufferevent_connect_hostname test.
As originally written, the test would only pass if the accept()
callbacks for the evconnlistener were all invoked before the last of
the CONNECTED/ERROR callbacks for the connecting/resolving bufferevent
had its call to event_base_loopexit() complete.  But this was only
accidentally true in 2.0, and might not be true at all in 2.1 where
we schedule event_base_once() callbacks more aggressively.

Found by Sebastian Hahn.
2012-01-09 16:44:53 -05:00
Nick Mathewson
d5a3fe5f3e Merge remote-tracking branch 'origin/patches-2.0' 2012-01-09 12:00:04 -05:00
Nick Mathewson
ecfc720a4f Make evconnlistener work around bug in older Linux when getting nmapped
Older Linuxes sometimes respond to some nmap probes by having accept()
return a success but with socklen 0.  That can lead to confusing behavior
when you go to process the sockaddr.
2012-01-09 11:49:41 -05:00
Nick Mathewson
f032516718 Remove bogus casts of socket to int before calling ev_callback
This should make 64-bit windows act better.

Found by Mark Heily.
2012-01-09 11:33:38 -05:00
Nick Mathewson
0586c25ec8 Merge remote-tracking branch 'origin/patches-2.0' 2011-12-14 16:28:18 -05:00
Arno Bakker
da70fa705b Backport evhttp_connection_get_bufferevent to Libevent 2.0
Backport by Arno Bakker; original implementation in 8d3a8500f4
2011-12-14 16:17:19 -05:00
Nick Mathewson
cac02fadc2 Merge remote-tracking branch 'origin/patches-2.0' 2011-12-08 14:38:04 -05:00
Nick Mathewson
7bbf6ca771 Slightly clarify evbuffer_peek documentation 2011-12-08 14:36:35 -05:00
Zack Weinberg
c986f2321d Fix behavior of evbuffer_peek(buf,-1,NULL,NULL,0)
(Patch altered by nickm to not affect the behavior of
evbuffer_peek(buf,-1,NULL,vec,n_vec).)
2011-12-08 14:31:09 -05:00
Nick Mathewson
e0f0dbf99f Remove some accidentally-committed debugging code 2011-12-08 14:11:30 -05:00
Nick Mathewson
5c7675cc5a whitespace fixes 2011-12-08 14:05:47 -05:00
Nick Mathewson
de5428e7d5 Merge remote-tracking branch 'fancycode/buffer_references'
Conflicts:
	buffer.c
2011-12-08 14:04:04 -05:00
Nick Mathewson
d430602863 Merge remote-tracking branch 'origin/patches-2.0'
Conflicts:
	configure.in
2011-12-08 11:43:04 -05:00
Mike Frysinger
358c745e54 check for sysctl before we use it
Not all C libraries under Linux support the sysctl() func.
2011-12-08 11:39:48 -05:00
Nick Mathewson
88a30ad880 Split up extra-long AC_CHECK_FUNCS/HEADERS lines in configure.in 2011-12-07 18:29:06 -05:00
Nick Mathewson
56c6afe26a Merge branch '21_ifaddr' 2011-12-07 18:17:34 -05:00
Nick Mathewson
7085a4568c Use getifaddrs to detect our interfaces if possible
The old scheme involved connected UDP sockets and getsockname(), and is
generally best avoied.
2011-12-07 18:16:32 -05:00