1288 Commits

Author SHA1 Message Date
Joachim Bauch
a773df54ce Fix a segfault when freeing SSL bufferevents in an unusual order
Have container bufferevents hold a reference to their underlying bufferevents.

(Commit message and minor revisions by nickm.)
2009-12-18 16:26:40 -05:00
Joachim Bauch
a6adeca72c Fix a segfault when writing a very fragmented evbuffer onto an SSL
Fixes bug 2916328.
2009-12-17 12:38:46 -05:00
Evan Jones
f6430ac1e3 Update sample/signal-test.c to use newer APIs and not leak. 2009-12-08 17:05:30 -05:00
Joachim Bauch
ea6b1df288 Only define _GNU_SOURCE if it is not already defined. 2009-12-08 15:38:34 -05:00
Sebastian Hahn
70cdfe49fa Fix compile on Snow Leopard with gcc warnings enabled 2009-12-06 02:59:19 +01:00
Nick Mathewson
7ae94450fd Fix a snow leopard compile warning in the unit tests.
Reported by Sebastian Hahn.
2009-12-04 16:37:47 -05:00
Nick Mathewson
0d744aa173 Refactor our 'suspend operation' logic on bufferevents.
There are lots of things we do internally in bufferevents to indicate
"the user would like this operation to happen, but we aren't going to
try until some other condition goes away."  Our logic here has gotten
entirely too complicated.

This patch tries to fix that by adding the idea of 'suspend flags' for
read and write.  To say "don't bother reading or writing until
condition X no longer holds," bufferevent_suspend_read/write(bev,
BEV_SUSPEND_X).  When X no longer holds, call
bufferevent_unsuspend_read/write(bev, BEV_SUSPEND_X).

Right now, only the read-watermark logic uses this.
2009-12-04 14:15:17 -05:00
Nick Mathewson
438f9ed26c Add the abilitity to mark some buffer callbacks as never-deferred. 2009-12-04 14:15:17 -05:00
Nick Mathewson
689fc091a5 New EVTHREAD_TRY_LOCK function to try to grab a lock. 2009-12-04 14:15:17 -05:00
Nick Mathewson
2b7abf038f Merge commit 'niels/dnscrash' 2009-12-04 13:49:27 -05:00
Yasuoka Masahiko
6c7c5799a4 Fix a crash when reading badly formatted resolve.conf; from Yasuoka Masahiko 2009-12-04 10:44:46 -08:00
unknown
b62d979b68 Update nmake makefile to build evthread.c 2009-12-02 01:24:37 -05:00
unknown
31687b4d8a Fix regress_iocp.c usage of old lock allocation macros. 2009-12-02 01:22:07 -05:00
Roman Puls
bd6f1babf7 Fix up evthread compilation on windows 2009-12-02 01:15:15 -05:00
William Ahern
56771a3eed Valgrind fix: Clear struct kevent before checking for OSX bug.
William's original commit message:

   Valgrind complains on startup because kq_init passes to kevent only
   a partially initialized structure. The code doesn't expect kevent
   to look at .fflags, .udata, or .data, I suppose, because it merely
   tickles the kernel looking for an error response. But perhaps
   that's unwarranted chuminess (notwithstanding that it's checking
   for an OS X bug), and needless noise nonetheless.
2009-11-29 10:20:46 -05:00
Nick Mathewson
0cd3bb9f3a Improved optional lock debugging.
There were a couple of places in the code where we manually kept lock
counts to make sure we never accessed resources without holding a
lock, and that we never released a lock we didn't have.  The
lock-debugging code already puts counts on _every_ lock when lock
debugging is enabled, so there is no need to keep these counts around
otherwise.  This patch rewrites the ASSERT_FOO_LOCKED macros to all
use a common EVLOCK_ASSERT_LOCKED().

We also teach the lock debugging code to keep track of who exactly
holds each lock, so that EVLOCK_ASSERT_LOCKED() means "locked by this
thread."
2009-11-27 17:36:51 -05:00
Zhuang Yuyao
2df1f82bfa Fix an evdns lock violation.
Original message:

   evdns contains a bug related to thread lock.

   enable thread lock by evthread_use_pthreads() will cause successive
   evdns_base_resolve_ipv4() (and other resolve functions i think) to
   hang on EVDNS_LOCK(base) after one or several successful call to
   evdns_base_resolve_ipv4().
