o allow connections to be removed from an rpc pool
o add new evtimer_assign, signal_assign, evtimer_new, and signal_new functions to manipulate timer and signal events, analagous to the now-recommended event_assign and event_new
o switch internal uses of event_set over to use event_assign.
-
+ o introduce evbuffer_contiguous_space() api that tells a user how much data is available in the first buffer chain
+
Changes in 1.4.0:
o allow \r or \n individually to separate HTTP headers instead of the standard "\r\n"; from Charles Kerr.
o demote most http warnings to debug messages
*/
size_t evbuffer_length(struct evbuffer *buf);
+/**
+ Returns the contiguous number of available bytes in the first buffer chain.
+
+ This is useful when processing of all available data can be split up into
+ chunks. Calls to evbuffer_pullup() that cause reallocation and copying
+ of data can thus be avoided.
+
+ @param buf pointer to the evbuffer
+ @return 0 if no data is available, otherwise the number of available bytes
+ in the first buffer chain.
+*/
+size_t evbuffer_contiguous_space(struct evbuffer *buf);
+
/**
Expands the available space in an event buffer.
do {
/* let's do some decompression */
- p->avail_in = EVBUFFER_LENGTH(src);
+ p->avail_in = evbuffer_contiguous_space(src);
p->next_in = evbuffer_pullup(src, p->avail_in);
p->next_out = (unsigned char *)tmp;
assert(res == Z_OK || res == Z_STREAM_END);
/* let's figure out how much was compressed */
- nread = EVBUFFER_LENGTH(src) - p->avail_in;
+ nread = evbuffer_contiguous_space(src) - p->avail_in;
nwrite = sizeof(tmp) - p->avail_out;
evbuffer_drain(src, nread);
do {
/* let's do some compression */
- p->avail_in = EVBUFFER_LENGTH(src);
+ p->avail_in = evbuffer_contiguous_space(src);
p->next_in = evbuffer_pullup(src, p->avail_in);
p->next_out = (unsigned char *)tmp;
assert(res == Z_OK || res == Z_STREAM_END);
/* let's figure out how much was compressed */
- nread = EVBUFFER_LENGTH(src) - p->avail_in;
+ nread = evbuffer_contiguous_space(src) - p->avail_in;
nwrite = sizeof(tmp) - p->avail_out;
evbuffer_drain(src, nread);
for (i = 0; i < sizeof(buffer); i++)
buffer[i] = i;
- bufferevent_write(bev1, buffer, sizeof(buffer));
+ /* break it up into multiple buffer chains */
+ bufferevent_write(bev1, buffer, 1800);
+ bufferevent_write(bev1, buffer + 1800, sizeof(buffer) - 1800);
/* we are done writing - we need to flush everything */
bufferevent_trigger_filter(bev1, NULL, BEV_OUTPUT, BEV_FLUSH);
bufferevent_free(bev1);
bufferevent_free(bev2);
- if (test_ok != 5) {
+ if (test_ok != 6) {
fprintf(stdout, "FAILED: %d\n", test_ok);
exit(1);
}