Commit 7241b929 authored by Pavel Emelyanov's avatar Pavel Emelyanov

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: 's avatarPavel Emelyanov <xemul@parallels.com>
parent b77400fe
......@@ -1302,7 +1302,7 @@ static int dump_one_task(const struct pstree_item *item)
return dump_one_zombie(item, &pps_buf);
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)
goto err;
......
......@@ -157,7 +157,7 @@ static struct cr_fdset *alloc_cr_fdset(void)
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;
......@@ -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,
unsigned long flags, struct cr_fdset *cr_fdset)
unsigned long flags)
{
struct cr_fdset *fdset;
unsigned int i;
int ret = -1;
/*
* We either reuse existing fdset or create new one.
*/
if (!cr_fdset) {
fdset = alloc_cr_fdset();
if (!fdset)
goto err;
} else
fdset = cr_fdset;
fdset = alloc_cr_fdset();
if (!fdset)
goto err;
for (i = 0; i < CR_FD_PID_MAX; 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;
err:
if (fdset != cr_fdset)
__close_cr_fdset(fdset);
else
close_cr_fdset(&fdset);
close_cr_fdset(&fdset);
return NULL;
}
struct cr_fdset *cr_dump_fdset_open(int pid, unsigned long use_mask,
struct cr_fdset *cr_fdset)
struct cr_fdset *cr_dump_fdset_open(int pid, unsigned long use_mask)
{
return cr_fdset_open(pid, use_mask, O_RDWR | O_CREAT | O_EXCL,
cr_fdset);
return cr_fdset_open(pid, use_mask, O_RDWR | O_CREAT | O_EXCL);
}
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)
......
......@@ -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 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);
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;
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)
return -1;
......
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