mirror of
https://github.com/apache/nuttx.git
synced 2026-06-01 16:59:28 +08:00
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 <xiaoxiang@xiaomi.com>
This commit is contained in:
committed by
Petro Karashchenko
parent
56b2e7254a
commit
7c1768c167
+2
-3
@@ -535,21 +535,20 @@ int epoll_ctl(int epfd, int op, int fd, FAR struct epoll_event *ev)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
extend = kmm_zalloc(sizeof(*extend) +
|
extend = kmm_zalloc(sizeof(*extend) +
|
||||||
sizeof(epoll_node_t) * eph->size);
|
2 * sizeof(epoll_node_t) * eph->size);
|
||||||
if (extend == NULL)
|
if (extend == NULL)
|
||||||
{
|
{
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
eph->size *= 2;
|
||||||
list_add_tail(&eph->extend, extend);
|
list_add_tail(&eph->extend, extend);
|
||||||
epn = (FAR epoll_node_t *)(extend + 1);
|
epn = (FAR epoll_node_t *)(extend + 1);
|
||||||
for (i = 0; i < eph->size; i++)
|
for (i = 0; i < eph->size; i++)
|
||||||
{
|
{
|
||||||
list_add_tail(&eph->free, &epn[i].node);
|
list_add_tail(&eph->free, &epn[i].node);
|
||||||
}
|
}
|
||||||
|
|
||||||
eph->size += eph->size;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
epn = container_of(list_remove_head(&eph->free), epoll_node_t, node);
|
epn = container_of(list_remove_head(&eph->free), epoll_node_t, node);
|
||||||
|
|||||||
Reference in New Issue
Block a user