134 Commits

Author SHA1 Message Date
Nick Mathewson
747331d164 Add freeze support to evbuffers.
From the documentation:
   Prevent calls that modify an evbuffer from succeeding. A buffer may
   frozen at the front, at the back, or at both the front and the back.

   If the front of a buffer is frozen, operations that drain data from
   the front of the buffer, or that prepend data to the buffer, will
   fail until it is unfrozen.   If the back a buffer is frozen, operations
   that append data from the buffer will fail until it is unfrozen.

We'll use this to ensure correctness on an evbuffer when we're waiting
for an overlapped IO call to finish.

svn:r1143
2009-04-08 03:04:39 +00:00
Nick Mathewson
d9086fc007 Add a new facility to "pin" the memory in an evbuffer chain.
For overlapped IO (and possibly other stuff) we need to be able to
label an evbuffer_chain as "pinned", meaning that every byte in it
must remain at the same address as it is now until it unpinned. This
differs from being "immutable": it is okay to add data to the end
of a pinned chain, so long as existing data is not moved.

svn:r1142
2009-04-08 03:03:59 +00:00
Nick Mathewson
60e0d59b33 Add locking to evbuffers.
svn:r1134
2009-04-05 02:44:17 +00:00
Nick Mathewson
f1b1bad415 Make the new evbuffer callbacks use a new struct-based interface.
The old interface would fail pretty hard when we had to batch up
multiple adds and drains in a single call.

svn:r1131
2009-04-03 14:27:03 +00:00
Nick Mathewson
f90500a5df Add a new improved search function.
The old evbuffer_find didn't allow iterative searching, and forced us
to repack the buffer completely every time we searched in it.  The
new evbuffer_search addresses both of these.  As a side-effect, the
evbuffer_find implementation is now a little more efficient.

svn:r1130
2009-04-03 01:21:36 +00:00
Nick Mathewson
01456265c3 Explode less badly in the case where we're told to prepend/append/remove a buffer to itself. Note some API/implementation deficiencies.
svn:r1110
2009-02-10 19:39:22 +00:00
Nick Mathewson
edfdb698e3 Add an assertion to evbuffer_chain_align so we can't reuse it in the future.
svn:r1105
2009-02-10 19:38:34 +00:00
Nick Mathewson
cc049bfc30 Enable (and debug) WSARecv for evbuffer iovec-like reads.
The two things we were missing: the flags parameter is not optional, and an error can actually indicate a close.

svn:r1100
2009-02-03 05:22:57 +00:00
Nick Mathewson
e84c765615 Allocate callback entries with contents 0d out.
svn:r1093
2009-02-01 05:26:47 +00:00
Nick Mathewson
8d3a10f8f1 Support temporarily suspending an evbuffer callback. This is different from disabling the callback, since we want to process changes, but not just yet.
svn:r1091
2009-02-01 01:43:58 +00:00
Niels Provos
a0cae310d0 make it so that evbuffer_add_file where we read the complete contents of the file can fail without side effects
svn:r1069
2009-01-29 03:22:47 +00:00
Niels Provos
66b2a7ffb7 test evbuffer_add_reference
svn:r1068
2009-01-29 03:20:40 +00:00
Nick Mathewson
b85b710cf5 Update copyright statements to reflect the facts that:
a) this is 2009
b) niels and nick have been comaintainers for a while
c) saying "all rights reserved" when you then go on to explicitly
   disclaim some rights is sheer cargo-cultism.

svn:r1065
2009-01-27 22:34:36 +00:00
Nick Mathewson
8889a77039 Replace all use of config.h with event-config.h.
svn:r1064
2009-01-27 22:30:46 +00:00
Nick Mathewson
9993137cbb Remove all trailing whitespace in all the source files.
svn:r1063
2009-01-27 21:10:31 +00:00
Nick Mathewson
88f2b7a00f Fix some warnings on linux gcc with --enable-gcc-warnings
svn:r1060
2009-01-27 13:37:09 +00:00
Niels Provos
1757cf717f use %zu for off_t
svn:r1059
2009-01-27 06:21:12 +00:00
Niels Provos
8b5bd77415 make it compile on linux
svn:r1058
2009-01-27 06:18:45 +00:00
Niels Provos
fdf694933c sendfile/mmap and memory reference implementation for evbuffers
svn:r1057
2009-01-27 06:05:38 +00:00
Niels Provos
b93e505452 second argument to evbuffer_pullup should be ssize_t
svn:r1056
2009-01-27 05:33:39 +00:00
Nick Mathewson
81dd04a726 Add a "flags" field to evbuffer callbacks.
For now, there is just one: enabled.  This lets us avoid lots of
mallocs/frees/tailq-manipulations just to turn a callback on and off.
The revised bufferevent code wants this.

svn:r1047
2009-01-23 18:04:34 +00:00
Nick Mathewson
de7f7a84a3 Remove in_callbacks check: allow full recursion in evbuffer callbacks. If you get yourself in an infinite loop, that's not our fault. Note this in the docs. Also reindent some docs now that my tabs match Niels's.
svn:r1046
2009-01-23 18:03:45 +00:00
Nick Mathewson
ec2f4cbc09 Move obsolete evbuffer function into include/event2/buffer_compat.h
svn:r1043
2009-01-23 01:35:57 +00:00
Nick Mathewson
c735f2b45a Code to allow multiple callbacks per evbuffer.
svn:r1042
2009-01-23 01:11:13 +00:00
Nick Mathewson
f6eb1f816c Change evbuffer_read implementation to split data across chunks, and use readv when available. This should make us use less space.
svn:r1024
2009-01-19 21:53:03 +00:00
Nick Mathewson
840318196b Make some evbuffer functions const
svn:r1010
2009-01-14 22:17:31 +00:00
Nick Mathewson
3552ac1eb3 Do not allow chain length to expand indefinitely.
svn:r1007
2009-01-14 19:39:17 +00:00
Nick Mathewson
6d3ed0657d Simplify evbuffer_write logic: combine nearly all of WSASend and writev cases.
svn:r1004
2009-01-14 14:58:48 +00:00
Nick Mathewson
bab8f2e182 Fix compilation on win32 WSASend evbuffer_write() code.
Still not enabled until I make sure that the unit tests test this.  They _do_ pass.

