From: Yuanhan Liu <yliu@fridaylinux.org>
To: Jens Freimann <jfreimann@redhat.com>
Cc: Zhiyong Yang <zhiyong.yang@intel.com>,
dev@dpdk.org, maxime.coquelin@redhat.com, lei.a.yao@intel.com
Subject: Re: [dpdk-dev] [PATCH] vhost: fix vhost-user init failed
Date: Fri, 14 Jul 2017 10:43:52 +0800 [thread overview]
Message-ID: <20170714024351.GG11626@yliu-home> (raw)
In-Reply-To: <20170710094827.zdykowebtm3m3w2k@dhcp-192-218.str.redhat.com>
On Mon, Jul 10, 2017 at 11:48:27AM +0200, Jens Freimann wrote:
> >@@ -668,7 +668,7 @@ rte_vhost_driver_register(const char *path, uint64_t flags)
> > }
> >
> > vhost_user.vsockets[vhost_user.vsocket_cnt++] = vsocket;
> >-
> >+ goto out;
> >out_mutex:
> > if (pthread_mutex_destroy(&vsocket->conn_mutex)) {
> > RTE_LOG(ERR, VHOST_CONFIG,
>
> Thanks for fixing this!
>
> Sorry for introducing this bug, I was about to send this before I saw
> your fix:
>
> diff --git a/lib/librte_vhost/socket.c b/lib/librte_vhost/socket.c
> index 57b86c0..b2158a7 100644
> --- a/lib/librte_vhost/socket.c
> +++ b/lib/librte_vhost/socket.c
> @@ -668,6 +668,9 @@ rte_vhost_driver_register(const char *path, uint64_t flags)
> }
>
> vhost_user.vsockets[vhost_user.vsocket_cnt++] = vsocket;
> +out:
> + pthread_mutex_unlock(&vhost_user.mutex);
> + return ret;
>
> out_mutex:
> if (pthread_mutex_destroy(&vsocket->conn_mutex)) {
> @@ -677,9 +680,7 @@ rte_vhost_driver_register(const char *path, uint64_t flags)
> out_free:
> free(vsocket->path);
> free(vsocket);
> -out:
> pthread_mutex_unlock(&vhost_user.mutex);
> -
> return ret;
> }
>
> Both works fine, so I leave it up to the maintainers how to fix.
>
> Reviewed-by: Jens Freimann <jfreimann@redhat.com>
I actually prefers below: I don't want a simple "out" on top of "out_mutex"
and "out_free", and an unconditional "goto" looks weird to me.
---
@@ -669,6 +669,9 @@ rte_vhost_driver_register(const char *path, uint64_t flags)
vhost_user.vsockets[vhost_user.vsocket_cnt++] = vsocket;
+ pthread_mutex_unlock(&vhost_user.mutex);
+ return ret;
+
out_mutex:
if (pthread_mutex_destroy(&vsocket->conn_mutex)) {
RTE_LOG(ERR, VHOST_CONFIG,
Applied to dpdk-next-virtio, with above changes.
Thanks!
--yliu
next prev parent reply other threads:[~2017-07-14 2:44 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-10 8:06 Zhiyong Yang
2017-07-10 9:38 ` Maxime Coquelin
2017-07-10 9:48 ` Jens Freimann
2017-07-12 2:41 ` Liu, Yu Y
2017-07-14 2:43 ` Yuanhan Liu [this message]
2017-07-13 8:18 ` Yao, Lei A
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=20170714024351.GG11626@yliu-home \
--to=yliu@fridaylinux.org \
--cc=dev@dpdk.org \
--cc=jfreimann@redhat.com \
--cc=lei.a.yao@intel.com \
--cc=maxime.coquelin@redhat.com \
--cc=zhiyong.yang@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).