Abel Mathew [Fri, 21 Oct 2011 19:53:32 +0000 (19:53 +0000)]
New event_base_update_cache_time() to set cached_tv to current time
This function is particularly useful for selectively increasing
the accuracy of the cached time value in 'base' during callbacks
that take a long time to execute.
This function has no effect if the base is currently not in its
event loop or if timeval caching is disabled via EVENT_BASE_FLAG_NO_CACHE_TIME.
Mansour Moufid [Fri, 14 Oct 2011 21:16:03 +0000 (17:16 -0400)]
Add argument checks to some memory functions in `event.c'.
Add a zero check to the function `event_mm_malloc_',
i.e. simply return NULL if the sz argument is zero.
On failure, set errno to ENOMEM and return NULL.
Add a zero check to the function `event_mm_calloc_',
i.e. simply return NULL if either argument is zero.
Also add an unsigned integer multiplication check, and if an integer
overflow would occur, set errno to ENOMEM and return NULL.
On failure, set errno to ENOMEM and return NULL.
Add a NULL check to the function `event_mm_strdup_',
i.e. set errno to EINVAL and return NULL.
Also add an unsigned integer addition check, and if an integer
overflow would occur, set errno to ENOMEM and return NULL.
If a memory allocation error occurs, again set errno to ENOMEM
and return NULL.
Leonid Evdokimov [Wed, 19 Oct 2011 18:38:37 +0000 (22:38 +0400)]
Empty DNS reply with OK status is another way to say NODATA.
Sometimes DNS reply has nothing but query section. It does not look like
error, so it should be treated as NODATA with TTL=0 as soon as there is
no SOA record to deduce negative TTL from.
Nick Mathewson [Thu, 6 Oct 2011 22:02:22 +0000 (18:02 -0400)]
Make evbuffer_file_segment_types adaptable
Instead of having a file segment born as one type and stay that way
forever, let them start out unmapped, but map themselves as needed
if they need to get written out on a non-drains_to_fd evbuffer.
Nick Mathewson [Thu, 29 Sep 2011 13:30:04 +0000 (09:30 -0400)]
Prefer mmap to sendfile unless a DRAINS_TO_FD flag is set. Allows add_file to work with SSL.
The sendfile() implementation for evbuffer_add_file is potentially more
efficient, but it has a problem: you can only use it to send bytes over
a socket using sendfile(). If you are writing bytes via SSL_send() or
via a filter, or if you need to be able to inspect your buffer, it
doesn't work.
As an easy fix, this patch disables the sendfile-based implementation of
evbuffer_add_file on an evbuffer unless the user sets a new
EVBUFFER_FLAG_DRAINS_TO_FD flag on that evbuffer, indicating that the
evbuffer will not be inspected, but only written out via
evbuffer_write(), evbuffer_write_atmost(), or drained with stuff like
evbuffer_drain() or evbuffer_add_buffer(). This flag is off by
default, except for evbuffers used for output on bufferevent_socket.
In the future, it could be interesting to make a best-effort file
segment implementation that tries to send via sendfile, but mmaps on
demand. That's too much complexity for a stable release series, though.
Nick Mathewson [Mon, 12 Sep 2011 18:53:39 +0000 (14:53 -0400)]
Build with large-file support on platforms where it matters
Some hosts require you to define certain options to get a large off_t
instead of a small one, to get useful ftell and fseek calls instead of
ones that can only support 2GB files, and so on. This patch makes
Libevent support those platforms by:
* Defining the right options when we build, and
* Changing our API so that it does not depend on the platform's
definition of off_t.
Sebastian Hahn [Sun, 10 Apr 2011 16:25:05 +0000 (18:25 +0200)]
Implement --enable-gcc-hardening configure option
Using --enable-gcc-hardening enables some additional safety features
that gcc makes available such as stack smashing protection using
canaries and ASLR.
This commit is based on a patch for Tor:
(git commit 04fa935e02270bc90aca0f1c652d31c7a872175b by Jacob Appelbaum)
Copyright (c) 2007-2011, The Tor Project, Inc.
Sebastian Hahn [Sun, 20 Mar 2011 03:24:33 +0000 (04:24 +0100)]
Make gcc warnings on by default, and --enable-gcc-warnings only add -Werror
This commit is based on a patch for Tor
(git commit ca60a6ce3f4786626ac455ec1b798b2e8304635c by Peter
Palfrader), Copyright (c) 2007-2011, The Tor Project, Inc.
(Originally, it added --enable-gcc-warnings-advisory as in Tor; Nick
changed that.)
Nick Mathewson [Wed, 24 Aug 2011 22:41:35 +0000 (18:41 -0400)]
Make IOCP rate-limiting group support stricter and less surprising.
Previously, we wouldn't decrement read/write buckets because of IOCP
reads and writes until those reads and writes were complete. That's
not so bad on the per-connection front. But for group limits, the
old approach makes us launch a huge amount of reads and writes
whenever the group limit becomes positive, and then decrement the
limit to a hugely negative number as they complete.
With this patch, we decrement our read buckets whenever we launch an
IOCP read or write, based on the maximum that tried to read or
write. Later, when the operations finish, we re-increment the
bucket based on the portion of the request that couldn't finish.
Nick Mathewson [Thu, 11 Aug 2011 16:47:21 +0000 (12:47 -0400)]
Make the priority inversion code use gettime(), not evutil_gettimeofday()
Since we're computing the time after each callback, we might as well
update the time cache (if we're using it) and use monotonic time (if
we've got that).