From 7c1768c167ea1db1dd1935fd1d34bbdd9b761b9b Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Sun, 28 Jul 2024 20:27:28 +0800 Subject: [PATCH] fs/epoll: Double array size when it is full correct the sequnce of array size from: size, size, 2*size, 4*size, 8*size... to: size, 2*size, 4*size, 8*size, 16*size... Signed-off-by: Xiang Xiao --- fs/vfs/fs_epoll.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/fs/vfs/fs_epoll.c b/fs/vfs/fs_epoll.c index 76d754d766..5b880fc35d 100644 --- a/fs/vfs/fs_epoll.c +++ b/fs/vfs/fs_epoll.c @@ -535,21 +535,20 @@ int epoll_ctl(int epfd, int op, int fd, FAR struct epoll_event *ev) */ extend = kmm_zalloc(sizeof(*extend) + - sizeof(epoll_node_t) * eph->size); + 2 * sizeof(epoll_node_t) * eph->size); if (extend == NULL) { ret = -ENOMEM; goto err; } + eph->size *= 2; list_add_tail(&eph->extend, extend); epn = (FAR epoll_node_t *)(extend + 1); for (i = 0; i < eph->size; i++) { list_add_tail(&eph->free, &epn[i].node); } - - eph->size += eph->size; } epn = container_of(list_remove_head(&eph->free), epoll_node_t, node);