svn:r1003
2009-01-13 22:02:32 +00:00
Nick Mathewson
169321c9e6 Rename four internal headers to follow the -internal.h convention.
svn:r1000
2009-01-13 20:26:37 +00:00
Nick Mathewson
822ca048ad Untested (and compiled-out) evbuffer_write backend to use WSASend on win32 where we use writev on unix.
svn:r998
2009-01-13 19:34:50 +00:00
Nick Mathewson
99db0e7f72 Add a new evbuffer_write_atmost() functino to write no more than a given number of bytes to an fd.
svn:r993
2009-01-12 20:42:19 +00:00
Niels Provos
e711ce454a reintroduce a memmove when there is enough misalignment to hold the new data; otherwise the size of the buffer may grow without bounds
svn:r857
2008-06-21 06:10:10 +00:00
Niels Provos
9586a1cbb0 fix an evbuffer corruption when adding an empty evbuffer; from Scott Lamb
svn:r845
2008-06-01 16:21:24 +00:00
Nick Mathewson
c6da86ffcb r19709@catbus: nickm | 2008-05-12 12:42:48 -0400
Possible fix for [1960723] snprintf and vsnprintf return values are wrong on win32


svn:r813
2008-05-12 16:44:24 +00:00
Nick Mathewson
6bf1ca780c r19675@catbus: nickm | 2008-05-11 20:39:39 -0400
Stop pretending that u_char and u_short are standard types that win32 is dumb not to have.  In fact, u_char can really just be spelled out, and u_short was usually just a bad way of saying ev_uint16_t.


svn:r808
2008-05-12 00:40:04 +00:00
Nick Mathewson
8acb80b4f9 r15551@tombo: nickm | 2008-05-08 14:49:20 -0400
Use _get_ convention for new accessor functions.  (These are all new ones as of 2.0, I believe).


svn:r799
2008-05-08 22:51:39 +00:00
Niels Provos
f04497e493 introduce evbuffer_reserve_space() and evbuffer_commit_space() to make processing in filters more efficient
svn:r757
2008-05-03 03:05:28 +00:00
Niels Provos
becc89b778 introduce evbuffer_contiguous_space() and use it in the zlib filter test
svn:r756
2008-05-03 02:37:18 +00:00
Nick Mathewson
49868b618a r15316@tombo: nickm | 2008-04-24 20:58:36 -0400
Rename internal memory management functions from event_malloc() etc to mm_malloc() etc.


svn:r725
2008-04-25 01:18:08 +00:00
Nick Mathewson
0ac73078ed r15193@tombo: nickm | 2008-04-16 16:00:35 -0400
Split event.h into several new headers in include/event2.  event.h is now just a wrapper that includes all the subheaders.


svn:r711
2008-04-16 20:01:51 +00:00
Niels Provos
193c06a7ed fix a bug in which evbuffer_add_vfprintf would loop forever; avoid
fragmentation in evbuffer_expand by increasing the size of the last buffer
in the chain; as a result with have to keep track of the previous_to_last
chain;   provide a evbuffer_validate() function in the regression test to
make sure that all evbuffer are internally consistent.


svn:r699
2008-03-31 02:04:34 +00:00
Niels Provos
00382110b2 address nick's comments and make evbuffer_pullup more efficient
svn:r680
2008-02-29 05:23:49 +00:00
Nick Mathewson
0322ce0a3b r18486@catbus: nickm | 2008-02-28 13:35:53 -0500
Make offsetof into evutil_offsetof.  Be a little more willing to call evbuffer_chain_align() from evbuffer_expand().  Clarify some docs, and add some XXX comments to note questionable areas.


svn:r677
2008-02-28 18:36:03 +00:00
Nick Mathewson
d71da6f737 r18484@catbus: nickm | 2008-02-28 12:47:20 -0500
Use event_warn() function, not fprintf-to-stderr.


svn:r676
2008-02-28 17:47:30 +00:00
Nick Mathewson
0e7cbe6508 r18482@catbus: nickm | 2008-02-28 12:38:40 -0500
Fix GCC 4.2 warnings; fix includes in subdirs.


svn:r675
2008-02-28 17:38:52 +00:00
Niels Provos
5c70ea4c9d improved code for evbuffer; avoids memcpy
svn:r674
2008-02-28 02:47:43 +00:00
Niels Provos
67bf29ad72 simplify evbuffer by removing orig_buffer
svn:r654
2008-02-23 06:02:04 +00:00
Nick Mathewson
1120f04f3e r16731@catbus: nickm | 2007-11-25 16:52:53 -0500
Replace all fds on non-unix-specific APIs with evutil_socket_t, which is int on unix and intptr_t on win32.


svn:r552
2007-11-25 21:53:06 +00:00
Nick Mathewson
6773a59721 r14953@tombo: nickm | 2007-11-25 15:56:40 -0500
Replace evbuffer_readline with a more powerful evbuffer_readln that can handle more EOL styles, and that can give useful results when there are NUL characters inside the returned values. Includes regression tests.


svn:r550
2007-11-25 21:32:26 +00:00