From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 763231F7 for ; Fri, 6 Mar 2015 11:04:42 +0100 (CET) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 06 Mar 2015 02:04:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,351,1422950400"; d="scan'208";a="687893795" Received: from irsmsx151.ger.corp.intel.com ([163.33.192.59]) by fmsmga002.fm.intel.com with ESMTP; 06 Mar 2015 02:04:41 -0800 Received: from irsmsx105.ger.corp.intel.com ([169.254.7.117]) by IRSMSX151.ger.corp.intel.com ([169.254.4.7]) with mapi id 14.03.0195.001; Fri, 6 Mar 2015 10:04:40 +0000 From: "Ananyev, Konstantin" To: "Xie, Huawei" , "dev@dpdk.org" Thread-Topic: [PATCH] lib/librte_vhost: combine select with sleep Thread-Index: AQHQV9HABZeCgLgB1UqFVlBdMKUwrZ0POd0A Date: Fri, 6 Mar 2015 10:04:40 +0000 Message-ID: <2601191342CEEE43887BDE71AB977258213F4481@irsmsx105.ger.corp.intel.com> References: <1425621147-14904-1-git-send-email-huawei.xie@intel.com> In-Reply-To: <1425621147-14904-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: combine select with sleep 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:04:42 -0000 > -----Original Message----- > From: Xie, Huawei > Sent: Friday, March 06, 2015 5:52 AM > To: dev@dpdk.org > Cc: Ananyev, Konstantin; Xie, Huawei > Subject: [PATCH] lib/librte_vhost: combine select with sleep >=20 > combine sleep into select when there is no file descriptors to be monitor= ed. >=20 > Signed-off-by: Huawei Xie Acked-by: Konstantin Ananyev > --- > lib/librte_vhost/vhost_user/fd_man.c | 13 +++++++------ > 1 file changed, 7 insertions(+), 6 deletions(-) >=20 > diff --git a/lib/librte_vhost/vhost_user/fd_man.c b/lib/librte_vhost/vhos= t_user/fd_man.c > index 63ac4df..a89b6fe 100644 > --- a/lib/librte_vhost/vhost_user/fd_man.c > +++ b/lib/librte_vhost/vhost_user/fd_man.c > @@ -211,25 +211,26 @@ fdset_event_dispatch(struct fdset *pfdset) > void *dat; > int fd; > int remove1, remove2; > + int ret; >=20 > if (pfdset =3D=3D NULL) > return; >=20 > while (1) { > + struct timeval tv; > + tv.tv_sec =3D 1; > + tv.tv_usec =3D 0; > FD_ZERO(&rfds); > FD_ZERO(&wfds); > pthread_mutex_lock(&pfdset->fd_mutex); >=20 > maxfds =3D fdset_fill(&rfds, &wfds, pfdset); > - if (maxfds =3D=3D -1) { > - pthread_mutex_unlock(&pfdset->fd_mutex); > - sleep(1); > - continue; > - } >=20 > pthread_mutex_unlock(&pfdset->fd_mutex); >=20 > - select(maxfds + 1, &rfds, &wfds, NULL, NULL); > + ret =3D select(maxfds + 1, &rfds, &wfds, NULL, &tv); > + if (ret <=3D 0) > + continue; >=20 > for (i =3D 0; i < num; i++) { > remove1 =3D remove2 =3D 0; > -- > 1.8.1.4