]> granicus.if.org Git - libevent/log
libevent
15 years agoExpose our cached gettimeofday value with a new interface
Nick Mathewson [Mon, 28 Dec 2009 06:40:37 +0000 (01:40 -0500)]
Expose our cached gettimeofday value with a new interface

I've got a two use case that wants this for a fairly sensible purpose:
one external and on internal.

15 years agoImprove readability of evutil_unparse_protoname()
Jardel Weyrich [Mon, 28 Dec 2009 21:03:47 +0000 (16:03 -0500)]
Improve readability of evutil_unparse_protoname()

15 years agoFix a bogus free in evutil_new_addrinfo()
Jardel Weyrich [Mon, 28 Dec 2009 21:01:59 +0000 (16:01 -0500)]
Fix a bogus free in evutil_new_addrinfo()

15 years agoFix an fd leak in evconnlistener_new_bind().
Jardel Weyrich [Mon, 28 Dec 2009 21:01:12 +0000 (16:01 -0500)]
Fix an fd leak in evconnlistener_new_bind().

15 years agoMake evutil_make_socket_nonblocking() leave any other flags alone.
Jardel Weyrich [Mon, 28 Dec 2009 21:00:05 +0000 (16:00 -0500)]
Make evutil_make_socket_nonblocking() leave any other flags alone.

Fixes bug 2922121

15 years agoFix compilation of devpoll.c by adding missing thread includes.
Dagobert Michelsen [Mon, 28 Dec 2009 20:53:01 +0000 (15:53 -0500)]
Fix compilation of devpoll.c by adding missing thread includes.

(Bug 2922156)

15 years agoReplace some cases of uint32_t with ev_uint32_t.
Nick Mathewson [Wed, 23 Dec 2009 12:53:19 +0000 (07:53 -0500)]
Replace some cases of uint32_t with ev_uint32_t.

Spotted by Roman Puls.

15 years agoDo not ignore bufferevent_enable(EV_READ) before bufferevent_connect().
Nick Mathewson [Wed, 23 Dec 2009 12:48:43 +0000 (07:48 -0500)]
Do not ignore bufferevent_enable(EV_READ) before bufferevent_connect().

Previously, we weren't remembering that we wanted to re-add the read
event once the connect was finished.  Now we are.

15 years agoFix up behavior of never-defered callbacks a little
Nick Mathewson [Tue, 22 Dec 2009 20:52:02 +0000 (15:52 -0500)]
Fix up behavior of never-defered callbacks a little

15 years agoSimplify the read high-watermark checking.
Nick Mathewson [Tue, 22 Dec 2009 20:51:39 +0000 (15:51 -0500)]
Simplify the read high-watermark checking.

15 years agoRemove the contents of WIN32-Prj as unmaintained.
Nick Mathewson [Tue, 22 Dec 2009 17:03:46 +0000 (12:03 -0500)]
Remove the contents of WIN32-Prj as unmaintained.

Makefile.nmake is now the preferred way to build with MSVC; the
project files haven't worked properly in ages.

15 years agoUse evutil_socket_t, not int, when logging socket errors.
Nick Mathewson [Tue, 22 Dec 2009 05:58:52 +0000 (00:58 -0500)]
Use evutil_socket_t, not int, when logging socket errors.

15 years agoFix a few locking issues on windows.
unknown [Mon, 21 Dec 2009 21:36:40 +0000 (16:36 -0500)]
Fix a few locking issues on windows.

15 years agoSet all instances of the version number correctly.
Nick Mathewson [Sat, 19 Dec 2009 04:37:50 +0000 (23:37 -0500)]
Set all instances of the version number correctly.

Note that we've made two subtle mistakes: we are supposed to suffix
any non-released version with "-dev", and we're supposed to use the
last byte of the numeric version to indicate whether we have done this.

For example, when 2.0.4-alpha is released, its numeric versin will be
0x 02 00 04 00.  As soon as we tag it, we will change the version in
the git repository to 2.0.4-alpha-dev, whose numeric version will be
0x 02 00 04 01 or something.

15 years agoDrop install-sh from our git repo: a mismatched version could break "make dist"
Nick Mathewson [Fri, 18 Dec 2009 22:04:37 +0000 (17:04 -0500)]
Drop install-sh from our git repo: a mismatched version could break "make dist"