2009-11-27 17:36:51 -05:00
Nick Mathewson
da1718b289 Fix a locking bug in event_base_loop()
We previously were releasing the lock when we exited the main loop
in some ways, but not in others.
2009-11-27 17:36:51 -05:00
Nick Mathewson
d84d8385cd Fix two use-after-free bugs in unit tests spoted by lock debugging 2009-11-27 17:36:51 -05:00
Nick Mathewson
76cd2b70bb Stop passing EVTHREAD_READ and EVTHREAD_WRITE to non-rw locks.
Previously, our default lock model kind of assumed that every lock was
potentially a read-write lock.  This was a poor choice, since
read-write locks are far more expensive than regular locks, and so the
lock API should only use them when we can actually take advantage of
them.  Neither our pthreads or win32 lock implementation provided rw
locks.

Now that we have a way (not currently used!) to	indicate that we
really want a read-write lock, we shouldn't actually say "lock this
for reading" or "lock this for writing" unless we mean it.
2009-11-27 17:36:51 -05:00
Nick Mathewson
347952ffe0 Revise the locking API: deprecate the old locking callbacks and add trylock.
Previously, there was no good way to request different kinds of lock
(say, read/write vs writeonly or recursive vs nonrecursive), or for a
lock function to signal failure (which would be important for a
trylock mode).

This patch revises the lock API to be a bit more useful.  The older
lock calls are still supported for now.

