265 Commits

Author SHA1 Message Date
Nick Mathewson
da45aa74a7 fix windows compilation issues with new file segment code
Found by Linus Nordberg
2011-12-02 01:48:17 -05:00
Andrea Montefusco
d7a8b36eaf New EVBUFFER_EOL_NUL to read NUL-terminated strings from an evbuffer 2011-11-14 11:42:52 -05:00
Nick Mathewson
27b5398fe0 Tweaks, fixups, and comments on evbuffer_add_iovec 2011-11-11 17:56:08 -05:00
Mark Ellzey
aaec5aca01 Added evbuffer_add_iovec and unit tests. 2011-11-11 17:39:28 -05:00
Nick Mathewson
dea055d026 Merge remote-tracking branch 'github/20_evbuffer_remove_bug' 2011-11-02 23:15:07 -04:00
Nick Mathewson
c882a95956 Merge remote-tracking branch 'origin/patches-2.0' 2011-11-02 23:14:24 -04:00
Nick Mathewson
b18c04dd74 Use the free-trailing-chains function in evbuffer_insert_chain too 2011-11-02 22:50:47 -04:00
Nick Mathewson
c37069cd79 Fix an evbuffer crash in evbuffer_remove_buffer()
Found by Greg Hazel.
2011-11-02 22:48:16 -04:00
Nick Mathewson
0cb70e3333 Merge remote-tracking branch 'origin/patches-2.0' 2011-10-26 10:17:21 -04:00
Nick Mathewson
3c824bd334 Update copyright dates to 2011. 2011-10-24 13:18:09 -04:00
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
Nick Mathewson
c6bbbf1b67 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.
2011-10-06 18:05:16 -04:00
Nick Mathewson
8358877768 Merge remote-tracking branch 'origin/patches-2.0'
Conflicts:
	buffer.c
	test/regress_buffer.c
2011-10-06 15:21:55 -04:00
Nick Mathewson
0ba0af9c6c 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.
2011-09-29 10:32:16 -04:00
Nick Mathewson
46974cd877 Merge remote-tracking branch 'origin/patches-2.0' 2011-09-28 09:23:41 -04:00
Nick Mathewson
1ef1f68462 Make evbuffer callbacks get the right n_added value after evbuffer_add
Patch from Alex.
2011-09-28 09:22:17 -04:00
Nick Mathewson
0d10804465 Merge remote-tracking branch 'origin/patches-2.0' 2011-08-18 15:18:14 -04:00
Nick Mathewson
6acfbdd83a Make overlapped reads result in evbuffer callbacks getting invoked 2011-08-18 13:15:46 -04:00
Nick Mathewson
ec670c15a7 Merge remote-tracking branch 'origin/patches-2.0'
Conflict in buffer.c: the new file-segment logic conflicted with the
solaris sendfile fix.
2011-08-17 22:08:06 -04:00
Michael Herf
643922e907 Solaris sendfile: correctly detect amount of data sent
Original message:

   Solaris sendfile seems to fail when sending moderately large (<1GB)
   files. Not a 32/64 problem, but a buffer problem.

   Anyone else ever try this? It is definitely broken in http-server.c.

   It seems to be broken in the following way:

   When sendfile sends partial data (EAGAIN, would block), "res" is
   always -1, rather than the amount sent.

   Here's a patch that reads from the "offset" pointer instead to
   discover what was sent. This seems to work:
2011-08-15 13:39:10 -04: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