From: Mark Ellzey Date: Tue, 5 May 2015 17:37:00 +0000 (-0700) Subject: Call underlying bev ctrl SET_FD on filtered bufferevents X-Git-Tag: release-2.1.6-beta~90^2~82^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c2aa7dcb70635844134b54df4ccdf4d547a0b2b4;p=libevent Call underlying bev ctrl SET_FD on filtered bufferevents If a bufferevent_filter is set on an underlying bufferevent which has ctrl functions, bufferevent_filter needs to handle this. For now I have added just BEV_CTRL_SET_FD, since this is needed for bufferevent_sock to assign file descriptors to the proper bufferevent_read/write callbacks. A good example of the problem can be found in issue #237 https://github.com/libevent/libevent/issues/237 --- diff --git a/bufferevent_filter.c b/bufferevent_filter.c index 4d9be43e..6c3ffc4f 100644 --- a/bufferevent_filter.c +++ b/bufferevent_filter.c @@ -536,10 +536,20 @@ be_filter_ctrl(struct bufferevent *bev, enum bufferevent_ctrl_op op, bevf = upcast(bev); data->ptr = bevf->underlying; return 0; - case BEV_CTRL_GET_FD: case BEV_CTRL_SET_FD: + bevf = upcast(bev); + + if (bevf->underlying && + bevf->underlying->be_ops && + bevf->underlying->be_ops->ctrl) { + return (bevf->underlying->be_ops->ctrl)(bevf->underlying, op, data); + } + + case BEV_CTRL_GET_FD: case BEV_CTRL_CANCEL_ALL: default: return -1; } + + return -1; }