DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Ananyev, Konstantin" <konstantin.ananyev@intel.com>
To: "Xie, Huawei" <huawei.xie@intel.com>, "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH] lib/librte_vhost: use loop instead of goto
Date: Fri, 6 Mar 2015 10:04:56 +0000	[thread overview]
Message-ID: <2601191342CEEE43887BDE71AB977258213F448B@irsmsx105.ger.corp.intel.com> (raw)
In-Reply-To: <1425621163-14942-1-git-send-email-huawei.xie@intel.com>



> -----Original Message-----
> From: Xie, Huawei
> Sent: Friday, March 06, 2015 5:53 AM
> To: dev@dpdk.org
> Cc: Ananyev, Konstantin; Xie, Huawei
> Subject: [PATCH] lib/librte_vhost: use loop instead of goto
> 
> This patch reorder the code a bit to use loop instead of goto.
> Besides, remove abudant check 'fd != -1'.

Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>

> 
> Signed-off-by: Huawei Xie <huawei.xie@intel.com>
> ---
>  lib/librte_vhost/vhost_user/fd_man.c | 26 +++++++++++---------------
>  1 file changed, 11 insertions(+), 15 deletions(-)
> 
> diff --git a/lib/librte_vhost/vhost_user/fd_man.c b/lib/librte_vhost/vhost_user/fd_man.c
> index a89b6fe..831c9c1 100644
> --- a/lib/librte_vhost/vhost_user/fd_man.c
> +++ b/lib/librte_vhost/vhost_user/fd_man.c
> @@ -172,23 +172,19 @@ fdset_del(struct fdset *pfdset, int fd)
>  	if (pfdset == NULL || fd == -1)
>  		return;
> 
> -again:
> -	pthread_mutex_lock(&pfdset->fd_mutex);
> +	do {
> +		pthread_mutex_lock(&pfdset->fd_mutex);
> 
> -	i = fdset_find_fd(pfdset, fd);
> -	if (i != -1 && fd != -1) {
> -		/* busy indicates r/wcb is executing! */
> -		if (pfdset->fd[i].busy == 1) {
> -			pthread_mutex_unlock(&pfdset->fd_mutex);
> -			goto again;
> +		i = fdset_find_fd(pfdset, fd);
> +		if (i != -1 && pfdset->fd[i].busy == 0) {
> +			/* busy indicates r/wcb is executing! */
> +			pfdset->fd[i].fd = -1;
> +			pfdset->fd[i].rcb = pfdset->fd[i].wcb = NULL;
> +			pfdset->num--;
> +			i = -1;
>  		}
> -
> -		pfdset->fd[i].fd = -1;
> -		pfdset->fd[i].rcb = pfdset->fd[i].wcb = NULL;
> -		pfdset->num--;
> -	}
> -
> -	pthread_mutex_unlock(&pfdset->fd_mutex);
> +		pthread_mutex_unlock(&pfdset->fd_mutex);
> +	} while (i != -1);
>  }
> 
>  /**
> --
> 1.8.1.4

  reply	other threads:[~2015-03-06 10:05 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-06  5:52 Huawei Xie
2015-03-06 10:04 ` Ananyev, Konstantin [this message]
2015-03-09  8:28   ` Thomas Monjalon

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=2601191342CEEE43887BDE71AB977258213F448B@irsmsx105.ger.corp.intel.com \
    --to=konstantin.ananyev@intel.com \
    --cc=dev@dpdk.org \
    --cc=huawei.xie@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).