Conversation
nbd168
commented
Feb 7, 2026
- avoid double close of externally owned channel fds
- fix refcounting bug
In uc_ubus_channel_req_cb an extra ref is taken for args and method, which are not used elsewhere. Signed-off-by: Felix Fietkau <nbd@nbd.name>
When a channel is opened via an fd obtained through fileno(), the fd is owned by an external resource. Track this in fd_handle and detach from uloop without closing the fd on disconnect/shutdown. Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
The args/type refcount fix is straightforward and clear, but I do not understand the purpose of the external fd fix. Why should we treat fd numbers obtained from Can you elaborate some more on the kind of issue you try to address with this fix? Should we rather never close fds at all in the channel case and leave it to the caller to clean them up? |
The change that I made addresses a nasty corner case in unetmsg, where the channel disconnect was closing the fd, and before the handle was freed (which would close the fd again), the fd number was already reused. This was causing the handle free to close an unrelated different open fd. |