[dpdk-dev] [PATCH] reset src fd field to -1 in fdset_move of vhost

Bing Zhao ilovethull at 163.com
Thu Dec 21 10:15:40 CET 2017


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 <bing.zhao at hxt-semitech.com>
---
 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




More information about the dev mailing list