diff options
author | Mark Ellzey <socket@gmail.com> | 2015-05-05 10:37:00 -0700 |
---|---|---|
committer | Mark Ellzey <socket@gmail.com> | 2015-05-05 10:37:00 -0700 |
commit | c2aa7dcb70635844134b54df4ccdf4d547a0b2b4 (patch) | |
tree | 206f1119ab52ec48be6e474c29099bb87889eff3 /bufferevent_filter.c | |
parent | a695a720cda892c270736d127333d73553842094 (diff) | |
download | libevent-c2aa7dcb70635844134b54df4ccdf4d547a0b2b4.tar.gz |
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
Diffstat (limited to 'bufferevent_filter.c')
-rw-r--r-- | bufferevent_filter.c | 12 |
1 files changed, 11 insertions, 1 deletions
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; } |