Quoting Dan Smith ([email protected]):
> This cleanup routine checks for unattached sockets that we instantiated
> and calls sock_release() on them to avoid leaking the struct socket when
> their buffers are consumed and the struct sock is free'd.
> 
> Signed-off-by: Dan Smith <[email protected]>

I realize it's being discussed on irc, but it looks good to me, so
whatever variation you end up doing,

Acked-by: Serge Hallyn <[email protected]>

> ---
>  checkpoint/objhash.c |   13 +++++++++++++
>  1 files changed, 13 insertions(+), 0 deletions(-)
> 
> diff --git a/checkpoint/objhash.c b/checkpoint/objhash.c
> index 9750483..5626707 100644
> --- a/checkpoint/objhash.c
> +++ b/checkpoint/objhash.c
> @@ -247,6 +247,18 @@ static void obj_sock_drop(void *ptr)
>       sock_put((struct sock *) ptr);
>  }
> 
> +static void cleanup_sock(void *ptr)
> +{
> +     struct sock *sk = (struct sock *) ptr;
> +
> +     if (sk->sk_socket && !sk->sk_socket->file) {
> +             struct socket *sock = sk->sk_socket;
> +             sock_orphan(sk);
> +             sock->sk = NULL;
> +             sock_release(sock);
> +     }
> +}
> +
>  static struct ckpt_obj_ops ckpt_obj_ops[] = {
>       /* ignored object */
>       {
> @@ -384,6 +396,7 @@ static struct ckpt_obj_ops ckpt_obj_ops[] = {
>               .ref_grab = obj_sock_grab,
>               .checkpoint = checkpoint_sock,
>               .restore = restore_sock,
> +             .cleanup = cleanup_sock,
>       },
>  };
> 
> -- 
> 1.6.2.5
> 
> _______________________________________________
> Containers mailing list
> [email protected]
> https://lists.linux-foundation.org/mailman/listinfo/containers
_______________________________________________
Containers mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/containers

_______________________________________________
Devel mailing list
[email protected]
https://openvz.org/mailman/listinfo/devel

Reply via email to