Commit 68a793a0 authored by Pavel Emelyanov's avatar Pavel Emelyanov

files: Users counter is not required on file desc

It's used only to check whether we should do file re-send and verify we've served
all the cliens. This can be replaced with proper list manipulations.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 89492de3
...@@ -85,7 +85,6 @@ static int collect_fd(int pid, struct fdinfo_entry *e) ...@@ -85,7 +85,6 @@ static int collect_fd(int pid, struct fdinfo_entry *e)
if ((desc->id != e->id) || (desc->type != e->type)) if ((desc->id != e->id) || (desc->type != e->type))
continue; continue;
futex_inc(&fdinfo_descs[i].users);
list_add(&le->list, &desc->list); list_add(&le->list, &desc->list);
if (fdinfo_descs[i].pid < pid) if (fdinfo_descs[i].pid < pid)
...@@ -110,7 +109,6 @@ static int collect_fd(int pid, struct fdinfo_entry *e) ...@@ -110,7 +109,6 @@ static int collect_fd(int pid, struct fdinfo_entry *e)
desc->addr = e->addr; desc->addr = e->addr;
desc->pid = pid; desc->pid = pid;
INIT_LIST_HEAD(&desc->list); INIT_LIST_HEAD(&desc->list);
futex_set(&desc->users, 1);
list_add(&le->list, &desc->list); list_add(&le->list, &desc->list);
nr_fdinfo_descs++; nr_fdinfo_descs++;
...@@ -277,8 +275,7 @@ static int open_transport_fd(int pid, struct fdinfo_entry *fe, ...@@ -277,8 +275,7 @@ static int open_transport_fd(int pid, struct fdinfo_entry *fe,
transport_name_gen(&saddr, &sun_len, getpid(), fe->addr); transport_name_gen(&saddr, &sun_len, getpid(), fe->addr);
pr_info("\t%d: Create transport fd for %lx users %d\n", pid, pr_info("\t%d: Create transport fd for %lx\n", pid, fe->addr);
fe->addr, futex_get(&fi->users));
fle = find_fdinfo_list_entry(pid, fe->addr, fi); fle = find_fdinfo_list_entry(pid, fe->addr, fi);
...@@ -329,7 +326,7 @@ static int open_fd(int pid, struct fdinfo_entry *fe, ...@@ -329,7 +326,7 @@ static int open_fd(int pid, struct fdinfo_entry *fe,
if (reopen_fd_as((int)fe->addr, tmp)) if (reopen_fd_as((int)fe->addr, tmp))
return -1; return -1;
if (futex_get(&fi->users) == 1) if (list_empty(&fi->list))
goto out; goto out;
sock = socket(PF_UNIX, SOCK_DGRAM, 0); sock = socket(PF_UNIX, SOCK_DGRAM, 0);
...@@ -338,14 +335,11 @@ static int open_fd(int pid, struct fdinfo_entry *fe, ...@@ -338,14 +335,11 @@ static int open_fd(int pid, struct fdinfo_entry *fe,
return -1; return -1;
} }
pr_info("\t%d: Create fd for %lx users %d\n", pid, pr_info("\t%d: Create fd for %lx\n", pid, fe->addr);
fe->addr, futex_get(&fi->users));
list_for_each_entry(fle, &fi->list, list) { list_for_each_entry(fle, &fi->list, list) {
int len; int len;
futex_dec(&fi->users);
if (pid == fle->pid) if (pid == fle->pid)
continue; continue;
...@@ -361,7 +355,6 @@ static int open_fd(int pid, struct fdinfo_entry *fe, ...@@ -361,7 +355,6 @@ static int open_fd(int pid, struct fdinfo_entry *fe,
} }
} }
BUG_ON(futex_get(&fi->users));
close(sock); close(sock);
out: out:
return 0; return 0;
...@@ -384,8 +377,7 @@ static int receive_fd(int pid, struct fdinfo_entry *fe, struct fdinfo_desc *fi) ...@@ -384,8 +377,7 @@ static int receive_fd(int pid, struct fdinfo_entry *fe, struct fdinfo_desc *fi)
return 0; return 0;
} }
pr_info("\t%d: Receive fd for %lx users %d\n", pid, pr_info("\t%d: Receive fd for %lx\n", pid, fe->addr);
fe->addr, futex_get(&fi->users));
tmp = recv_fd(fe->addr); tmp = recv_fd(fe->addr);
if (tmp < 0) { if (tmp < 0) {
...@@ -433,8 +425,7 @@ static int open_fdinfo(int pid, struct fdinfo_entry *fe, int *fdinfo_fd, int sta ...@@ -433,8 +425,7 @@ static int open_fdinfo(int pid, struct fdinfo_entry *fe, int *fdinfo_fd, int sta
if (move_img_fd(fdinfo_fd, (int)fe->addr)) if (move_img_fd(fdinfo_fd, (int)fe->addr))
return -1; return -1;
pr_info("\t%d: Got fd for %lx users %d\n", pid, pr_info("\t%d: Got fd for %lx\n", pid, fe->addr);
fe->addr, futex_get(&fi->users));
BUG_ON(fd_is_special(fe)); BUG_ON(fd_is_special(fe));
......
...@@ -37,7 +37,6 @@ struct fdinfo_desc { ...@@ -37,7 +37,6 @@ struct fdinfo_desc {
u32 type; u32 type;
u64 addr; u64 addr;
int pid; int pid;
futex_t users;
struct list_head list; struct list_head list;
}; };
......
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