From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yuanhan Liu Subject: Re: [PATCH] reset src fd field to -1 in fdset_move of vhost Date: Fri, 19 Jan 2018 22:37:29 +0800 Message-ID: <20180119143729.GP29540@yliu-mob> References: <20171221091540.8624-1-ilovethull@163.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: dev@dpdk.org, bing.zhao@hxt-semitech.com To: Bing Zhao Return-path: Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by dpdk.org (Postfix) with ESMTP id 73DAF1B32D for ; Fri, 19 Jan 2018 15:37:34 +0100 (CET) Content-Disposition: inline In-Reply-To: <20171221091540.8624-1-ilovethull@163.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Thu, Dec 21, 2017 at 05:15:40PM +0800, Bing Zhao wrote: > In the fdset_move, after copying the fd&rwfds from the src to the dst, the fd should be set to -1. Or else in some cases, there will be a fault missing. E.g: > Before: 1 -1 3 4 -1 6 7 -1 9 10 > After: 1 10 3 4 9 6 7 -1 9 10 > Then the index7 will be returned correctly for the first time, but if another fd is to be added, it will fail. Hi, Have you met a real issue? I'm a bit doubt about that, since the fd array is also guarded by "pfdset->num", which makes sure we will not access those invalid entries (i.e. the last 2 entries in above example). --yliu > Signed-off-by: Bing Zhao > --- > lib/librte_vhost/fd_man.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/lib/librte_vhost/fd_man.c b/lib/librte_vhost/fd_man.c > index 4c6fed418..48594dd7f 100644 > --- a/lib/librte_vhost/fd_man.c > +++ b/lib/librte_vhost/fd_man.c > @@ -63,6 +63,7 @@ fdset_move(struct fdset *pfdset, int dst, int src) > { > pfdset->fd[dst] = pfdset->fd[src]; > pfdset->rwfds[dst] = pfdset->rwfds[src]; > + pfdset->fd[src].fd = -1; > } > > static void > -- > 2.11.0.windows.1 >