195 Commits

Author SHA1 Message Date
Joachim Bauch
95a8b87a23 fixed typo 2011-10-17 21:48:23 +02:00
Joachim Bauch
ba24f616e5 added comments to describe refcounting of multicase chains 2011-10-17 21:46:12 +02:00
Joachim Bauch
26041a8ed8 prevent nested multicast references, reworked locking 2011-08-09 23:08:54 +02:00
Joachim Bauch
9d7368ae2d support adding buffers to other buffers non-destructively 2011-08-09 23:08:46 +02:00
Nick Mathewson
7d08a28c1c Merge remote-tracking branch 'github/21_end_of_buffer'
Conflicts:
	include/event2/buffer.h
2011-07-05 15:07:07 -04:00
Nick Mathewson
c3d362858c Merge remote-tracking branch 'origin/patches-2.0' 2011-07-04 11:48:41 -04:00
Mark Ellzey
f87f56894d Speed up invoke_callbacks on evbuffers when there are no callbacks
This fixes a performance regression against 1.4
2011-07-04 11:47:24 -04:00
Nir Soffer
e3e97ae31b Set the special "not found" evbuffer_ptr consistantly.
The _internal.pos_in_chain field was uninitialized or set to different
values in different places returning the special "not found" pointer.

Signed-off-by: Nir Soffer <nirsof@gmail.com>
2011-06-20 14:10:36 -04:00
Nick Mathewson
9ab8ab83cd Tweaks to return types with end-of-buf ptrs 2011-06-13 16:55:55 -04:00
Nir Soffer
7aeb2fd4ca Allow evbuffer_ptr to point to position 0 in an empty evbuffer 2011-06-13 16:48:03 -04:00
Nick Mathewson
e6fe1da9ad Allow evbuffer_ptr_set to yield a point just after the end of the buffer. 2011-06-13 16:48:02 -04:00
Nick Mathewson
d19a326087 Remove a needless branch in evbuffer_drain()
Found by Gilad Benjamini; see June 2011 thread "Dead or wrong code".
2011-06-08 13:32:47 -04:00
Nick Mathewson
d927965f22 Fix a bug in the improved EOL_CRLF code
When searching for a CRLF, it would find an LF, then look for a
preceding CR if not at the start of the buffer.  That's fine when
we're starting from the beginning of the buffer, but if we're starting
at (say) byte 100, and we have that byte == LF, we shouldn't check for
a CR at byte 99.
2011-06-06 15:33:27 -04:00
Nick Mathewson
264c7b9600 Merge remote-tracking branch 'origin/patches-2.0' 2011-06-06 15:26:37 -04:00
Nick Mathewson
4461f1a096 Fix incorrect results from evbuffer_search_eol(EOL_LF)
Our evbuffer_strchr() function [which was only used for
search_eol(EOL_LF) could give incorrect results if it found its answer
in the first chunk but didn't start searching from the front of the
chunk.

Also, this patch adds unit tests for evbuffer_search_eol, particularly
in those cases that evbuffer_readln() tests didn't exercise.
2011-06-06 15:11:28 -04:00
Nick Mathewson
8254de765d Fix windows file segment mappings
Instead of mapping enough bytes for each segment, we were failing to
take into account the slop created by rounding the segment position
down to the nearest page.

Should fix bug 3142394 found by Sebastian Hahn.
2011-06-02 17:09:53 -04:00
Nick Mathewson
7b9d13957f Try to squeeze a little more speed out of EVBUFFER_EOL_CRLF 2011-06-01 14:19:13 -04:00
Mina Naguib
5dde0f0424 Roughly 20% speed increase when line-draining a buffer using EVBUFFER_EOL_CRLF 2011-05-31 13:56:56 -04:00
Nick Mathewson
9f560bfa11 Use "_WIN32", not WIN32: it's standard and we don't need to fake it
This patch was automatically generated with perl.

Based on a patch by Peter Rosin.
2011-05-25 20:03:15 -04:00
Nick Mathewson
b647e0bc94 Merge remote branch 'kev009/21_ac_use_system_extensions' 2011-01-07 12:31:30 -05:00
Kevin Bowling
c13e185914 Remove use and reference to event-private.h 2011-01-07 00:34:22 -07:00
Kevin Bowling
0915ca0aa6 Include evconfig-private.h in internal files for great good. 2011-01-02 08:43:45 -07:00
Kevin Bowling
9b27b30720 Remove event-private.h and switch to evconfig-private.h 2011-01-02 08:04:12 -07:00
Kevin Bowling
c51ef9307a Eliminate a couple more manual internal _GNU_SOURCE defines 2010-12-22 23:24:01 -07:00
Nick Mathewson
3f405d2d4b Add CreateFileMapping file_segment implementation for win32 2010-12-20 19:25:15 -05:00
Nick Mathewson
c2d9884a6a Add support for mmaps with nonzero offset values. Needs testing. 2010-12-20 19:25:15 -05:00
Nick Mathewson
e72afae068 Add evbuffer_add_file_segment() so one fd can be used efficiently in more than one evbuffer_add_file at a time 2010-12-20 19:25:05 -05:00
Evan Jones
b63ab1776b EVUTIL_ASSERT: Use sizeof() to avoid "unused variable" warnings. 2010-12-14 00:14:07 -05:00
Nick Mathewson
bb0d2b4e85 Consistentize tabs 2010-12-09 11:47:54 -05:00
Nick Mathewson
7bcace2d54 Fix some irix compilation warnings spotted by Kevin Bowling 2010-11-22 21:02:34 -05:00
Nick Mathewson
a3245afec2 Fix win32 build in response to fixes from win64 build. 2010-11-01 14:23:33 -04:00
Nick Mathewson
545a61145c Fix even more win64 warnings: buffer, event_tagging, http, evdns, evrpc 2010-11-01 14:13:33 -04:00
Nick Mathewson
e4f34e8a0f Correct logic for realigning a chain in evbuffer_add
The old logic was both too eager to realign (it would move a whole
chain to save a byte) and too reluctant to realign (it would only
realign when data would fit into the misaligned portion, without
considering the space at the end of the chain).

The new logic matches that from evbuffer_expand_singlechain: it only
realigns a chain when not much data is to be moved, and there's a
bunch of space to be regained.

Spotted by Yan Lin.
2010-10-25 22:39:29 -04:00
Nick Mathewson
ac7e52d84d Make evbuffer_add_file take ev_off_t, not off_t
This change has no effect on non-windows platforms, since those
either define off_t to 64-bits, or allow you to decide whether
it should be 64-bits yourself via some LARGEFILE-like macro.

On Windows, however, off_t is always 32-bit, so it's a bad choice
for "file size" or "file offset" values.  Instead, I'm adding
an ev_off_t type, and using it in the one place where we used
off_t to mean "the size of a file" or "an offset into a file" in the
API.

This breaks ABI compatibility on Windows.
2010-10-25 14:29:30 -04:00
Nick Mathewson
6be589ae68 Fix signed/unsigned warnings on opensolaris, where iov_len is signed 2010-10-14 13:48:40 -04:00
Nick Mathewson
fdc640b02d 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.
2010-10-06 10:56:49 -04:00
Nick Mathewson
9c8db0f804 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
2010-09-23 22:45:55 -04:00
Christopher Davis
03afa209de 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.
2010-09-08 01:22:21 -07: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
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
niks
65abdc2011 Fix wrong sie calculation of iovec buffers when exact=1
The old code had a bug where the 'exact' flag to 1 in
_evbuffer_read_setup_vecs would never actually make the iov_len field
of the last iovec get truncated.  This patch fixes that.
2010-07-16 09:11:09 -04:00
Nick Mathewson
3467f2fa3b Fix logic in correcting high values from FIONREAD
The old logic made sense back when buffer.c was an enormous linear
buffer, but it doesn't make any sense for the chain-based
implementation.

This patch also refactors the ioctl{socket}? call into its own function.
2010-05-28 15:05:32 -04:00
Nick Mathewson
c44de06c76 Numerous opensolaris compilation fixes
For future note, opensolaris doesn't have sys/sysctl.h, doesn't like
comparing iov_buf to a chain_space_ptr without a cast, and is (predictably)
unforgiving of dumb syntax errors.

Also, we had accidentally broken the devpoll backend test in configure.in
2010-05-08 19:34:09 -04:00
Nick Mathewson
dcdae6b743 Make evbuffer_add_file() work on windows
Right now only the add_file() mode is supported, when it would be
nicer to have mmap support.  Perhaps for Libevent 2.1.x.
2010-05-08 16:34:18 -04:00
Nick Mathewson
d49b92a835 Remove one last bug in last_with_datap logic. Found with valgrind 2010-04-23 23:04:20 -04:00
Giuseppe Scrivano
d469c503c5 Fix compiler warnings under WIN32 2010-04-13 02:00:58 -04:00
Nick Mathewson
eb86c8c5ff Add evbuffer_copyout to copy data from an evbuffer without draining
The evbuffer_remove() function copies data from the front of an
evbuffer into an array of char, and removes the data from the buffer.
This function behaves the same, but does not remove the data.  This
behavior can be handy for lots of protocols, where you want the
evbuffer to accumulate data until a complete record has arrived.

Lots of people have asked for a function more or less like this, and
though it isn't too hard to code one from evbuffer_peek(), it is
apparently annoying to do it in every app you write.  The
evbuffer_peek() function is significantly faster, but it requires that
the user be able to handle data in separate extents.

This patch also reimplements evbufer_remove() as evbuffer_copyout()
followed by evbuffer_drain().  I am reasonably confident that this
won't be a performance hit: the memcpy() overhead should dominate the
cost of walking the list an extra time.
2010-04-13 01:42:01 -04:00
Nick Mathewson
8c83e99579 Add more unit tests for evbuffer_expand 2010-04-09 16:40:53 -04:00
Nick Mathewson
06a4443abe Unit-test every evbuffer_add_file() implementation.
Previously, we'd only test the default one, even if the others were still
compiled in.
2010-04-09 15:28:26 -04:00
Christopher Davis
28bfed47e2 Clean up a mistake in pointer manipulation in evbuffer_remove 2010-04-02 19:08:32 -04:00