15 years agoFix a segfault when freeing SSL bufferevents in an unusual order
Joachim Bauch [Fri, 18 Dec 2009 21:24:41 +0000 (16:24 -0500)]
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.)

15 years agoFix a segfault when writing a very fragmented evbuffer onto an SSL
Joachim Bauch [Thu, 17 Dec 2009 17:38:46 +0000 (12:38 -0500)]
Fix a segfault when writing a very fragmented evbuffer onto an SSL

Fixes bug 2916328.

15 years agoUpdate sample/signal-test.c to use newer APIs and not leak.
Evan Jones [Tue, 8 Dec 2009 22:02:24 +0000 (17:02 -0500)]
Update sample/signal-test.c to use newer APIs and not leak.

15 years agoOnly define _GNU_SOURCE if it is not already defined.
Joachim Bauch [Tue, 8 Dec 2009 20:38:34 +0000 (15:38 -0500)]
Only define _GNU_SOURCE if it is not already defined.

15 years agoFix compile on Snow Leopard with gcc warnings enabled
Sebastian Hahn [Sun, 6 Dec 2009 01:59:19 +0000 (02:59 +0100)]
Fix compile on Snow Leopard with gcc warnings enabled

15 years agoFix a snow leopard compile warning in the unit tests.
Nick Mathewson [Fri, 4 Dec 2009 21:37:43 +0000 (16:37 -0500)]
Fix a snow leopard compile warning in the unit tests.

Reported by Sebastian Hahn.

15 years agoRefactor our 'suspend operation' logic on bufferevents.
Nick Mathewson [Mon, 23 Nov 2009 23:34:32 +0000 (18:34 -0500)]
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.

15 years agoAdd the abilitity to mark some buffer callbacks as never-deferred.
Nick Mathewson [Mon, 23 Nov 2009 20:53:24 +0000 (15:53 -0500)]
Add the abilitity to mark some buffer callbacks as never-deferred.

15 years agoNew EVTHREAD_TRY_LOCK function to try to grab a lock.
Nick Mathewson [Sat, 28 Nov 2009 16:31:39 +0000 (11:31 -0500)]
New EVTHREAD_TRY_LOCK function to try to grab a lock.

15 years agoMerge commit 'niels/dnscrash'
Nick Mathewson [Fri, 4 Dec 2009 18:49:27 +0000 (13:49 -0500)]
Merge commit 'niels/dnscrash'

15 years agoFix a crash when reading badly formatted resolve.conf; from Yasuoka Masahiko
Yasuoka Masahiko [Fri, 4 Dec 2009 18:44:46 +0000 (10:44 -0800)]
Fix a crash when reading badly formatted resolve.conf; from Yasuoka Masahiko

15 years agoUpdate nmake makefile to build evthread.c
unknown [Wed, 2 Dec 2009 06:24:37 +0000 (01:24 -0500)]
Update nmake makefile to build evthread.c

15 years agoFix regress_iocp.c usage of old lock allocation macros.
unknown [Wed, 2 Dec 2009 06:22:07 +0000 (01:22 -0500)]
Fix regress_iocp.c usage of old lock allocation macros.

15 years agoFix up evthread compilation on windows
Roman Puls [Wed, 2 Dec 2009 06:15:15 +0000 (01:15 -0500)]
Fix up evthread compilation on windows

15 years agoValgrind fix: Clear struct kevent before checking for OSX bug.
William Ahern [Sun, 29 Nov 2009 15:20:46 +0000 (10:20 -0500)]
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.

15 years agoImproved optional lock debugging.
Nick Mathewson [Fri, 27 Nov 2009 22:22:19 +0000 (17:22 -0500)]
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."

15 years agoFix an evdns lock violation.
Zhuang Yuyao [Fri, 27 Nov 2009 21:02:49 +0000 (16:02 -0500)]
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().

15 years agoFix a locking bug in event_base_loop()
Nick Mathewson [Fri, 27 Nov 2009 21:00:59 +0000 (16:00 -0500)]
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.

