Commit 56497223 authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

restore: allocate pstree items from a shared pool (v2)

A pstree item will contain pid and state. Both these properties will be
determined after creating processes and will be used from the
controlling proces.

v2: fix the error path
Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent bd90e988
......@@ -134,9 +134,16 @@ struct pstree_item *__alloc_pstree_item(bool rst)
{
struct pstree_item *item;
item = xzalloc(sizeof(*item) + (rst ? sizeof(item->rst[0]) : 0));
if (!rst) {
item = xzalloc(sizeof(*item));
if (!item)
return NULL;
} else {
item = shmalloc(sizeof(*item) + sizeof(item->rst[0]));
if (!item)
return NULL;
memset(item, 0, sizeof(*item) + sizeof(item->rst[0]));
}
INIT_LIST_HEAD(&item->children);
INIT_LIST_HEAD(&item->sibling);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment