Greetings,
I'm trying to understand how to properly free bufferevents when all data
is finished sending using filters chain.
I.e. I have one bufferevent and bufferevent_filter on top of it. I'm
writing some data into filter, and on some event I'm deciding that all
data is sent and I want to close it. If I close it immediately with
bufferevent_free I'll loose data that is in output_buffer, but is not
sent to the client. I there is no filter I'm setting write callback and,
there I check if there is still data in output_buffer and call
bufferevent_free if it's empty. With filters it doesn't work because
filter write_callback is called when underlying buffer can accept data
AND there is data in filter buffer (BEV_NORMAL), so if there is no data
in filter buffer, but there is some in underlying buffer, it will not be
called.
To fix this there should be got_out_eof in struct
bufferevent_filtered, that should be set when bufferevent_flush is
called with EV_WRITE, after that be_filter_process_output should call
user write callback no mater what. After that in user write callback we
check if all output buffers in filters chain are empty and if yes, then
free the filter bufferent. Am I missing something?
Artem Germanov.
***********************************************************************
To unsubscribe, send an e-mail to majord...@freehaven.net with
unsubscribe libevent-users in the body.