We also add a debugging mode to catch common errors in using the
locking APIs.
2009-11-27 17:36:24 -05:00
Nick Mathewson
e1ffbb82e3 Fix memory-leak of signal handler array with kqueue.
It turns out that kqueue_dealloc wasn't calling evsig_dealloc()
(because it doesn't use the main signal handler logic) so the sh_old
array was leaking.

This patch also introduces a fix in evsig_dealloc() where we set
the sh_old array to NULL when we free it, so that main/fork can pass.
2009-11-21 23:57:44 -05:00
Nick Mathewson
07e9e9b4b1 Parenthesize macro arguments more aggressively 2009-11-20 16:50:55 -05:00
Nick Mathewson
f32b57505e Add a warning about the use of event_initialized. 2009-11-20 16:38:01 -05:00
Nick Mathewson
91fe23fc08 Tolerate code that returns from a fatal_cb.
Also, replace more abort() calls with EVUTIL_ASSERT() or event_errx.
2009-11-20 15:46:04 -05:00
Nick Mathewson
94d00651f4 Add stub header for 2.0.4-alpha changelog. 2009-11-20 12:56:29 -05:00
Nick Mathewson
0af10d5695 Add more people who wrote patches to the acknowledgments
The names came from grepping ChangeLog for 'patch/code from/by'.
2009-11-20 12:47:21 -05:00
Nick Mathewson
0b4272681f Improve the README with more information and links.
(Also, try to test out the new commit script.)
2009-11-20 12:37:47 -05:00
Nick Mathewson
ba3407142b Add a .gitignore file.
.gitignore plays the same role in Git as the svn:ignore property does in
subversion.
2009-11-20 12:17:14 -05:00
Niels Provos
505040a2b5 call it 2.0.3-alpha
svn:r1556
2009-11-20 00:18:35 +00:00
Niels Provos
f169153956 Remove most calls to event_err() in http and deal with memory errors instead
svn:r1555
release-2.0.3-alpha
2009-11-19 23:08:50 +00:00
Niels Provos
986500de4d nick found a race condition in the pthreads test case
svn:r1554
2009-11-19 22:02:33 +00:00
Niels Provos
b8f222e055 On FreeBSD and other OSes, connect can return ECONREFUSED immediately; instead of failing the function call, pretend with faileld in the callback.
svn:r1553
2009-11-19 21:14:31 +00:00
Nick Mathewson
bdfe72f3c5 Documentation adjustments
svn:r1552
2009-11-19 00:21:48 +00:00
Nick Mathewson
7511b6a97c Fix a spelling error and remove some dead code
svn:r1551
2009-11-19 00:21:38 +00:00
Nick Mathewson
f070a4aed2 Do the proper hack for the (Open)BSD getaddrinfo quirk.
From evutil.c:

   Some older BSDs (like OpenBSD up to 4.6) used to believe that
   giving a numeric port without giving an ai_socktype was verboten.
   We test for this so we can apply an appropriate workaround.  If it
   turns out that the bug is present, then:

    - If nodename==NULL and servname is numeric, we build an answer
      ourselves using evutil_getaddrinfo_common().

    - If nodename!=NULL and servname is numeric, then we set
      servname=NULL when calling getaddrinfo, and post-process the
      result to set the ports on it.

   We test for this bug at runtime, since otherwise we can't have the
   same binary run on multiple BSD versions.

svn:r1550
2009-11-18 23:18:55 +00:00
Nick Mathewson
07ce7f9991 Make our failing-connection bufferevent test more tolerant.
I thought we had a way to do connect() that would never fail
immediately, but always wait for a moment before failing.  It
turns out that on FreeBSD it can fail immediately.  This is not
FreeBSD's fault, or even a real bug anywhere but in the unit test.

svn:r1549
2009-11-18 21:17:00 +00:00
Nick Mathewson
cf749e227c Add a temporary workaround for an ssl bug found on FreeBSD.
Basically, we only want to report the 'connected' event because of
the socket connect() finishing when we have an actual socket
bufferevent; on an SSL bufferevent, 'connected' means 'SSL
connection finished.'

This isn't FreeBSD's fault: it just has a connect() that tends to
succeed pretty early.

svn:r1548
2009-11-18 21:16:53 +00:00
Nick Mathewson
9bf124bff6 Build correctly with mm replacement turned off.
svn:r1547
2009-11-18 21:16:47 +00:00
Nick Mathewson
767eb70f50 Fix compilation with threading disabled.
svn:r1546
2009-11-18 21:16:33 +00:00
Nick Mathewson
d7d1f1da09 Move responsibility for IOCP callback into bufferevent_async.
This patch from Chris Davis saves some callback depth, and adds proper
ref-counting to bufferevents when there's a deferred evbuffer callback
inflight.  It could use a couple more comments to really nail down what
its invariants are.

svn:r1543
2009-11-17 20:31:09 +00:00
Nick Mathewson
201d8d0baf Clarify even more about various system-specific problems with getaddrinfo
svn:r1542
2009-11-17 18:29:44 +00:00
Nick Mathewson
9151d000e6 Use the common-case code from getaddrinfo_common *always*; OS differences are just too huge.
svn:r1541
2009-11-17 03:36:43 +00:00
Nick Mathewson
3451c870da Never pass our weird flags to the system getaddrinfo. Make sure there is no overlap between flag values.
svn:r1540
2009-11-17 02:57:32 +00:00
Nick Mathewson
625a261a53 OpenBSD demands that sys/types.h be included before sys/socket.h
svn:r1539
2009-11-17 02:40:14 +00:00
Nick Mathewson
888007f9a4 Windows *does* have getservbyname, no matter what autoconf says.
TODO: figure out why autoconf is confused about this.

svn:r1538
2009-11-17 02:38:19 +00:00
Nick Mathewson
86f5742015 Add two implementations of getaddrinfo: one blocking and one nonblocking.
The entry points are evutil_getaddrinfo and evdns_getaddrinfo respectively.
There are fairly extensive unit tests.

I believe this code conforms to RFC3493 pretty closely, but there are
probably more issues.  It should get tested on more platforms.

This code means we can dump the well-intentioned but weirdly-implemented
bufferevent_evdns and evutil_resolve code.

svn:r1537
2009-11-16 22:25:46 +00:00
Nick Mathewson
72bafc175a Remove the stupid brokenness where DNS option names needed to end with a
colon.

svn:r1536
2009-11-16 22:23:55 +00:00
Nick Mathewson
f9de8670fd Fix a declaration of __func__ in rpcgen.
svn:r1535
2009-11-16 22:23:06 +00:00
Nick Mathewson
18a8cfac39 Prefer calloc(a,b) to malloc(a*b). via openbsd.
svn:r1531
2009-11-15 19:00:12 +00:00