Commit 096dc144 authored by Kirill Tkhai's avatar Kirill Tkhai Committed by Pavel Emelyanov

files: Use non-block __recv_fds() in recv_fd_from_peer()

Save one syscall and analyze recvmsg() error code to check
that there is no data in the socket.
Signed-off-by: 's avatarKirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent 15ac89db
......@@ -888,22 +888,17 @@ static int plant_fd(struct fdinfo_list_entry *fle, int fd)
int recv_fd_from_peer(struct fdinfo_list_entry *fle)
{
struct fdinfo_list_entry *tmp;
int fd, ret, tsock, count;
int fd, ret, tsock;
if (fle->received)
return 0;
tsock = get_service_fd(TRANSPORT_FD_OFF);
do {
if (ioctl(tsock, FIONREAD, &count) < 0) {
pr_perror("Can't do ioctl on transport sock: pid=%d\n", fle->pid);
return -1;
} else if (count == 0)
ret = __recv_fds(tsock, &fd, 1, (void *)&tmp, sizeof(struct fdinfo_list_entry *), MSG_DONTWAIT);
if (ret == -EAGAIN || ret == -EWOULDBLOCK)
return 1;
ret = recv_fds(tsock, &fd, 1, (void *)&tmp, sizeof(struct fdinfo_list_entry *));
if (ret)
else if (ret)
return -1;
pr_info("Further fle=%p, pid=%d\n", tmp, fle->pid);
......
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