2815 Commits

Author SHA1 Message Date
Nick Mathewson
c89b4e63f6 Refactor the functions that run over every event.
Now there are appropriate "for each event", "for each fd", and "for
each signal" helpers that they can use; this makes the code a bit
simpler, and far less duplicated.

This lets me turn back on the functions I disabled when removing
eventlist.

Additionally, check more lists for circularity in
event_base_assert_ok().

Add typedefs for the callback types.

Name fewer things "ctx".

Adds an implementation of Floyd's tortoise-and-hare algorithm to check
for circularity in TAILQs and LISTs, to avoid the abuse of flags that
event_base_assert_ok() was doing before.

Suggested by Dave Hart.
2012-02-20 13:55:23 -05:00
Nick Mathewson
65bc91c210 Fix an "unused return value" warning on write() in signal handler 2012-02-17 10:42:59 -05:00
Nick Mathewson
819e98ac7d Start work on a 2.1 changelog and whats-new 2012-02-16 01:21:42 -05:00
Nick Mathewson
a270728e28 Add another caveat to the TCP_DEFER_ACCEPT documentation 2012-02-15 21:27:52 -05:00
Mark Ellzey
5880e4a1fc Support TCP_DEFER_ACCEPT sockopts for listeners
A listening socket can be enabled with the sockopt
TCP_DEFER_ACCEPT. This informs the kernel to not call the user-land
accept() until real data has been written to the socket.

A new flag LEV_OPT_DEFERRED_ACCEPT has been introduced to
automatically set this option. Optionally
evutil_make_tcp_listen_socket_deferred() can be called manually.

(Tweaked slightly by nickm.)
2012-02-15 21:19:28 -05:00
Nick Mathewson
a220a08139 Merge remote-tracking branch 'github/21_fast_syscalls' 2012-02-15 21:07:44 -05:00
Nick Mathewson
a63ed16186 Merge remote-tracking branch 'origin/patches-2.0' 2012-02-15 20:26:52 -05:00
Nick Mathewson
bec50680a3 Stop crashing in evdns when nameserver probes give a weird error
When a nameserver is down, we periodically try sending a "probe"
message to that nameserver to see if it has come back up.  If a
nameserver comes up, we cancel any pending probe messages.

Cancelling a probe message while handling the probe's response would
result in a access-after-free or a double-free, so when we notice that
we're about to call a nameserver up because of having received a probe
from it, we need to check whether current response is the response
from the probe.

There was a case where we didn't to that, though: when the resolver
gave us an unusual error response to our request that it resolve
google.com.  This is pretty rare, but apparently it can happen with
some weird cacheing nameservers -- the one on the mikrotik router, for
example.  Without this patch, we would crash with a NULL pointer
derefernce.

Thanks to Hannes Sowa for finding this issue and helping me track it
down.
2012-02-15 20:25:31 -05:00
Nick Mathewson
a37cbfdafc Merge remote-tracking branch 'origin/patches-2.0'
Conflicts:
	configure.in
2012-02-14 15:44:03 -05:00
Mark Ellzey
2d67b63853 Changed OPENSSL_LDFLAGS to OPENSSL_LIBADD 2012-02-14 15:37:58 -05:00
Mark Ellzey
9278196847 Added OPENSSL_LDFLAGS env variable which is appended to SSL checks.
If openssl is not installed system-wide or not compiled as a shared library,
some systems require various link flags (e.g., -ld).
2012-02-14 15:01:02 -05:00
Nick Mathewson
2ed4430225 If open(O_CLOEXEC) fails, fall back to fcntl(CLOEXEC)
This is needed for folks who build with recent Linux kernel headers
but run with older kernels.
2012-02-14 11:48:55 -05:00
Nick Mathewson
f088d0c52e Fix up usage of reserved identifiers in ht-internal.h 2012-02-13 18:34:00 -05:00
Nick Mathewson
4900c5f96e Port changes from Tor for ht-internal.h 2012-02-13 18:04:05 -05:00
Nick Mathewson
46e5bb7bdc Invert the sense and the name of HT_CACHE_HASH_VALUES
This is meant to make it easier to merge ht-internal.h back upstream
into Tor.
2012-02-13 17:59:14 -05:00
Nick Mathewson
6c81be746c Synchronize with upstream tinytest 2012-02-13 17:49:17 -05:00
Nick Mathewson
a9dc063ceb Merge in a punctuation fix from upstream tinytest 2012-02-13 17:30:46 -05:00
Nick Mathewson
bbea8d6bc5 Move libevent 1.x headers to include/, to put all public headers in one place. 2012-02-13 12:45:07 -05:00
Nick Mathewson
2793197663 Merge remote-tracking branch 'origin/patches-2.0' 2012-02-11 21:20:47 -05:00
Nick Mathewson
03dce42dfa Tweak the evutil_open_closeonexec patch to work on windows, old unixes.
Windows doesn't have a mode_t as far as I can tell.

