2675 Commits

Author SHA1 Message Date
Nick Mathewson
af6c9d8ee6 Save syscalls when constructing listener sockets for evhttp 2012-02-10 16:32:32 -05:00
Nick Mathewson
a35f396f28 Use pipes for telling signals to main thread when possible 2012-02-10 16:25:53 -05:00
Nick Mathewson
ca76cd931f Use a wrapper function to create the notification pipe/socketpair/eventfd 2012-02-10 16:15:10 -05:00
Nick Mathewson
4970329a88 The LEV_OPT_CLOSE_ON_EXEC flag now applies to accepted listener sockets too 2012-02-10 16:14:09 -05:00
Nick Mathewson
7e9e289367 Minimize syscalls during socket creation in listener.c 2012-02-10 16:13:30 -05:00
Nick Mathewson
a1c042bfe9 Infrastructure for using faster/fewer syscalls when creating sockets
Linux provides some features that allow avoiding extra calls to
fcntl when creating new nonblocking/close-on-exec sockets, so
we can add wrapper functions to emulate those when they are not
available.

Additionally, even when we are emulating those functions, we can
take a fast path that cuts our fcntl calls in half: we don't need to
look up the previous value of a file's flags when we have just
created it.
2012-02-10 16:11:47 -05:00
Nick Mathewson
e465623a9c Merge remote-tracking branch 'origin/patches-2.0' 2012-02-10 12:05:39 -05:00
Nick Mathewson
5d7bfa1519 In the kqueue backend, do not report EBADF as an EV_READ
We were doing this because of (correct) reports that NetBSD gives an
EBADF when you try to add the write side of a pipe for which the
read side has been closed.  But on most kqueue platforms, that
doesn't happen, and on *all* kqueue platforms, reporting a
nonexistent fd (which we usually have if we have seen EBADF) as
readable tends to give programs a case of the vapors.

Nicholas Marriott wrote the original patch here; I did the comment
fixes.
2012-02-10 11:24:51 -05:00
Nick Mathewson
df19ba6a03 Merge remote-tracking branch 'origin/patches-2.0' 2012-02-09 15:16:02 -05:00
Nick Mathewson
19715a60e2 Avoid crash when freeing event_iocp and using event_set_mem_functions
There was a calloc that needed to be an mm_calloc.

Reported by "fffvvvzz" on sourceforge.  Ticket 3486114
2012-02-09 15:07:19 -05:00
Ross Lagerwall
76d4c929d7 Put #ifdef around some files to support alternate build systems. 2012-02-08 18:46:00 +02:00
Nick Mathewson
6f6cebe356 Bring the changelog up to date 2012-02-06 21:18:25 -05:00
Nick Mathewson
c00416f745 Merge remote-tracking branch 'origin/patches-2.0' 2012-02-06 12:39:09 -05:00
Nick Mathewson
5b4b8126de Loop on filtering SSL reads until we are blocked or exhausted.
This is not a perfect fix, but it's much much better than the
current buggy behavior, which could lead to filtering SSL
connections that just stopped reading.

Based on ideas by Maseeb Abdul Qadir and Mark Ellzey.
2012-02-06 12:37:40 -05:00
Nick Mathewson
4dee4cc7e1 Replace more C99/C++ comments with oldschool /* */ comments 2012-02-02 11:45:23 -05:00
Nick Mathewson
7c46d4aa63 Merge remote-tracking branch 'origin/patches-2.0' 2012-02-02 11:41:37 -05:00
Greg Hewgill
d84d917099 Use C-style comments in C source files (for compatibility with compilers such as xlc on AIX). 2012-02-02 11:39:38 -05:00
Nick Mathewson
032aac156c Merge remote-tracking branch 'origin/patches-2.0' 2012-02-01 14:57:44 -05:00
Nick Mathewson
d6094b160f evdns: fix a bug in circular-queue implementation
found by Wang Qin
2012-02-01 14:56:43 -05:00
Sebastian Hahn
e4a56ed527 Fix a compile warning in event_reinit
Introduced in 272033efe575a9dc7ec6f123a96afba5c69ff1c6
2012-01-31 19:00:24 +01:00
Nick Mathewson
604569bf3f Remove the eventqueue list and the ev_next pointers.
Those pointers were once used to maintain a complete list of
inserted IO and signal events.  But such a list is now available by
walking over ev_io_map and ev_signal_map!  So all they did was
require extra pointer operations to maintain, and extra 8-16 bytes
of storage in each struct event.

To be cowardly and keep the option of going back to having this
redundancy, I'm wrapping the removed code in a set of ifdefs.

This is a first cut; it needs cleanups and stress-testing!!  In
particular, it just plain disables a couple of functions that could
probably be saved.

There seems to be a need for an evmap_{io,signal}_foreach() or something.
2012-01-27 16:35:04 -05:00
Nick Mathewson
7622d2659b Make test-changelist faster 2012-01-27 15:10:28 -05:00
Nick Mathewson
39b3f38d72 Check changelist as part of checking representational integrity 2012-01-27 14:39:18 -05:00
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