Commit 1ce1cca2 authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

sk-queue: don't block on restore of socket queues

If a socket queue doesn't have a free space, a error should be returned,
because nobody reads this socket.
Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent ea20f5d2
......@@ -189,10 +189,20 @@ void show_sk_queues(int fd, struct cr_options *o)
int restore_sk_queue(int fd, unsigned int peer_id)
{
struct sk_packet *pkt, *tmp;
int ret, img_fd;
int ret, img_fd, flags;
pr_info("Trying to restore recv queue for %u\n", peer_id);
flags = fcntl(fd, F_GETFL, 0);
if (flags == -1) {
pr_perror("Unable to get flags for %d", fd);
return -1;
}
if (fcntl(fd, F_SETFL, flags | O_NONBLOCK) ) {
pr_perror("Unable to set O_NONBLOCK for %d", fd);
return -1;
}
img_fd = open_image_ro(CR_FD_SK_QUEUES);
if (img_fd < 0)
return -1;
......@@ -221,6 +231,11 @@ int restore_sk_queue(int fd, unsigned int peer_id)
xfree(pkt);
}
if (fcntl(fd, F_SETFL, flags) ) {
pr_perror("Unable to restore flags for %d", fd);
return -1;
}
close(img_fd);
return 0;
}
......@@ -75,6 +75,7 @@ int restore_socket_opts(int sk, SkOptsEntry *soe)
int ret = 0;
struct timeval tv;
pr_info("%d restore sndbuf %d rcv buf %d\n", sk, soe->so_sndbuf, soe->so_rcvbuf);
ret |= restore_opt(sk, SOL_SOCKET, SO_SNDBUFFORCE, &soe->so_sndbuf);
ret |= restore_opt(sk, SOL_SOCKET, SO_RCVBUFFORCE, &soe->so_rcvbuf);
......
......@@ -40,6 +40,7 @@ TST_NOFILE = \
sockets_spair \
sockets_dgram \
socket_queues \
socket_queues02 \
socket-tcp \
ipc_namespace \
selfexe00 \
......
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