15 years agoFix two use-after-free bugs in unit tests spoted by lock debugging
Nick Mathewson [Fri, 27 Nov 2009 20:24:32 +0000 (15:24 -0500)]
Fix two use-after-free bugs in unit tests spoted by lock debugging

15 years agoStop passing EVTHREAD_READ and EVTHREAD_WRITE to non-rw locks.
Nick Mathewson [Fri, 27 Nov 2009 21:44:47 +0000 (16:44 -0500)]
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.

15 years agoRevise the locking API: deprecate the old locking callbacks and add trylock.
Nick Mathewson [Fri, 27 Nov 2009 20:20:43 +0000 (15:20 -0500)]
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.

15 years agoFix memory-leak of signal handler array with kqueue.
Nick Mathewson [Sat, 21 Nov 2009 06:11:49 +0000 (01:11 -0500)]
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.

15 years agoParenthesize macro arguments more aggressively
Nick Mathewson [Fri, 20 Nov 2009 21:50:55 +0000 (16:50 -0500)]
Parenthesize macro arguments more aggressively

15 years agoAdd a warning about the use of event_initialized.
Nick Mathewson [Fri, 20 Nov 2009 21:38:01 +0000 (16:38 -0500)]
Add a warning about the use of event_initialized.

15 years agoTolerate code that returns from a fatal_cb.
Nick Mathewson [Fri, 20 Nov 2009 20:46:04 +0000 (15:46 -0500)]
Tolerate code that returns from a fatal_cb.

Also, replace more abort() calls with EVUTIL_ASSERT() or event_errx.

15 years agoAdd stub header for 2.0.4-alpha changelog.
Nick Mathewson [Fri, 20 Nov 2009 17:56:29 +0000 (12:56 -0500)]
Add stub header for 2.0.4-alpha changelog.

15 years agoAdd more people who wrote patches to the acknowledgments
Nick Mathewson [Fri, 20 Nov 2009 17:46:00 +0000 (12:46 -0500)]
Add more people who wrote patches to the acknowledgments

The names came from grepping ChangeLog for 'patch/code from/by'.

15 years agoImprove the README with more information and links.
Nick Mathewson [Fri, 20 Nov 2009 17:37:47 +0000 (12:37 -0500)]
Improve the README with more information and links.

(Also, try to test out the new commit script.)

15 years agoAdd a .gitignore file.
Nick Mathewson [Fri, 20 Nov 2009 17:17:14 +0000 (12:17 -0500)]
Add a .gitignore file.

.gitignore plays the same role in Git as the svn:ignore property does in
subversion.

15 years agocall it 2.0.3-alpha
Niels Provos [Fri, 20 Nov 2009 00:18:35 +0000 (00:18 +0000)]
call it 2.0.3-alpha

svn:r1556

15 years agoRemove most calls to event_err() in http and deal with memory errors instead release-2.0.3-alpha
Niels Provos [Thu, 19 Nov 2009 23:08:50 +0000 (23:08 +0000)]
Remove most calls to event_err() in http and deal with memory errors instead

svn:r1555

15 years agonick found a race condition in the pthreads test case
Niels Provos [Thu, 19 Nov 2009 22:02:33 +0000 (22:02 +0000)]
nick found a race condition in the pthreads test case

svn:r1554

15 years agoOn FreeBSD and other OSes, connect can return ECONREFUSED immediately; instead of...
Niels Provos [Thu, 19 Nov 2009 21:14:31 +0000 (21:14 +0000)]
On FreeBSD and other OSes, connect can return ECONREFUSED immediately; instead of failing the function call, pretend with faileld in the callback.

svn:r1553

15 years agoDocumentation adjustments
Nick Mathewson [Thu, 19 Nov 2009 00:21:48 +0000 (00:21 +0000)]
Documentation adjustments

svn:r1552

15 years agoFix a spelling error and remove some dead code
Nick Mathewson [Thu, 19 Nov 2009 00:21:38 +0000 (00:21 +0000)]
Fix a spelling error and remove some dead code

svn:r1551

15 years agoDo the proper hack for the (Open)BSD getaddrinfo quirk.
Nick Mathewson [Wed, 18 Nov 2009 23:18:55 +0000 (23:18 +0000)]
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

