15 Commits

Author SHA1 Message Date
Dave Hart
b4a29c0a0f Add a magic number to debug_locks to better catch lock-coding errors.
Original description by Dave Hart:

 [This patch contains] the addition of a signature field to debug_lock
 initialized by the alloc routine and verified by the rest, to catch
 invalid lock pointers sooner. That helped me track down a nasty
 problem I had before adding the time.h include to
 libevent-internal.h, where different .c files had different ideas of
 whether event_base had a tod_tv_cache member depending on which
 included time.h before libevent-internal.h.
2011-03-07 23:08:42 -05:00
Kevin Bowling
0915ca0aa6 Include evconfig-private.h in internal files for great good. 2011-01-02 08:43:45 -07:00
Evan Jones
fbe64f216c Use relative includes instead of system includes consistently. 2010-12-02 11:03:55 -05:00
Nick Mathewson
5de2bcb70f 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.
2010-09-01 16:03:39 -04:00
Nick Mathewson
743f866539 Honor NDEBUG; build without warnings with NDEBUG; make NDEBUG always-off in unit test code 2010-08-23 11:49:06 -04:00
Nick Mathewson
d4977b52f0 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*.
2010-08-17 13:15:34 -04:00
Nick Mathewson
3808168d21 Completely remove the (mostly-removed) obsolete thread functions. 2010-08-10 15:02:50 -04:00
Nick Mathewson
ec347b9225 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.
2010-08-06 20:21:27 -04:00
Nick Mathewson
c5bab56002 Remove the obsolete evthread interfaces
These were added in 2.0.1, and deprecated in 2.0.4 and 2.0.5; we've
promised that they would be removed, and warned whenever they were
invoked.  Users should call evthread_set_lock_callbacks instead...  or
ideally just call evthread_use_windows_threads or
evthread_use_pthreads.
2010-05-11 11:44:07 -04:00
Nick Mathewson
17efc1cdfa Update all our copyright notices to say "2010" 2010-03-04 01:38:48 -05:00
Nick Mathewson
e5bbd40ad7 Clean up formatting: use tabs, not 8-spaces, to indent. 2010-02-18 17:44:09 -05:00
unknown
c51bb3c342 Fix a few locking issues on windows. 2009-12-21 16:36:40 -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
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