vhost: fix dead lock on closing in server mode
authorTonghao Zhang <xiangxia.m.yue@gmail.com>
Fri, 27 Apr 2018 15:19:43 +0000 (08:19 -0700)
committerFerruh Yigit <ferruh.yigit@intel.com>
Mon, 14 May 2018 21:29:59 +0000 (22:29 +0100)
commit8b4b949144b80cc7312bbc189d38a3feaf2c74e5
treee28e6fec1c4d0586b8a78e974729f991825d6e77
parenta24e7032f74ecc9ba5a86232efaa972b71425de7
vhost: fix dead lock on closing in server mode

When qemu close the unix socket fd of the vhostuser as a
server, and then immediately delete the vhostuser port on
openvswitch. There will be a deadlock.

A thread (fdset event thread):       B thread:
1. fdset_event_dispatch              rte_vhost_driver_unregister
2. set the fd busy to 1.             lock vsocket->conn_mutex
3. vhost_user_read_cb                fdset_del waits busy changed to 0.
4. vhost peer closed, remove the
   conn from vsocket->conn_list:
   lock vsocket->conn_mutex

5. set the fd busy to 0

Fixes: 65388b43f592 ("vhost: fix fd leaks for vhost-user server mode")
Cc: stable@dpdk.org
Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
Acked-by: Maxime Coquelin <maxime.coquelin@redhat.com>
lib/librte_vhost/fd_man.c
lib/librte_vhost/fd_man.h
lib/librte_vhost/socket.c