[CRIU] Re: [PATCH cr 1/2] sk-queue: don't block on restore of
socket queues
Pavel Emelyanov
xemul at parallels.com
Fri Sep 28 08:39:14 EDT 2012
On 09/28/2012 08:37 PM, Andrey Vagin wrote:
> If a socket queue doesn't have a free space, a error should be returned,
> because nobody reads this socket.
>
> Signed-off-by: Andrey Vagin <avagin at openvz.org>
> ---
> sk-queue.c | 17 ++++++++++++++++-
> sockets.c | 1 +
> test/zdtm/live/static/Makefile | 1 +
> 3 files changed, 18 insertions(+), 1 deletions(-)
>
> diff --git a/sk-queue.c b/sk-queue.c
> index 347f987..6cc2153 100644
> --- a/sk-queue.c
> +++ b/sk-queue.c
> @@ -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;
> + }
Do we need this? We'll restore the fd flags anyway.
> +
> close(img_fd);
> return 0;
> }
> diff --git a/sockets.c b/sockets.c
> index 739e98f..50bd058 100644
> --- a/sockets.c
> +++ b/sockets.c
> @@ -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);
>
> diff --git a/test/zdtm/live/static/Makefile b/test/zdtm/live/static/Makefile
> index 072ec1e..f23c4cd 100644
> --- a/test/zdtm/live/static/Makefile
> +++ b/test/zdtm/live/static/Makefile
> @@ -40,6 +40,7 @@ TST_NOFILE = \
> sockets_spair \
> sockets_dgram \
> socket_queues \
> + socket_queues02 \
> socket-tcp \
> ipc_namespace \
> selfexe00 \
More information about the CRIU
mailing list