15 years agoMake our failing-connection bufferevent test more tolerant.
Nick Mathewson [Wed, 18 Nov 2009 21:17:00 +0000 (21:17 +0000)]
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

15 years agoAdd a temporary workaround for an ssl bug found on FreeBSD.
Nick Mathewson [Wed, 18 Nov 2009 21:16:53 +0000 (21:16 +0000)]
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

15 years agoBuild correctly with mm replacement turned off.
Nick Mathewson [Wed, 18 Nov 2009 21:16:47 +0000 (21:16 +0000)]
Build correctly with mm replacement turned off.

svn:r1547

15 years agoFix compilation with threading disabled.
Nick Mathewson [Wed, 18 Nov 2009 21:16:33 +0000 (21:16 +0000)]
Fix compilation with threading disabled.

svn:r1546

15 years agoMove responsibility for IOCP callback into bufferevent_async.
Nick Mathewson [Tue, 17 Nov 2009 20:31:09 +0000 (20:31 +0000)]
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

15 years agoClarify even more about various system-specific problems with getaddrinfo
Nick Mathewson [Tue, 17 Nov 2009 18:29:44 +0000 (18:29 +0000)]
Clarify even more about various system-specific problems with getaddrinfo

svn:r1542

15 years agoUse the common-case code from getaddrinfo_common *always*; OS differences are just...
Nick Mathewson [Tue, 17 Nov 2009 03:36:43 +0000 (03:36 +0000)]
Use the common-case code from getaddrinfo_common *always*; OS differences are just too huge.

svn:r1541

15 years agoNever pass our weird flags to the system getaddrinfo. Make sure there is no overlap...
Nick Mathewson [Tue, 17 Nov 2009 02:57:32 +0000 (02:57 +0000)]
Never pass our weird flags to the system getaddrinfo.  Make sure there is no overlap between flag values.

svn:r1540

15 years agoOpenBSD demands that sys/types.h be included before sys/socket.h
Nick Mathewson [Tue, 17 Nov 2009 02:40:14 +0000 (02:40 +0000)]
OpenBSD demands that sys/types.h be included before sys/socket.h

svn:r1539

15 years agoWindows *does* have getservbyname, no matter what autoconf says.
Nick Mathewson [Tue, 17 Nov 2009 02:38:19 +0000 (02:38 +0000)]
Windows *does* have getservbyname, no matter what autoconf says.

TODO: figure out why autoconf is confused about this.

svn:r1538

15 years agoAdd two implementations of getaddrinfo: one blocking and one nonblocking.
Nick Mathewson [Mon, 16 Nov 2009 22:25:46 +0000 (22:25 +0000)]
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

15 years agoRemove the stupid brokenness where DNS option names needed to end with a
Nick Mathewson [Mon, 16 Nov 2009 22:23:55 +0000 (22:23 +0000)]
Remove the stupid brokenness where DNS option names needed to end with a
colon.

svn:r1536

15 years agoFix a declaration of __func__ in rpcgen.
Nick Mathewson [Mon, 16 Nov 2009 22:23:06 +0000 (22:23 +0000)]
Fix a declaration of __func__ in rpcgen.

svn:r1535

15 years agoPrefer calloc(a,b) to malloc(a*b). via openbsd.
Nick Mathewson [Sun, 15 Nov 2009 19:00:12 +0000 (19:00 +0000)]
Prefer calloc(a,b) to malloc(a*b).  via openbsd.

svn:r1531

15 years agoWhen running set[ug]id, don't check the environment.
Nick Mathewson [Sun, 15 Nov 2009 18:59:59 +0000 (18:59 +0000)]
When running set[ug]id, don't check the environment.

Idea from OpenBSD, but made a bit more generic to handle uncivilized lands
that do not define issetugid.

svn:r1530

15 years agoUse arc4random() for dns transaction ids where available. Patch taken from OpenBSD
Nick Mathewson [Sun, 15 Nov 2009 18:59:48 +0000 (18:59 +0000)]
Use arc4random() for dns transaction ids where available.  Patch taken from OpenBSD

svn:r1528

15 years agoFix a couple of event_debug calls.
Nick Mathewson [Sat, 14 Nov 2009 21:54:30 +0000 (21:54 +0000)]
Fix a couple of event_debug calls.

