On Tue, Mar 13, 2018 at 7:42 PM, Bruno CARLUS <[email protected]> wrote: > Hello, > > I just identified a little problem in my code: > I use a filter bufferevent wrapped on a socket bufferevent, for example: > > bev = bufferevent_socket_new(base, listener, BEV_OPT_CLOSE_ON_FREE); > struct timeval timeout_read = {5, 0}; > bufferevent_set_timeouts(bev, &timeout_read, NULL); > bufferevent_setwatermark(bev, EV_READ, 1500, 0); > > bev_filter = bufferevent_filter_new(bev, readandfiltercb, NULL, > BEV_OPT_CLOSE_ON_FREE, NULL, NULL); > bufferevent_setwatermark(bev_filter, EV_READ, 3000, 0); > bufferevent_setcb(bev_filter, freadcb, fwritecb, eventcb, NULL); > > I'm sending 1000 bytes packets on this socket. > readandfiltercb is called every 2 packets: it filters data and copy it to the > bev_filter input buffer. > freadcb is then called ok. > > But when udp stream is over, it remains one 1000 bytes packet in the buffer. > eventcb is called because of the timeout: then it flushes bufferevent > readandfiltercb is called ok: it filters and copies last bytes to bev_filter > input buffer. > But then freadcb is not called at all. > > Is it normal? > How to force bypass the watermark and flush bev_filter input buffer as well?
Hello, I don't think so, my guess is that during flush it doesn't call readcb (in be_filter_flush() there is no bufferevent_trigger_nolock_() like in be_filter_read_nolock_()). I will write a test today and will come back to you later, in the evening. > Last point: Is the underlying fd of a bufferevent can be a mmap file? > I could not find reference to the use of EVBUFFER_SENDFILE in the doc... How you will poll mmaped fd? Can you explain this a little bit more? Maybe I'm missing something. -- Azat. *********************************************************************** To unsubscribe, send an e-mail to [email protected] with unsubscribe libevent-users in the body.
