All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Liu Bo <bo.liu@linux.alibaba.com>
Cc: virtio-fs@redhat.com
Subject: Re: [Virtio-fs] [PATCH 5/5] virtiofsd: add helper for lo_data cleanup
Date: Thu, 6 Jun 2019 10:41:06 +0100	[thread overview]
Message-ID: <20190606094105.GH2788@work-vm> (raw)
In-Reply-To: <1559695356-75503-6-git-send-email-bo.liu@linux.alibaba.com>

* Liu Bo (bo.liu@linux.alibaba.com) wrote:
> This offers an helper function for lo_data's cleanup.
> 
> Signed-off-by: Liu Bo <bo.liu@linux.alibaba.com>

That's ok, but will need updating when you do a new version of the
lo.source.

Dave

> ---
>  contrib/virtiofsd/passthrough_ll.c | 34 +++++++++++++++++++---------------
>  1 file changed, 19 insertions(+), 15 deletions(-)
> 
> diff --git a/contrib/virtiofsd/passthrough_ll.c b/contrib/virtiofsd/passthrough_ll.c
> index 649991e..73ca09f 100644
> --- a/contrib/virtiofsd/passthrough_ll.c
> +++ b/contrib/virtiofsd/passthrough_ll.c
> @@ -2205,6 +2205,24 @@ static gboolean lo_key_equal(gconstpointer a, gconstpointer b)
>                 la->dev == lb->dev;
>  }
>  
> +static void fuse_lo_data_cleanup(struct lo_data *lo, bool free_source)
> +{
> +        if (lo->inodes)
> +                g_hash_table_destroy(lo->inodes);
> +	lo_map_destroy(&lo->fd_map);
> +	lo_map_destroy(&lo->dirp_map);
> +	lo_map_destroy(&lo->ino_map);
> +
> +	if (lo->proc_self_fd >= 0) {
> +		close(lo->proc_self_fd);
> +	}
> +
> +	if (lo->root.fd >= 0)
> +		close(lo->root.fd);
> +
> +        if (free_source)
> +                free((char *)lo->source);
> +}
>  
>  int main(int argc, char *argv[])
>  {
> @@ -2325,21 +2343,7 @@ err_out2:
>  err_out1:
>  	fuse_opt_free_args(&args);
>  
> -        if (lo.inodes)
> -                g_hash_table_destroy(lo.inodes);
> -	lo_map_destroy(&lo.fd_map);
> -	lo_map_destroy(&lo.dirp_map);
> -	lo_map_destroy(&lo.ino_map);
> -
> -	if (lo.proc_self_fd >= 0) {
> -		close(lo.proc_self_fd);
> -	}
> -
> -	if (lo.root.fd >= 0)
> -		close(lo.root.fd);
> -
> -        if (free_source)
> -                free((char *)lo.source);
> +        fuse_lo_data_cleanup(&lo, free_source);
>  
>  	return ret ? 1 : 0;
>  }
> -- 
> 1.8.3.1
> 
> _______________________________________________
> Virtio-fs mailing list
> Virtio-fs@redhat.com
> https://www.redhat.com/mailman/listinfo/virtio-fs
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK


      reply	other threads:[~2019-06-06  9:41 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-05  0:42 [Virtio-fs] [PATCH 0/5] leak fixes Liu Bo
2019-06-05  0:42 ` [Virtio-fs] [PATCH 1/5] virtiofsd: cleanup allocated resource in se Liu Bo
2019-06-06  9:04   ` Dr. David Alan Gilbert
2019-06-06 16:56     ` Liu Bo
2019-06-05  0:42 ` [Virtio-fs] [PATCH 2/5] virtiofsd: fix memory leak on lo.source Liu Bo
2019-06-06  9:11   ` Dr. David Alan Gilbert
2019-06-05  0:42 ` [Virtio-fs] [PATCH 3/5] virtiofsd: fix memory leak on lo.inodes hashmap Liu Bo
2019-06-06  9:30   ` Dr. David Alan Gilbert
2019-06-05  0:42 ` [Virtio-fs] [PATCH 4/5] virtiofsd: fix error handling in main() Liu Bo
2019-06-06  9:33   ` Dr. David Alan Gilbert
2019-06-05  0:42 ` [Virtio-fs] [PATCH 5/5] virtiofsd: add helper for lo_data cleanup Liu Bo
2019-06-06  9:41   ` Dr. David Alan Gilbert [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190606094105.GH2788@work-vm \
    --to=dgilbert@redhat.com \
    --cc=bo.liu@linux.alibaba.com \
    --cc=virtio-fs@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.