]> granicus.if.org Git - libevent/commitdiff
Call underlying bev ctrl SET_FD on filtered bufferevents
authorMark Ellzey <socket@gmail.com>
Tue, 5 May 2015 17:37:00 +0000 (10:37 -0700)
committerMark Ellzey <socket@gmail.com>
Tue, 5 May 2015 17:37:00 +0000 (10:37 -0700)
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

bufferevent_filter.c

index 4d9be43e25db8c69743f712b5cbdc6afcec48e5b..6c3ffc4f2d9e2b8b947d6d51e2eae14134fd3fa1 100644 (file)
@@ -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;
 }