261 Commits

Author SHA1 Message Date
Niels Provos
8e8d94a3e0 Do not drop data from evbuffer when out of memory; reported by Jacek Masiulaniec
svn:r1436
2009-09-24 22:18:19 +00:00
Nick Mathewson
3b461a6d03 Treat a negative number of bytes to read as the kernel saying "I don't know."
svn:r1426
2009-09-11 18:21:37 +00:00
Nick Mathewson
22bd5b4287 Support sendfile on solaris: patch from Caitlin Mercer.
svn:r1419
2009-08-16 16:40:42 +00:00
Nick Mathewson
8a99083f01 Add an evbuffer_search_range() to search a bounded range of a buffer
This can be handy when you have	one search to find the end of a	header
section, and then you want to find a substring within the header
section without looking at the body.

svn:r1410
2009-08-07 17:16:52 +00:00
Nick Mathewson
d41347722a Refactor evbuffer_readln() into a search-for-eol function and an extract-line function.
svn:r1404
2009-07-31 17:35:42 +00:00
Nick Mathewson
a26d2d1b87 Refactor evbuffer_readln to use evbuffer_ptr; remove old evbuffer_iterator.
svn:r1403
2009-07-31 17:34:47 +00:00
Nick Mathewson
b06b2649b4 Make "deferred callback queue" independent of event_base.
This way, we can more easily have an IOCP bufferevent implementation
that does not need an event_base at all.  Woot.

svn:r1381
2009-07-26 01:29:39 +00:00
Nick Mathewson
8eb155a1c0 Fix build on platforms (like Solaris 10, reportedly) which lack a MAP_FILE.
svn:r1375
2009-07-23 14:48:24 +00:00
Nick Mathewson
5aefb8a6d6 Fix type on freebsd sendfile. Patch from navin seshadri. Fixes bug 2811991
svn:r1330
2009-06-25 15:22:36 +00:00
Nick Mathewson
0b22ca1929 Use ev_ssize_t in place of ssize_t *everywhere*.
svn:r1309
2009-05-22 19:11:48 +00:00
Nick Mathewson
8997f234f2 Use the native "struct iovec" as our "struct evbuffer_iovec" when available, so we do not need to copy more pointers than necessary.
svn:r1299
2009-05-21 20:59:00 +00:00
Nick Mathewson
23243b8a98 Replace reserve/commit with new iovec-based interface. Add a new evbuffer_peek.
svn:r1296
2009-05-19 21:39:35 +00:00
Nick Mathewson
dc4c7b9570 Change the interface of evbuffer_add_reference: give the cleanup function more info.
svn:r1294
2009-05-15 22:44:18 +00:00
Nick Mathewson
bba69e03f8 New semantics for evbuffer_cb_set_flags().
Previously, set_flags() would replace all previous user-visible flags.
Now it just sets the flags, and there is a clear_flags() function to
clear other flags.

svn:r1293
2009-05-15 20:23:59 +00:00
Nick Mathewson
e865eb938c More msvc build tweaks.
svn:r1262
2009-05-01 00:54:14 +00:00
Nick Mathewson
24607a397c Note a place we might do better about lock releasing.
svn:r1252
2009-04-29 20:48:43 +00:00
Nick Mathewson
11cab33418 Fix compile: #elif FOO is not the same as #elif defined(FOO).
svn:r1245
2009-04-28 19:08:07 +00:00
Niels Provos
5c4c13d8c2 make sendfile work on freebsd
svn:r1239
2009-04-24 03:24:22 +00:00
Nick Mathewson
ec6bfd0335 Fix for evbuffer_read() when all data fits in penultimate chain.
Previously we were reading into the next-to-last chain, but incrementing
the fullness of the last.  Bug found by Victor Goya.

svn:r1237
2009-04-23 21:41:53 +00:00
Nick Mathewson
a8f6d961eb Actually stop using EVBUFFER_LENGTH/DATA, and move them to buffer_compat.h
svn:r1183
2009-04-17 06:56:09 +00:00
Nick Mathewson
93d4f884aa Make buffer iocp stuff compile happily
svn:r1174
2009-04-14 20:11:10 +00:00
Nick Mathewson
0e32ba54dc Do not remove an empty chain that we have pinned for reading when we drain the whole buffer.
svn:r1166
2009-04-13 03:06:59 +00:00
Nick Mathewson
9f1a94ecec add pin/unpin functions, and a deref-and-free pair.
svn:r1165
2009-04-13 03:06:47 +00:00
Nick Mathewson
dcda7915ac Add a reference count to evbuffers.
svn:r1164
2009-04-13 03:06:27 +00:00
Nick Mathewson
b01891fe1d Make evbuffer_commit_space trigger callbacks.
svn:r1163
2009-04-13 03:06:05 +00:00
Nick Mathewson
829b52b6c1 Refactor the code that sets up iovecs for reading into its own function. iocp needs this.
svn:r1162
2009-04-13 03:05:46 +00:00
Nick Mathewson
b29b875d84 Facility to make evbuffers get their callbacks deferred.
svn:r1154
2009-04-10 20:43:08 +00:00
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