]> granicus.if.org Git - libevent/log
libevent
14 years agoFix signed/unsigned warnings on opensolaris, where iov_len is signed
Nick Mathewson [Thu, 14 Oct 2010 17:48:40 +0000 (13:48 -0400)]
Fix signed/unsigned warnings on opensolaris, where iov_len is signed

14 years agoFix -Wsigned-compare warnings in test/*
Nick Mathewson [Thu, 14 Oct 2010 17:16:41 +0000 (13:16 -0400)]
Fix -Wsigned-compare warnings in test/*

14 years agoadd limits.h to event_tagging.c so opensolaris will build
Nick Mathewson [Thu, 14 Oct 2010 17:16:00 +0000 (13:16 -0400)]
add limits.h to event_tagging.c so opensolaris will build

14 years agofix a signed/unsigned warning in kqueue.c
Nick Mathewson [Thu, 14 Oct 2010 17:15:32 +0000 (13:15 -0400)]
fix a signed/unsigned warning in kqueue.c

14 years agoNew unit test for ssl bufferevents starting with connected SSLs.
Nick Mathewson [Thu, 14 Oct 2010 15:44:32 +0000 (11:44 -0400)]
New unit test for ssl bufferevents starting with connected SSLs.

14 years agoFix a case where an ssl bufferevent with CLOSE_ON_FREE didn't close its fd
Nick Mathewson [Thu, 14 Oct 2010 15:41:10 +0000 (11:41 -0400)]
Fix a case where an ssl bufferevent with CLOSE_ON_FREE didn't close its fd

This could happen when we got an SSL with a BIO already set on it.

14 years agoAvoid spurious reads from just-created open openssl bufferevents
Nick Mathewson [Thu, 14 Oct 2010 14:53:26 +0000 (10:53 -0400)]
Avoid spurious reads from just-created open openssl bufferevents

When handshaking, we listen for reads or writes from the
transport. But when we're connected, we start out with writes enabled
and reads disabled, which means we should not have the transport read
for us.

14 years agoThe corrected bufferevent filter semantics let us fix our openssl tests
Nick Mathewson [Fri, 8 Oct 2010 05:09:02 +0000 (01:09 -0400)]
The corrected bufferevent filter semantics let us fix our openssl tests

14 years agoCorrect logic on disabling underlying bufferevents when disabling a filter
Nick Mathewson [Fri, 8 Oct 2010 04:59:02 +0000 (00:59 -0400)]
Correct logic on disabling underlying bufferevents when disabling a filter

Previously, whenever writing was disabled on a bufferevent_filter (or
a filtering SSL bufferevent), we would stop writing on the underlying
bufferevent.  This would make for trouble, though, since if you
implemented common patterns like "stop writing once data X has been
flushed", your bufferevent filter would disable the underlying
bufferevent after the data was flushed to the underlying bufferevent,
but before actually having it written to the network.

Now, we have filters leave their underlying bufferevents enabled for
reading and writing for reading and writing immediately.  They are not
disabled, unless the user wants to disable them, which is now allowed.
To handle the case where we want to choke reading on the underlying
bufferevent because the filter no longer wants to read, we use
bufferevent_suspend_read().  This is analogous to the way that we use
bufferevent_suspend_write() to suspend writing on a filtering
bufferevent when the underlying bufferevent's output buffer has hit
its high watermark.

14 years agoFix serious bugs in per-bufferevent rate-limiting code
Nick Mathewson [Tue, 12 Oct 2010 17:46:14 +0000 (13:46 -0400)]
Fix serious bugs in per-bufferevent rate-limiting code

Our old code was too zealous about deleting the refill events that
would actually make connections able to read or write again after
they had run out of bandwidth.  Under some circumstances, this could
cause a bufferevent to never actually refill one of its
rate-limiting buckets.

Also, the code treated setting a per-connection rate-limit on a
connection that already had a group-limit as if it were changing the
limit on a connection whose allocation had already run out.

This patch fixes both of those problems.

14 years agoHandle rate-limiting for reading on OpenSSL bufferevents correctly.
Nick Mathewson [Tue, 12 Oct 2010 16:59:13 +0000 (12:59 -0400)]
Handle rate-limiting for reading on OpenSSL bufferevents correctly.

We were looking at the number of bytes read on the wbio, not in the
rbio.  But these are usually different BIOs, and the reading is
supposed to happen on the rbio.

14 years agoMerge branch '20_internal_prio'
Nick Mathewson [Sat, 9 Oct 2010 04:02:31 +0000 (00:02 -0400)]
Merge branch '20_internal_prio'

14 years agoMerge branch 'iovmax'
Nick Mathewson [Fri, 8 Oct 2010 01:06:25 +0000 (21:06 -0400)]
Merge branch 'iovmax'

14 years agoTurn some booleans in evconnlistener_iocp into one-bit bitfields.
Nick Mathewson [Thu, 7 Oct 2010 22:05:01 +0000 (18:05 -0400)]
Turn some booleans in evconnlistener_iocp into one-bit bitfields.

14 years agoMake iocp/listener/error work; don't accept again if lev is disabled.
Christopher Davis [Thu, 7 Oct 2010 20:41:39 +0000 (13:41 -0700)]
Make iocp/listener/error work; don't accept again if lev is disabled.

14 years agoFix allocation error for IOCP listeners. Probably harmless, since struct event is big
Nick Mathewson [Thu, 23 Sep 2010 21:41:49 +0000 (17:41 -0400)]
Fix allocation error for IOCP listeners. Probably harmless, since struct event is big

14 years agoAdd a LEV_OPT_THREADSAFE option for threadsafe evconnlisteners
Nick Mathewson [Thu, 23 Sep 2010 20:49:58 +0000 (16:49 -0400)]
Add a LEV_OPT_THREADSAFE option for threadsafe evconnlisteners

14 years agoFix an EINVAL on evbuffer_write_iovec on OpenSolaris.
Nick Mathewson [Wed, 6 Oct 2010 01:34:07 +0000 (21:34 -0400)]
Fix an EINVAL on evbuffer_write_iovec on OpenSolaris.

The writev() call is limited to at most IOV_MAX iovecs (or UIO_MAXIOV,
depending on whom you ask).  This isn't a problem anywhere we've
tested except on OpenSolaris, where IOV_MAX was a mere 16.

This patch makes us go from "use up to 128 iovecs when writing" to
"use up to 128 iovecs when writing, or IOV_MAX/UIO_MAXIOV, whichever
is less".  This is still wrong if you somehow find a platform that
defines IOV_MAX < UIO_MAXIOV, but I hereby claim that such a platform
is too stupid to worry about for now.

Found by Michael Herf.

14 years agoFix warnings on mingw with gcc 4.5
Nick Mathewson [Tue, 5 Oct 2010 18:29:48 +0000 (14:29 -0400)]
Fix warnings on mingw with gcc 4.5

14 years agoDefine symbolic constants to use in place of SHUT_RD etc
Nick Mathewson [Tue, 5 Oct 2010 17:06:32 +0000 (13:06 -0400)]
Define symbolic constants to use in place of SHUT_RD etc

14 years agoSend a shutdown(SHUT_WR) before closing an http connection
Christopher Davis [Tue, 5 Oct 2010 17:01:54 +0000 (13:01 -0400)]
Send a shutdown(SHUT_WR) before closing an http connection

This avoids getting an ECONNRESET from the TCP stack.

Fixes bug 2928690

14 years agoFix a spurious-call bug on epoll.c
Nick Mathewson [Fri, 1 Oct 2010 03:15:47 +0000 (23:15 -0400)]
Fix a spurious-call bug on epoll.c

We were trying to check whether any events had really been
notified on an fd before calling evmap_io_active on it, but instead
we were checking for an event pointer, which was always true.

In practice, this patch shouldn't change much, since epoll_wait
shouldn't return an event unless there is actually an event going
on.

Spotted by an anonymous bug reporter on Sourceforge.  Closes bug
3078425.

14 years agoMerge remote branch 'github/signed_compare'
Nick Mathewson [Tue, 28 Sep 2010 05:09:17 +0000 (01:09 -0400)]
Merge remote branch 'github/signed_compare'

14 years agoMerge remote branch 'github/win_lib'
Nick Mathewson [Mon, 27 Sep 2010 20:05:20 +0000 (16:05 -0400)]
Merge remote branch 'github/win_lib'

14 years agoDo not search outside of the system directory for windows DLLs
Nick Mathewson [Mon, 27 Sep 2010 19:12:55 +0000 (15:12 -0400)]
Do not search outside of the system directory for windows DLLs

Hardens against some attacks.

14 years agoFix compile in kqueue.c
Sebastian Hahn [Mon, 27 Sep 2010 19:14:28 +0000 (21:14 +0200)]
Fix compile in kqueue.c

Commit 38d09606 removed the evsigbase pointer, but forgot to remove
an assignment to it in kqueue.c.

14 years agoFix all warnings in the main codebase flagged by -Wsigned-compare
Nick Mathewson [Fri, 24 Sep 2010 02:45:55 +0000 (22:45 -0400)]
Fix all warnings in the main codebase flagged by -Wsigned-compare

Remember, the code
   int is_less_than(int a, unsigned b) {
      return a < b;
   }
is buggy, since the C integer promotion rules basically turn it into
   int is_less_than(int a, unsigned b) {
      return ((unsigned)a) < b;
   }
and we really want something closer to
   int is_less_than(int a, unsigned b) {
      return a < 0 || ((unsigned)a) < b;
   }
.

Suggested by an example from Ralph Castain

14 years agoUnit tests for listener error callbacks
Nick Mathewson [Thu, 23 Sep 2010 18:23:45 +0000 (14:23 -0400)]
Unit tests for listener error callbacks

14 years agoAdd error callback to evconnlistener
Simon Perreault [Mon, 20 Sep 2010 16:47:39 +0000 (12:47 -0400)]
Add error callback to evconnlistener

14 years agoMake event.c debugging messages report fds
Nick Mathewson [Wed, 22 Sep 2010 02:44:39 +0000 (22:44 -0400)]
Make event.c debugging messages report fds

14 years agoMake debugging output for epoll backend more comprehensive
Nick Mathewson [Wed, 22 Sep 2010 02:23:32 +0000 (22:23 -0400)]
Make debugging output for epoll backend more comprehensive

14 years agoPut internal events at highest priority
Nick Mathewson [Fri, 17 Sep 2010 04:24:50 +0000 (00:24 -0400)]
Put internal events at highest priority

(If we allow user events to starve internal events, then internal events
never actually happen, signals don't get acked, etc)

14 years agoRemove event_base.evsigbase; nothing used it.
Nick Mathewson [Wed, 15 Sep 2010 16:50:31 +0000 (12:50 -0400)]
Remove event_base.evsigbase; nothing used it.

14 years agoRemove the now-useless evsig_caught and evsig_process
Nick Mathewson [Wed, 15 Sep 2010 05:54:51 +0000 (01:54 -0400)]
Remove the now-useless evsig_caught and evsig_process

14 years agoMake default signal backend fully threadsafe
Nick Mathewson [Wed, 15 Sep 2010 05:40:02 +0000 (01:40 -0400)]
Make default signal backend fully threadsafe

Jason Toffaletti discovered with helgrind that our signal handler was
messing with evsig_base, which can be set from lots of places in the
code.  Ordinarly, we'd just stick a lock on it, except that it is
illegal (and genuinely error-prone) to call pthread_mutex_acquire()
from inside a signal handler.

The solution is to only store the fd we write to in a static variable,
write the signal number to the fd, and put evsig_cb in charge of
activating signal events.

I have no idea how we'll cope if we want to enable this to handle
siginfo (where available) in the future.

14 years agoWarn when using the error-prone EV_SIGNAL interface in an error-prone way. Also...
Nick Mathewson [Wed, 15 Sep 2010 05:08:39 +0000 (01:08 -0400)]
Warn when using the error-prone EV_SIGNAL interface in an error-prone way.  Also, fix a couple of race conditions in signal.c

When using the signal.c signal backend, Libevent currently only allows
one event_base to actually receive signals at a time.  (This has been
the behavior since at least 1.4 and probably much earlier.)  Now, we
detect and warn if you're likely to be racing about which signal goes
to which thread.

We also add a lock to control modifications of the evsig_base field,
to avoid race conditions like those found by Jason Toffaletti.

Also, more comments.  Comments are good.

14 years agoObey enabled status when unsuspending
Simon Perreault [Thu, 9 Sep 2010 21:19:20 +0000 (17:19 -0400)]
Obey enabled status when unsuspending

14 years agoBump to the latest version of tinytest
Nick Mathewson [Thu, 9 Sep 2010 20:13:09 +0000 (16:13 -0400)]
Bump to the latest version of tinytest

This lets us do without libevent-specific code in tinytest.c, and
lets us add a feature to skip individual tests from the command
line.

14 years agoMake SSL tests cover enabling/disabling EV_READ.
Nick Mathewson [Thu, 9 Sep 2010 20:01:42 +0000 (16:01 -0400)]
Make SSL tests cover enabling/disabling EV_READ.

I want my 80% coverage.

14 years agoBump version to 2.0.7-rc-dev
Nick Mathewson [Thu, 9 Sep 2010 19:59:18 +0000 (15:59 -0400)]
Bump version to 2.0.7-rc-dev

14 years agoMake all versioning changes for 2.0.7-rc, and add ChangeLog release-2.0.7-rc
Nick Mathewson [Thu, 9 Sep 2010 18:59:27 +0000 (14:59 -0400)]
Make all versioning changes for 2.0.7-rc, and add ChangeLog

14 years agoMake event_base_virtual_del() notify the base if needed
Christopher Davis [Thu, 9 Sep 2010 18:36:45 +0000 (14:36 -0400)]
Make event_base_virtual_del() notify the base if needed

14 years agoAdd a missing time.h include to test/regress_thread.c
Nick Mathewson [Thu, 9 Sep 2010 17:43:31 +0000 (13:43 -0400)]
Add a missing time.h include to test/regress_thread.c

14 years agoFix an uninitialized-variable warning on windows
Nick Mathewson [Thu, 9 Sep 2010 17:00:54 +0000 (13:00 -0400)]
Fix an uninitialized-variable warning on windows

14 years agoDon't decrement virutal event count twice in connect_complete.
Christopher Davis [Thu, 9 Sep 2010 03:33:21 +0000 (20:33 -0700)]
Don't decrement virutal event count twice in connect_complete.

14 years agoFix a few Windows compile warnings.
Christopher Davis [Thu, 9 Sep 2010 02:55:13 +0000 (19:55 -0700)]
Fix a few Windows compile warnings.

14 years agoMerge branch 'tests'
Nick Mathewson [Wed, 8 Sep 2010 18:53:57 +0000 (14:53 -0400)]
Merge branch 'tests'

14 years agoMerge remote branch 'github/win_notify'
Nick Mathewson [Wed, 8 Sep 2010 18:52:37 +0000 (14:52 -0400)]
Merge remote branch 'github/win_notify'

14 years agoAdd a missing header for regress_thread.c
Nick Mathewson [Wed, 8 Sep 2010 18:52:24 +0000 (14:52 -0400)]
Add a missing header for regress_thread.c

14 years agoImplement EVBASE_NEED_NOTIFY on win32
Nick Mathewson [Wed, 8 Sep 2010 18:40:51 +0000 (14:40 -0400)]
Implement EVBASE_NEED_NOTIFY on win32

14 years agoFix a compile warning in regress_thread.c
Sebastian Hahn [Wed, 8 Sep 2010 18:29:39 +0000 (20:29 +0200)]
Fix a compile warning in regress_thread.c

14 years agoMerge remote branch 'chrisd/iocp-fixes4'
Nick Mathewson [Wed, 8 Sep 2010 18:12:12 +0000 (14:12 -0400)]
Merge remote branch 'chrisd/iocp-fixes4'

Conflicts:
test/regress_thread.c

14 years agoMerge branch 'th_notify_fd_reinit'
Nick Mathewson [Wed, 8 Sep 2010 18:00:45 +0000 (14:00 -0400)]
Merge branch 'th_notify_fd_reinit'

14 years agoImprove testing of when thread-notification occurs
Nick Mathewson [Wed, 8 Sep 2010 17:29:06 +0000 (13:29 -0400)]
Improve testing of when thread-notification occurs

14 years agoMinimize calls to base_notify implementation functions, thereby avoiding needless...
Nick Mathewson [Wed, 8 Sep 2010 17:22:55 +0000 (13:22 -0400)]
Minimize calls to base_notify implementation functions, thereby avoiding needless syscalls

The trick here is that if we already told the base to wake up, and it
hasn't woken up yet, we don't need to tell it to wake up again.  This
should help lots with inherently multithreaded code like IOCP.

14 years agoAvoid needlessly calling evthread_notify_base() when the loop is not running
Nick Mathewson [Wed, 8 Sep 2010 17:02:58 +0000 (13:02 -0400)]
Avoid needlessly calling evthread_notify_base() when the loop is not running

Also make sure that we always hold the base lock when calling evthread_notify_base.

14 years agoMerge remote branch 'github/globals'
Nick Mathewson [Wed, 8 Sep 2010 15:39:24 +0000 (11:39 -0400)]
Merge remote branch 'github/globals'

14 years agoOnly process up to MAX_DEFERRED deferred_cbs at a time.
Christopher Davis [Wed, 1 Sep 2010 18:04:57 +0000 (11:04 -0700)]
Only process up to MAX_DEFERRED deferred_cbs at a time.

If threads queue callbacks while event_process_deferred_callbacks is
running, the loop may spin long enough to significantly skew timers.
A unit test stressing this behavior is also in this commit.

14 years agoAdd event_config_set_num_cpus_hint for tuning thread pools, etc.
Christopher Davis [Sat, 28 Aug 2010 11:07:48 +0000 (04:07 -0700)]
Add event_config_set_num_cpus_hint for tuning thread pools, etc.

14 years agoIOCP-related unit test tweaks
Christopher Davis [Sat, 28 Aug 2010 09:44:11 +0000 (02:44 -0700)]
IOCP-related unit test tweaks

14 years agoSome IOCP bufferevent tweaks.
Christopher Davis [Tue, 17 Aug 2010 12:02:00 +0000 (05:02 -0700)]
Some IOCP bufferevent tweaks.

- Increment reference count of bufferevents before initiating overlapped
  operations to prevent the destructor from being called while operations
  are pending. The only portable way of canceling overlapped ops is to
  close the socket.

- Translate error codes to WSA* codes.

- Better handling of errors.

- Add an interface to add and del "virtual" events. Because IOCP
  bufferevents don't register any events with the base, the event loop
  has no way of knowing they exist. This causes the loop to terminate
  prematurely. event_base_{add,del}_virtual increment/decrement base's
  event count so the loop runs while there are any enabled IOCP
  bufferevents.

14 years agoStop IOCP when freeing the event_base.
Christopher Davis [Sat, 28 Aug 2010 09:08:27 +0000 (02:08 -0700)]
Stop IOCP when freeing the event_base.

14 years agoIOCP-related evbuffer fixes.
Christopher Davis [Mon, 16 Aug 2010 08:23:57 +0000 (01:23 -0700)]
IOCP-related evbuffer fixes.

- Prevent evbuffer_{add,prepend}_buffer from moving read-pinned chains.
- Fix evbuffer_drain to handle read-pinned chains better.
- Raise the limit on WSABUFs from two to MAX_WSABUFS for overlapped reads.

14 years agoFix a few memory leaks in the tests
Nick Mathewson [Tue, 7 Sep 2010 14:28:15 +0000 (10:28 -0400)]
Fix a few memory leaks in the tests

14 years agoMove the "function to getsockname() on a listener" to regress_testutils
Nick Mathewson [Mon, 6 Sep 2010 19:47:07 +0000 (15:47 -0400)]
Move the "function to getsockname() on a listener" to regress_testutils

This reverts commit fab50488fcb741884ccdfa7b83643eac3e5c9cbf.

The function was, on reflection, not important enough to break the feature
freeze, since it's trivial to build on your own.

14 years agoMerge remote branch 'github/sysqueue_include_order'
Nick Mathewson [Mon, 6 Sep 2010 19:40:13 +0000 (15:40 -0400)]
Merge remote branch 'github/sysqueue_include_order'

14 years agoFix event_del(0) instance in bench.c
Shuo Chen [Mon, 6 Sep 2010 14:10:17 +0000 (10:10 -0400)]
Fix event_del(0) instance in bench.c

14 years agoMerge remote branch 'github/win32_posix_underscore'
Nick Mathewson [Sun, 5 Sep 2010 02:02:32 +0000 (22:02 -0400)]
Merge remote branch 'github/win32_posix_underscore'

14 years agoMerge remote branch 'github/cdecl'
Nick Mathewson [Sun, 5 Sep 2010 02:00:38 +0000 (22:00 -0400)]
Merge remote branch 'github/cdecl'

14 years agoFix uninitialized port var in http_delete_test. Last one, I hope.
Nick Mathewson [Sat, 4 Sep 2010 02:00:25 +0000 (22:00 -0400)]
Fix uninitialized port var in http_delete_test.  Last one, I hope.

14 years agoFix uninitialized variables in http_bad_request_test. (oops)
Nick Mathewson [Sat, 4 Sep 2010 01:03:25 +0000 (21:03 -0400)]
Fix uninitialized variables in http_bad_request_test. (oops)

14 years agoAllow more than one copy of regression tests to run at once
Nick Mathewson [Fri, 3 Sep 2010 22:48:31 +0000 (18:48 -0400)]
Allow more than one copy of regression tests to run at once

Mostly this was a matter of just removing all the hardwired ports in
the test code.  The http/connection_retry test is still a little
screwy, though.

14 years agoExpose a function to add a nameserver by sockaddr
Nick Mathewson [Fri, 3 Sep 2010 20:42:16 +0000 (16:42 -0400)]
Expose a function to add a nameserver by sockaddr

14 years agoExpose a function to getsockname() on a listener's fd.
Nick Mathewson [Fri, 3 Sep 2010 20:41:16 +0000 (16:41 -0400)]
Expose a function to getsockname() on a listener's fd.

14 years agoPrefer autoreconf -ivf to manual autogen.sh
Nick Mathewson [Fri, 3 Sep 2010 19:12:35 +0000 (15:12 -0400)]
Prefer autoreconf -ivf to manual autogen.sh

Suggested by Ralph Castain

14 years agoFix pointer-to-__cdecl-function syntax
Nick Mathewson [Thu, 2 Sep 2010 17:21:17 +0000 (13:21 -0400)]
Fix pointer-to-__cdecl-function syntax

14 years agoUse the _func() replacements for open, fstat, etc in evutil.c on win32
Nick Mathewson [Thu, 2 Sep 2010 15:10:50 +0000 (11:10 -0400)]
Use the _func() replacements for open, fstat, etc in evutil.c on win32

Remember that in a fit of ANSI C compliance, Microsoft decided to
screw portability by renaming basically all the functions in unistd.h to
get prefixed with an understore.

For some reason, mingw didn't seem to mind, but at least some people's
compilers did: see bug 3044490.

14 years agoDeclare signal handler function as "__cdecl" on Windows.
Nick Mathewson [Thu, 2 Sep 2010 16:06:58 +0000 (12:06 -0400)]
Declare signal handler function as "__cdecl" on Windows.

I swear, they must have half a dozen different calling conventions.

(goes to check)

Holy crud.  They actually do.  There's __cdecl, __stdcall, __fastcall,
"thiscall", "naked" and the obsolete "__pascal", "__fortran", and
"__syscall".  And don't forget WINAPI and __far.

Anyways, this should fix 3044488 if I got it right.

14 years agoMove evkeyvalq into a separate header for evhttp_parse_query users
Nick Mathewson [Thu, 2 Sep 2010 15:36:44 +0000 (11:36 -0400)]
Move evkeyvalq into a separate header for evhttp_parse_query users

The evhttp_parse_query API is a bit misdesigned; all the other
evkeyvalq stuff is abstract and lets you get away with having a header
stub, but evhttp_parse_query seems to require that you instantiate an
empty evkeyvalq of your own.

14 years agoDeclare evkeyvalq and event_list even if event_struct.h comes before sys/queue.h
Nick Mathewson [Thu, 2 Sep 2010 15:27:57 +0000 (11:27 -0400)]
Declare evkeyvalq and event_list even if event_struct.h comes before sys/queue.h

Fixes bug 3036645 reported by Mihai Draghicioiu

14 years agoClose th_notify_fds and open a new pair on reinit
Nick Mathewson [Wed, 1 Sep 2010 20:36:30 +0000 (16:36 -0400)]
Close th_notify_fds and open a new pair on reinit

After a fork, you want subthreads to wake up the event_base in the
child process, not to have the child process and the main process
fight over who wakes up whom.

Related to a problem found by Nicholas Marriott while debugging
3048812.

14 years agoOn windows, make lock/thread function tables static
Nick Mathewson [Wed, 1 Sep 2010 20:03:39 +0000 (16:03 -0400)]
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.

14 years agoMake defer-internal.h use lock macros, not direct cess to lock fns
Nick Mathewson [Wed, 1 Sep 2010 19:56:22 +0000 (15:56 -0400)]
Make defer-internal.h use lock macros, not direct cess to lock fns

14 years agoStop using global arrays to implement the EVUTIL_ctype functions
Nick Mathewson [Wed, 1 Sep 2010 19:01:39 +0000 (15:01 -0400)]
Stop using global arrays to implement the EVUTIL_ctype functions

These apparently made libtool sad on win32, and the function call
overhead here should be negligable anyway.

14 years agoFix a bug in our win32 condition implementation
Nick Mathewson [Mon, 30 Aug 2010 15:35:06 +0000 (11:35 -0400)]
Fix a bug in our win32 condition implementation

The do ... while loop in our wait code could spin while waiting
because the event object wasn't reset until there were no longer any
events waiting to be woken up.  We also want to reset the event object
if the count of events to wake up reaches zero.

Found by Chris Davis.  Fixes bug 3053358.

14 years agoFix an issue with forking and signal socketpairs in select/poll backends
Nick Mathewson [Thu, 26 Aug 2010 19:09:58 +0000 (15:09 -0400)]
Fix an issue with forking and signal socketpairs in select/poll backends

Nicholas Marriott identifies an issue where a signal socketpair
doesn't get recreated if the event backend doesn't set event_reinit.

See bug 3048812

There may be a similar issue with respect to th_notify_fd

14 years agoRename regress_pthread.c to regress_thread.c
Nick Mathewson [Tue, 17 Aug 2010 18:44:12 +0000 (14:44 -0400)]
Rename regress_pthread.c to regress_thread.c

14 years agoDetect events with no ev_base; warn instead of crashing
Nick Mathewson [Mon, 23 Aug 2010 16:01:45 +0000 (12:01 -0400)]
Detect events with no ev_base; warn instead of crashing

14 years agoHonor NDEBUG; build without warnings with NDEBUG; make NDEBUG always-off in unit...
Nick Mathewson [Mon, 23 Aug 2010 15:48:46 +0000 (11:48 -0400)]
Honor NDEBUG; build without warnings with NDEBUG; make NDEBUG always-off in unit test code

14 years agoAvoid deadlock when activating signals.
Nick Mathewson [Thu, 19 Aug 2010 18:00:06 +0000 (14:00 -0400)]
Avoid deadlock when activating signals.

Fixes bug 3048812.

Based on patch by Nicholas Marriott.

14 years agoFix kquue correctness test on x84_64
Nick Mathewson [Thu, 19 Aug 2010 13:38:44 +0000 (09:38 -0400)]
Fix kquue correctness test on x84_64

Apparently, in our configure.in check for a working kqueue, we were
leaving some fields unset that seemed to irritate 64-bit kqueue a lot.

Found by Christopher Layne

14 years agoFix logic error in win32 TRY_LOCK that caused problems with rate-limiting
Nick Mathewson [Wed, 18 Aug 2010 16:02:25 +0000 (12:02 -0400)]
Fix logic error in win32 TRY_LOCK that caused problems with rate-limiting

14 years agoSet close-on-exec bit for filedescriptors created by dns subsystem.
Nick Mathewson [Wed, 18 Aug 2010 14:49:12 +0000 (10:49 -0400)]
Set close-on-exec bit for filedescriptors created by dns subsystem.

Based on patch for 1.4 by Ralf Schmitt.

14 years agoCorrectly detect failure to delete bufferevent read-timeout event
Nick Mathewson [Tue, 17 Aug 2010 17:26:03 +0000 (13:26 -0400)]
Correctly detect failure to delete bufferevent read-timeout event

Gilad Benjamini noted that we check the error code for deleting a
write-timeout event twice, and the read timeout not at all.  This
shouldn't be a bit problem, since it's really hard for a delete to
fail on a timeout-only event, but it's worth fixing.

Fixes bug 3046787

14 years agoAdd a unit test for conditions
Nick Mathewson [Tue, 17 Aug 2010 02:55:45 +0000 (22:55 -0400)]
Add a unit test for conditions

14 years agoMake the regress_pthread.c tests work on windows with current test APIs
Nick Mathewson [Mon, 16 Aug 2010 16:38:22 +0000 (12:38 -0400)]
Make the regress_pthread.c tests work on windows with current test APIs

14 years agoUse conditions instead of current_event_lock to fix a deadlock.
Nick Mathewson [Tue, 17 Aug 2010 17:18:18 +0000 (13:18 -0400)]
Use conditions instead of current_event_lock to fix a deadlock.

Avi Bab correctly noted as bug 3044479 the fact that any thread
blocking on current_event_lock will do so while holding
th_base_lock, making it impossible for the currently running event's
callback to call any other functions that require th_base_lock.

This patch switches the current_event_lock code to instead use a
condition variable that we wait on if we're trying to mess with
a currently-executing event, and that we signal when we're done
executing a callback if anybody is waiting on it.

14 years agoAdd a condition variable backend, with implementations for pthreads and win32
Nick Mathewson [Tue, 17 Aug 2010 17:15:34 +0000 (13:15 -0400)]
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*.

14 years agoMake definition of WIN32_LEAN_AND_MEAN in event.h conditional.
Gilad Benjamini [Fri, 13 Aug 2010 21:19:18 +0000 (17:19 -0400)]
Make definition of WIN32_LEAN_AND_MEAN in event.h conditional.

(Inclusion order might trigger a warning for redefinition on Windows.)

14 years agoClean up syntax on TAILQ_ENTRY() usage
Gilad Benjamini [Fri, 13 Aug 2010 21:08:59 +0000 (17:08 -0400)]
Clean up syntax on TAILQ_ENTRY() usage

Though the C standards allow it, it's apparently possible to get MSVC
upset by saying "struct { int field; } (declarator);" instead of
"struct {int field; } declarator;", so let's just not do that.

Bugfix for 3044492

(commit msg by nickm)