svn:r1527

15 years agoChange event_base.activequeues to "array of eventlist".
Nick Mathewson [Mon, 9 Nov 2009 19:37:27 +0000 (19:37 +0000)]
Change event_base.activequeues to "array of eventlist".

Previously, event_base.activequeues was of type "array of pointers to
eventlist."  This was pointless: none of the eventlists were allowed
to be NULL.  Worse, it was inefficient:

  - It made looking up an active event queue take two pointer
    deferences instead of one, thus risking extra cache misses.
  - It used more RAM than it needed to, because of the extra pointer
    and the malloc overhead.

Also, this patch fixes a bug where we were saying
calloc(N,N*sizeof(X)) instead of calloc(N,sizeof(X)) when allocating
activequeues.  That part, I'll backport.

Also, we warn and return -1 on failure to allocate activequeues,
rather than calling event_err.

svn:r1525

15 years agoChange an OOM err to a warn in event_tagging.c
Nick Mathewson [Mon, 9 Nov 2009 19:37:21 +0000 (19:37 +0000)]
Change an OOM err to a warn in event_tagging.c

svn:r1524

15 years agoChange an err to a warn in bufferevent_openssl
Nick Mathewson [Mon, 9 Nov 2009 19:37:15 +0000 (19:37 +0000)]
Change an err to a warn in bufferevent_openssl

svn:r1523

15 years agoPatch from Ryan Phillips: accept ipv6 addresses returned by getaddrinfo in http.c
Nick Mathewson [Mon, 9 Nov 2009 18:50:20 +0000 (18:50 +0000)]
Patch from Ryan Phillips: accept ipv6 addresses returned by getaddrinfo in http.c

svn:r1522

15 years agoUnit tests for got_break and got_exit.
Nick Mathewson [Mon, 9 Nov 2009 18:36:34 +0000 (18:36 +0000)]
Unit tests for got_break and got_exit.

svn:r1521

15 years agoMake persistent timeouts more accurate.
Nick Mathewson [Mon, 9 Nov 2009 18:30:57 +0000 (18:30 +0000)]
Make persistent timeouts more accurate.

Previously, if the user scheduled a persistent timeout for {1,0}, we
would schedule the first one at "now+one second", and then when we
were about to run its callback, we would schedule it again for one
second after that.  This would introduce creeping delays to the event
that was supposed to run every second.

Now, we schedule the event for one second after it was _last
scheduled_.  To do this, we introduce internal code to add an event at
an _absolute_ tv rather than at now+tv.

svn:r1520

15 years agoMake sure that common timeouts are inserted in-order.
Nick Mathewson [Mon, 9 Nov 2009 18:30:48 +0000 (18:30 +0000)]
Make sure that common timeouts are inserted in-order.

This code should be a no-op, except under strange thread contention
situations.

svn:r1519

15 years agoAdd an option to disable the timeval cache.
Nick Mathewson [Mon, 9 Nov 2009 18:30:33 +0000 (18:30 +0000)]
Add an option to disable the timeval cache.

svn:r1518

15 years agoImplement queued timeouts for case where many timeouts are the same.
Nick Mathewson [Mon, 9 Nov 2009 17:16:30 +0000 (17:16 +0000)]
Implement queued timeouts for case where many timeouts are the same.

Libevent's current timeout code is relatively optimized for the
randomly scattered timeout case, where events are added with their
timeouts in no particular order.  We add and remove timeouts with
O(lg n) behavior.

Frequently, however, an application will want to have many timeouts
of the same value.  For example, we might have 1000 bufferevents,
each with a 2 second timeout on reading or writing.  If we knew this
were always the case, we could just put timeouts in a queue and get
O(1) add and remove behavior.  Of course, a queue would give O(n)
performance for a scattered timeout pattern, so we don't want to
just switch the implementation.

This patch gives the user the ability to explicitly tag certain
timeout values as being "very common".  These timeout values have a
cookie encoded in the high bits of their tv_usec field to indicate
which queue they belong on.  The queues themselves are each
triggered by an entry in the minheap.

See the regress_main.c code for an example use.

svn:r1517