Some unixes, iirc, don't like three-argument open without O_CREAT.
2012-02-11 21:17:18 -05:00
Ross Lagerwall
d2b5f7223a Make uses of open() close-on-exec safe by introducing evutil_open_closeonexec.
In a multi-process/threaded environment, opening fds internally
without the close-on-exec flag could leak fds to child processes.
2012-02-11 21:10:22 -05:00
Nick Mathewson
a6503944dd Add a bufferevent_getcb() to find a bufferevent's current callbacks 2012-02-11 12:04:15 -05:00
Nick Mathewson
bf2c5a7797 Also make win32select.c conditional for IDE users 2012-02-10 23:56:49 -05:00
Nick Mathewson
87a7cded02 Merge branch 'ifdef' of git://github.com/rosslagerwall/libevent 2012-02-10 23:52:27 -05:00
Nick Mathewson
de69eb7ba9 Merge remote-tracking branch 'origin/patches-2.0' 2012-02-10 23:51:11 -05:00
Nick Mathewson
0c483170be Add an empty section to the changelog for 2.0.18-stable 2012-02-10 22:20:05 -05:00
Nick Mathewson
c5b6e46488 Merge remote-tracking branch 'origin/patches-2.0' 2012-02-10 22:18:19 -05:00
Nick Mathewson
5a807b7aa2 Correct a name in the credits. oops 2012-02-10 22:17:59 -05:00
Nick Mathewson
8fd7a243e8 Merge remote-tracking branch 'origin/patches-2.0' 2012-02-10 22:16:46 -05:00
Nick Mathewson
2d7bf0f78d Bump version to 2.0.17-stable-dev 2012-02-10 22:16:14 -05:00
Nick Mathewson
2d9154601e Merge remote-tracking branch 'origin/patches-2.0' 2012-02-10 18:50:17 -05:00
Nick Mathewson
83e58ccd30 Update the credits in the readme release-2.0.17-stable 2012-02-10 18:39:31 -05:00
Nick Mathewson
0cdbd642e3 Finalize the changelog 2012-02-10 18:36:10 -05:00
Nick Mathewson
2b0a2c4519 Fix compilation on osx 2012-02-10 18:04:04 -05:00
Nick Mathewson
539466e568 Merge remote-tracking branch 'origin/patches-2.0'
Conflicts:
	Makefile.am
	WIN32-Code/event2/event-config.h
	configure.in
2012-02-10 17:33:50 -05:00
Nick Mathewson
e49e289129 Update copyright notices to 2012 2012-02-10 17:29:53 -05:00
Nick Mathewson
8152b4c2b3 Bump version to 2.0.17-stable 2012-02-10 16:49:05 -05:00
Nick Mathewson
bac906c761 Prefer epoll_create1 on Linuxen that have it 2012-02-10 16:39:46 -05:00
Nick Mathewson
33fca629a6 Save some syscalls when constructing a socket for a bufferevent 2012-02-10 16:33:25 -05:00
Nick Mathewson
713e570ab4 Save some syscalls when creating evdns sockets 2012-02-10 16:32:50 -05:00
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