From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id EE1A01F7 for ; Fri, 6 Mar 2015 11:05:18 +0100 (CET) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP; 06 Mar 2015 02:05:19 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,351,1422950400"; d="scan'208";a="676083751" Received: from irsmsx106.ger.corp.intel.com ([163.33.3.31]) by fmsmga001.fm.intel.com with ESMTP; 06 Mar 2015 02:05:17 -0800 Received: from irsmsx105.ger.corp.intel.com ([169.254.7.117]) by IRSMSX106.ger.corp.intel.com ([169.254.8.235]) with mapi id 14.03.0195.001; Fri, 6 Mar 2015 10:04:56 +0000 From: "Ananyev, Konstantin" To: "Xie, Huawei" , "dev@dpdk.org" Thread-Topic: [PATCH] lib/librte_vhost: use loop instead of goto Thread-Index: AQHQV9HJPL0FTk44p0CE7QM6UVZwF50POk5g Date: Fri, 6 Mar 2015 10:04:56 +0000 Message-ID: <2601191342CEEE43887BDE71AB977258213F448B@irsmsx105.ger.corp.intel.com> References: <1425621163-14942-1-git-send-email-huawei.xie@intel.com> In-Reply-To: <1425621163-14942-1-git-send-email-huawei.xie@intel.com> Accept-Language: en-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [163.33.239.182] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH] lib/librte_vhost: use loop instead of goto X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Mar 2015 10:05:19 -0000 > -----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 >=20 > This patch reorder the code a bit to use loop instead of goto. > Besides, remove abudant check 'fd !=3D -1'. Acked-by: Konstantin Ananyev >=20 > Signed-off-by: Huawei Xie > --- > lib/librte_vhost/vhost_user/fd_man.c | 26 +++++++++++--------------- > 1 file changed, 11 insertions(+), 15 deletions(-) >=20 > diff --git a/lib/librte_vhost/vhost_user/fd_man.c b/lib/librte_vhost/vhos= t_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 =3D=3D NULL || fd =3D=3D -1) > return; >=20 > -again: > - pthread_mutex_lock(&pfdset->fd_mutex); > + do { > + pthread_mutex_lock(&pfdset->fd_mutex); >=20 > - i =3D fdset_find_fd(pfdset, fd); > - if (i !=3D -1 && fd !=3D -1) { > - /* busy indicates r/wcb is executing! */ > - if (pfdset->fd[i].busy =3D=3D 1) { > - pthread_mutex_unlock(&pfdset->fd_mutex); > - goto again; > + i =3D fdset_find_fd(pfdset, fd); > + if (i !=3D -1 && pfdset->fd[i].busy =3D=3D 0) { > + /* busy indicates r/wcb is executing! */ > + pfdset->fd[i].fd =3D -1; > + pfdset->fd[i].rcb =3D pfdset->fd[i].wcb =3D NULL; > + pfdset->num--; > + i =3D -1; > } > - > - pfdset->fd[i].fd =3D -1; > - pfdset->fd[i].rcb =3D pfdset->fd[i].wcb =3D NULL; > - pfdset->num--; > - } > - > - pthread_mutex_unlock(&pfdset->fd_mutex); > + pthread_mutex_unlock(&pfdset->fd_mutex); > + } while (i !=3D -1); > } >=20 > /** > -- > 1.8.1.4