Commit d2e30bcc authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

rlimit: Allocate and free appropriate Core entry, v2

On Thu, Mar 13, 2014 at 04:20:37PM +0400, Pavel Emelyanov wrote:
>
> Would you rework this patch on top of my recent
> "allocate Core in on xmalloc call" one?

Attached.

>From c2233d4fafce30c4e7214a1a7ab3677824a30d75 Mon Sep 17 00:00:00 2001
From: Cyrill Gorcunov <gorcunov@openvz.org>
Date: Thu, 13 Mar 2014 16:57:14 +0400
Subject: [PATCH] rlimit: Allocate and free appropriate Core entry
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 2341cd1f
......@@ -29,8 +29,14 @@ CoreEntry *core_entry_alloc(int th, int tsk)
void *m;
sz = sizeof(CoreEntry);
if (tsk)
if (tsk) {
sz += sizeof(TaskCoreEntry) + TASK_COMM_LEN;
if (th) {
sz += sizeof(TaskRlimitsEntry);
sz += RLIM_NLIMITS * sizeof(RlimitEntry *);
sz += RLIM_NLIMITS * sizeof(RlimitEntry);
}
}
if (th)
sz += sizeof(ThreadCoreEntry) + sizeof(ThreadSasEntry);
......@@ -45,6 +51,23 @@ CoreEntry *core_entry_alloc(int th, int tsk)
task_core_entry__init(core->tc);
core->tc->comm = xptr_pull_s(&m, TASK_COMM_LEN);
memzero(core->tc->comm, TASK_COMM_LEN);
if (th) {
TaskRlimitsEntry *rls;
int i;
rls = xptr_pull(&m, TaskRlimitsEntry);
task_rlimits_entry__init(rls);
core->rlimits = rls;
rls->n_rlimits = RLIM_NLIMITS;
rls->rlimits = xptr_pull_s(&m, sizeof(RlimitEntry *) * RLIM_NLIMITS);
for (i = 0; i < RLIM_NLIMITS; i++) {
rls->rlimits[i] = xptr_pull(&m, RlimitEntry);
rlimit_entry__init(rls->rlimits[i]);
}
}
}
if (th) {
......
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