From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from m50-133.163.com (m50-133.163.com [123.125.50.133]) by dpdk.org (Postfix) with ESMTP id 9E2991B238 for ; Thu, 21 Dec 2017 10:15:45 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=hnlGsdpexsT9nQOXb+ ESBg+2ExGk43X7WnGISU1NnDc=; b=Nc6BNqRj8ju1QnJDkp63y6retkK2Pe6KcI nG7Z96Vv2MLw/gg+pir8iShLSPyPQgqPFsfjT7b4uXwHim4Q6slrslbYmkTdnJsX qkBJc5C8w/mvJ1AlDSLra100OSthwZG7Bp2XjbGKu1HWRcTDxznoJ3/Il0WmFjNI /0+tIOYnk= Received: from SHL0405.hxtcorp.net (unknown [116.231.15.193]) by smtp3 (Coremail) with SMTP id DdGowABnv6a6eztaxyEFAA--.451S2; Thu, 21 Dec 2017 17:15:41 +0800 (CST) From: Bing Zhao To: dev@dpdk.org Cc: bing.zhao@hxt-semitech.com, Bing Zhao Date: Thu, 21 Dec 2017 17:15:40 +0800 Message-Id: <20171221091540.8624-1-ilovethull@163.com> X-Mailer: git-send-email 2.11.0.windows.1 X-CM-TRANSID: DdGowABnv6a6eztaxyEFAA--.451S2 X-Coremail-Antispam: 1Uf129KBjvdXoWrur45ArWxtw4kCry3tFyUtrb_yoW3KFX_ua 4rAF4DGa1kJFsrAw12kFsYvFWkAr4ayF9rGan7A3yfCrs8tw45Wa4IqrZYqa45Xr45uF1q 9rs8ur1rCw4YvjkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IUjbTmPUUUUU== X-Originating-IP: [116.231.15.193] X-CM-SenderInfo: xlor4vhwkxzzi6rwjhhfrp/1tbiQx61t1c6-1pmxQAAs0 Subject: [dpdk-dev] [PATCH] reset src fd field to -1 in fdset_move of vhost X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Dec 2017 09:15:47 -0000 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. 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