mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-30 22:05:36 +00:00
proc: allow parse_thread to use an existent buffer
parse_thread allocated a buffer for threads and then it initialized read pid for each thread. Now we want to use it on restore and in this moment we already have a buffer with initialized virt pid-s, so we need to initialize read pid-s only. Signed-off-by: Andrey Vagin <avagin@openvz.org> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
committed by
Pavel Emelyanov
parent
3e5ad587f4
commit
dbd41b522f
24
proc_parse.c
24
proc_parse.c
@@ -1246,6 +1246,9 @@ int parse_threads(int pid, struct pid **_t, int *_n)
|
||||
struct pid *t = NULL;
|
||||
int nr = 1;
|
||||
|
||||
if (*_t)
|
||||
t = *_t;
|
||||
|
||||
dir = opendir_proc(pid, "task");
|
||||
if (!dir)
|
||||
return -1;
|
||||
@@ -1257,21 +1260,26 @@ int parse_threads(int pid, struct pid **_t, int *_n)
|
||||
if (de->d_name[0] == '.')
|
||||
continue;
|
||||
|
||||
tmp = xrealloc(t, nr * sizeof(struct pid));
|
||||
if (!tmp) {
|
||||
xfree(t);
|
||||
return -1;
|
||||
if (*_t == NULL) {
|
||||
tmp = xrealloc(t, nr * sizeof(struct pid));
|
||||
if (!tmp) {
|
||||
xfree(t);
|
||||
return -1;
|
||||
}
|
||||
t = tmp;
|
||||
t[nr - 1].virt = -1;
|
||||
}
|
||||
t = tmp;
|
||||
t[nr - 1].real = atoi(de->d_name);
|
||||
t[nr - 1].virt = -1;
|
||||
nr++;
|
||||
}
|
||||
|
||||
closedir(dir);
|
||||
|
||||
*_t = t;
|
||||
*_n = nr - 1;
|
||||
if (*_t == NULL) {
|
||||
*_t = t;
|
||||
*_n = nr - 1;
|
||||
} else
|
||||
BUG_ON(nr - 1 != *_n);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user