15 years agoWe do not work any more without an event-config.h; stop pretending that it is meaning...
Nick Mathewson [Fri, 6 Nov 2009 21:46:57 +0000 (21:46 +0000)]
We do not work any more without an event-config.h; stop pretending that it is meaningful to check for HAVE_CONFIG_H

svn:r1516

15 years agoFix kqueue.c build on GNU/kFreeBSD systems.
Nick Mathewson [Fri, 6 Nov 2009 21:13:25 +0000 (21:13 +0000)]
Fix kqueue.c build on GNU/kFreeBSD systems.

Yes, some people like to have a BSD-family kernel (thus getting
kqueue) with a GNU-family libc (thus occasionally mandating
_GNU_SOURCE).

Thanks to Debian for noticing this.

svn:r1514

15 years agoFix a miscalculated realloc() size in win32select.c.
Nick Mathewson [Fri, 6 Nov 2009 17:12:39 +0000 (17:12 +0000)]
Fix a miscalculated realloc() size in win32select.c.

This bug was introduced by the code to make the backend able to safely release the base lock while calling select().

Also, we change win32select.c to the same 32-fds-to-start default as the rest of the backends, so that the main/many_events test can test it.  It was at 64-to-start, so the test wasn't hitting it.

svn:r1513

15 years agoActually add the new dns-example.c code. :p
Nick Mathewson [Thu, 5 Nov 2009 22:24:21 +0000 (22:24 +0000)]
Actually add the new dns-example.c code. :p

svn:r1512

15 years agoMove the evdns sample code into the sample directory and fix it not to use any deprec...
Nick Mathewson [Thu, 5 Nov 2009 22:19:09 +0000 (22:19 +0000)]
Move the evdns sample code into the sample directory and fix it not to use any deprecated APIs.

svn:r1511

15 years agoFix some build warnings on MSVC, mostly related to signed/unsigned comparisons.
Nick Mathewson [Thu, 5 Nov 2009 21:22:23 +0000 (21:22 +0000)]
Fix some build warnings on MSVC, mostly related to signed/unsigned comparisons.

svn:r1510

15 years agoExport nmakefiles in source distribution.
Nick Mathewson [Thu, 5 Nov 2009 20:45:07 +0000 (20:45 +0000)]
Export nmakefiles in source distribution.

svn:r1509

15 years agoAdd nmake files to build with MSVC.
Nick Mathewson [Thu, 5 Nov 2009 20:40:11 +0000 (20:40 +0000)]
Add nmake files to build with MSVC.

Right now, they just make static libraries and unit tests.  They probably set lots of options wrong.

svn:r1507

15 years agoBuild fixes for MSVC
Nick Mathewson [Thu, 5 Nov 2009 20:37:19 +0000 (20:37 +0000)]
Build fixes for MSVC

svn:r1506

15 years agoRename win32.c to win32select.c, and take it out of the WIN32-Code ghetto.
Nick Mathewson [Thu, 5 Nov 2009 18:49:08 +0000 (18:49 +0000)]
Rename win32.c to win32select.c, and take it out of the WIN32-Code ghetto.

svn:r1504

15 years agoFix another ssize_t user
Nick Mathewson [Thu, 5 Nov 2009 18:25:46 +0000 (18:25 +0000)]
Fix another ssize_t user

svn:r1503

15 years agoRemove win32-code/config.h. It was apparently confusing.
Nick Mathewson [Thu, 5 Nov 2009 18:07:27 +0000 (18:07 +0000)]
Remove win32-code/config.h.  It was apparently confusing.

svn:r1502

15 years agoFix a few types to use compatible versions
Nick Mathewson [Thu, 5 Nov 2009 15:57:22 +0000 (15:57 +0000)]
Fix a few types to use compatible versions

svn:r1501

15 years agoImplement size limits on HTTP header length and body length.
Nick Mathewson [Wed, 4 Nov 2009 20:17:32 +0000 (20:17 +0000)]
Implement size limits on HTTP header length and body length.

Patch from Constantine Verutin, simplified a little.

svn:r1500

