mirror of
https://github.com/clearlinux/graphene.git
synced 2026-09-05 21:31:36 +00:00
[LibOS] Do not get/put handles when adding/removing from epoll
Previously, Graphene explicitly incremented refcount of a handle added to/removed from epoll, in epoll_ctl(EPOLL_CTL_ADD/EPOLL_CTL_DEL). However, according to epoll(7), closing a file descriptor causes the FD (handle) to be removed from all epoll sets. In other words, adding/removing a handle to/from epoll must not count towards refcount of the handle. Otherwise the handle remains dangling in the epoll set even if it was close()'d (this particular case led to Nginx segfault). This commit removes get/put of handle during epoll add/remove.
This commit is contained in:
committed by
Michał Kowalczyk
parent
1645e3435f
commit
0b6809fc19
@@ -137,7 +137,6 @@ int delete_from_epoll_handles(struct shim_handle* handle) {
|
||||
|
||||
LISTP_DEL(epoll_fd, &handle->epolls, back);
|
||||
unlock(&handle->lock);
|
||||
put_handle(handle);
|
||||
|
||||
struct shim_handle* epoll_hdl = epoll_fd->epoll;
|
||||
struct shim_epoll_handle* epoll = &epoll_hdl->info.epoll;
|
||||
@@ -217,6 +216,7 @@ int shim_do_epoll_ctl(int epfd, int op, int fd, struct __kernel_epoll_event* eve
|
||||
INIT_LIST_HEAD(epoll_fd, back);
|
||||
LISTP_ADD_TAIL(epoll_fd, &hdl->epolls, back);
|
||||
unlock(&hdl->lock);
|
||||
put_handle(hdl);
|
||||
|
||||
INIT_LIST_HEAD(epoll_fd, list);
|
||||
LISTP_ADD_TAIL(epoll_fd, &epoll->fds, list);
|
||||
@@ -250,7 +250,6 @@ int shim_do_epoll_ctl(int epfd, int op, int fd, struct __kernel_epoll_event* eve
|
||||
debug("delete handle %p from epoll handle %p\n", hdl, epoll);
|
||||
|
||||
put_handle(epoll_hdl);
|
||||
put_handle(hdl);
|
||||
|
||||
LISTP_DEL(epoll_fd, &epoll->fds, list);
|
||||
epoll->nfds--;
|
||||
|
||||
Reference in New Issue
Block a user