On Sat, Apr 27, 2013 at 1:52 PM, kgardenia42 <kgardeni...@googlemail.com> wrote: > Hi, > > I have a bufferevent_filter to parse some protocol data from the "src" > evbuffer and unwrap it into the "dst" evbuffer. > > This all works fine. The problem I have, however, is that when there > is a greedy sender sending a lot of data the input_filter just keeps > getting called hundreds or thousands of times, massively bloating the > dst buffer. > > What I would *like* to happen is for the lower level read callback (on > the bev which is wrapped by the filter) to be called so that dst gets > drained and I don't get the bloat. > > I've read the docs and I can't seem to grock this part of it and > couldn't find a relevant example. Can someone please advise how to > accomplish this? > > I see that the filter callback has a "enum bufferevent_flush_mode > state" parameter. Is this relevant here? >
I think you want to look into watermarks: it's a way to tell Libevent "Don't let this buffer get more full than X" or "don't bother me unless this buffer has at least X bytes". I'm too distracted to post good code for using watermarks together with filters tonight, but the idea should be pretty straightforward from the documentation and the reference manual. (If somebody _can_ write a good example, possibly nice and terse for inclusion in the manual, that would rock.) Let us know if it still doesn't make sense or doesn't work for you though. peace, -- Nick *********************************************************************** To unsubscribe, send an e-mail to majord...@freehaven.net with unsubscribe libevent-users in the body.