mirror of
https://github.com/checkpoint-restore/criu
synced 2025-09-01 14:55:39 +00:00
fdset: Kill ability to re-use fdset
It's not required any longer. Now fdsets are allocated one-by-one only when required and there's no need in adding new fds to existing sets. Thus just remove the last arg from cr_fdset_open. Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
@@ -1302,7 +1302,7 @@ static int dump_one_task(const struct pstree_item *item)
|
|||||||
return dump_one_zombie(item, &pps_buf);
|
return dump_one_zombie(item, &pps_buf);
|
||||||
|
|
||||||
ret = -1;
|
ret = -1;
|
||||||
cr_fdset = cr_dump_fdset_open(item->pid, CR_FD_DESC_TASK, NULL);
|
cr_fdset = cr_dump_fdset_open(item->pid, CR_FD_DESC_TASK);
|
||||||
if (!cr_fdset)
|
if (!cr_fdset)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
|
29
crtools.c
29
crtools.c
@@ -157,7 +157,7 @@ static struct cr_fdset *alloc_cr_fdset(void)
|
|||||||
return cr_fdset;
|
return cr_fdset;
|
||||||
}
|
}
|
||||||
|
|
||||||
void __close_cr_fdset(struct cr_fdset *cr_fdset)
|
static void __close_cr_fdset(struct cr_fdset *cr_fdset)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
@@ -184,21 +184,15 @@ void close_cr_fdset(struct cr_fdset **cr_fdset)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static struct cr_fdset *cr_fdset_open(int pid, unsigned long use_mask,
|
static struct cr_fdset *cr_fdset_open(int pid, unsigned long use_mask,
|
||||||
unsigned long flags, struct cr_fdset *cr_fdset)
|
unsigned long flags)
|
||||||
{
|
{
|
||||||
struct cr_fdset *fdset;
|
struct cr_fdset *fdset;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
/*
|
fdset = alloc_cr_fdset();
|
||||||
* We either reuse existing fdset or create new one.
|
if (!fdset)
|
||||||
*/
|
goto err;
|
||||||
if (!cr_fdset) {
|
|
||||||
fdset = alloc_cr_fdset();
|
|
||||||
if (!fdset)
|
|
||||||
goto err;
|
|
||||||
} else
|
|
||||||
fdset = cr_fdset;
|
|
||||||
|
|
||||||
for (i = 0; i < CR_FD_PID_MAX; i++) {
|
for (i = 0; i < CR_FD_PID_MAX; i++) {
|
||||||
if (!(use_mask & CR_FD_DESC_USE(i)))
|
if (!(use_mask & CR_FD_DESC_USE(i)))
|
||||||
@@ -221,23 +215,18 @@ static struct cr_fdset *cr_fdset_open(int pid, unsigned long use_mask,
|
|||||||
return fdset;
|
return fdset;
|
||||||
|
|
||||||
err:
|
err:
|
||||||
if (fdset != cr_fdset)
|
close_cr_fdset(&fdset);
|
||||||
__close_cr_fdset(fdset);
|
|
||||||
else
|
|
||||||
close_cr_fdset(&fdset);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cr_fdset *cr_dump_fdset_open(int pid, unsigned long use_mask,
|
struct cr_fdset *cr_dump_fdset_open(int pid, unsigned long use_mask)
|
||||||
struct cr_fdset *cr_fdset)
|
|
||||||
{
|
{
|
||||||
return cr_fdset_open(pid, use_mask, O_RDWR | O_CREAT | O_EXCL,
|
return cr_fdset_open(pid, use_mask, O_RDWR | O_CREAT | O_EXCL);
|
||||||
cr_fdset);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct cr_fdset *cr_show_fdset_open(int pid, unsigned long use_mask)
|
struct cr_fdset *cr_show_fdset_open(int pid, unsigned long use_mask)
|
||||||
{
|
{
|
||||||
return cr_fdset_open(pid, use_mask, O_RDONLY, NULL);
|
return cr_fdset_open(pid, use_mask, O_RDONLY);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int parse_ns_string(const char *ptr, unsigned int *flags)
|
static int parse_ns_string(const char *ptr, unsigned int *flags)
|
||||||
|
@@ -143,7 +143,7 @@ int cr_show(unsigned long pid, struct cr_options *opts);
|
|||||||
int convert_to_elf(char *elf_path, int fd_core);
|
int convert_to_elf(char *elf_path, int fd_core);
|
||||||
int cr_check(void);
|
int cr_check(void);
|
||||||
|
|
||||||
struct cr_fdset *cr_dump_fdset_open(int pid, unsigned long use_mask, struct cr_fdset *);
|
struct cr_fdset *cr_dump_fdset_open(int pid, unsigned long use_mask);
|
||||||
struct cr_fdset *cr_show_fdset_open(int pid, unsigned long use_mask);
|
struct cr_fdset *cr_show_fdset_open(int pid, unsigned long use_mask);
|
||||||
void close_cr_fdset(struct cr_fdset **cr_fdset);
|
void close_cr_fdset(struct cr_fdset **cr_fdset);
|
||||||
|
|
||||||
|
@@ -33,7 +33,7 @@ static int do_dump_namespaces(int ns_pid, unsigned int ns_flags)
|
|||||||
struct cr_fdset *fdset;
|
struct cr_fdset *fdset;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
fdset = cr_dump_fdset_open(ns_pid, CR_FD_DESC_NS, NULL);
|
fdset = cr_dump_fdset_open(ns_pid, CR_FD_DESC_NS);
|
||||||
if (fdset == NULL)
|
if (fdset == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user