15 years agoCommit ConnectEx code to get connect working with async bufferevents.
Nick Mathewson [Wed, 4 Nov 2009 05:19:26 +0000 (05:19 +0000)]
Commit ConnectEx code to get connect working with async bufferevents.

This is code by Chris Davis, with changes to get the unit tests failing less aggressively.

The unit tests for this code do not completely pass yet; Chris is looking into that.  If they aren't passing by the next release, I'll turn off this code.

svn:r1499

15 years agoAdd a missing include for win32.
Nick Mathewson [Wed, 4 Nov 2009 03:54:05 +0000 (03:54 +0000)]
Add a missing include for win32.

svn:r1498

15 years agoOops; add missing bufferevent_evdns.c file
Nick Mathewson [Tue, 3 Nov 2009 20:42:32 +0000 (20:42 +0000)]
Oops; add missing bufferevent_evdns.c file

svn:r1497

15 years agoAdd a bufferevent function to resolve a name then connect to it.
Nick Mathewson [Tue, 3 Nov 2009 20:40:48 +0000 (20:40 +0000)]
Add a bufferevent function to resolve a name then connect to it.

This function, bufferevent_socket_connect_hostname() can either use
evdns to do the resolve, or use a new function (evutil_resolve) that
uses getaddrinfo or gethostbyname, like http.c does now.

This function is meant to eventually replace the hostname resolution mess in
http.c.

svn:r1496

15 years agoFix one IOCP-callback signature I missed
Nick Mathewson [Tue, 3 Nov 2009 20:05:06 +0000 (20:05 +0000)]
Fix one IOCP-callback signature I missed

svn:r1495

15 years agoRemove compat/sys/_time.h
Nick Mathewson [Tue, 3 Nov 2009 19:54:56 +0000 (19:54 +0000)]
Remove compat/sys/_time.h

I've gone through everything that it declared to see where it was used,
and it seems that we probably don't need it anywhere.

Here's what it declared, and why I think we're okay dropping it.

o struct timeval {}
  (Used all over, and we can't really get away with declaring it ourselves;
  we need the same definition the system uses.  If we can't find struct
  timeval, we're pretty much sunk.)

o struct timespec {}
  (Used in event.c, evdns.c, kqueue.c, evport.c.  Of these,
   kqueue.c and event.c include sys/_time.h.  event.c conditions its use on
   _EVENT_HAVE_CLOCK_GETTIME, and kqueue() only works if timespec is defined.)

o TIMEVAL_TO_TIMESPEC
  (Used in kqueue.c, but every place with kqueue has sys/time.h)

o struct timezone {}
  (event2/util.h has a forward declaration; only evutil.c references it and
   doesn't look at its contents.)

o timerclear, timerisset, timercmp, timeradd, timersub
  (Everything now uses the evutil_timer* variants.)

o ITIMER_REAL, ITIMER_VIRTUAL, ITIMER_PROF, struct itemerval
  (These are only used in test/regress.c, which does not include _time.h)

o CLOCK_REALTIME
  (Only used in evdns.c, which does not include _time.h)

o TIMESPEC_TO_TIMEVAL
o DST_*
o timespecclear, timespecisset, timespeccmp, timespecadd, timespecsub
o struct clockinfo {}
o CLOCK_VIRTUAL, CLOCK_PROF
o TIMER_RELTIME, TIMER_ABSTIME
  (unused)

svn:r1494

15 years agoFix remaining AcceptEx issues.
Nick Mathewson [Mon, 2 Nov 2009 20:59:13 +0000 (20:59 +0000)]
Fix remaining AcceptEx issues.

svn:r1492

15 years agoClean up acceptex code some more: add locking, single-threading, enable/disable.
Nick Mathewson [Mon, 2 Nov 2009 20:20:40 +0000 (20:20 +0000)]
Clean up acceptex code some more: add locking, single-threading, enable/disable.

svn:r1491

15 years agoRefactor IOCP callback interface
Nick Mathewson [Mon, 2 Nov 2009 19:51:26 +0000 (19:51 +0000)]
Refactor IOCP callback interface

Chris Davis points out that GetQueuedCompletionStatus
sometimes returns false not to report "No events for
you!" but instead to report "An overlapped operation
failed."  Add a way to tell an event_overlapped that
its operation failed.

svn:r1490