vhost: do not close a closed connfd
kill a spdk process with aio bdev storage many times will get error messages: bdev_aio.c: 244:bdev_aio_group_poll: *ERROR*: epoll_wait error(9): Bad file descriptor on ch=0x152a7f0 vhost.c:1010:_spdk_vhost_event_send: *ERROR*: Timeout waiting for event: stop device. When spdk process exits, the connfd is closed by rte_vhost_driver_unregister, then other function such as epoll_create1 in aio bdev may allocate the same fd, but this fd is closed by vhost_user_read_cb again, so epoll_wait return -1 Signed-off-by: Honghui Wang <wanghonghui@ucloud.cn> Change-Id: Ic3fd938892f004c18fb38d4594c006c40a01efaa Reviewed-on: https://review.gerrithub.io/c/439851 Reviewed-by: GangCao <gang.cao@intel.com> Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com> Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com> Tested-by: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
parent
0e46c8f638
commit
3eb66ba88e
@ -292,7 +292,6 @@ vhost_user_read_cb(int connfd, void *dat, int *remove)
|
||||
|
||||
ret = vhost_user_msg_handler(conn->vid, connfd);
|
||||
if (ret < 0) {
|
||||
close(connfd);
|
||||
*remove = 1;
|
||||
vhost_destroy_device(conn->vid);
|
||||
|
||||
@ -301,6 +300,10 @@ vhost_user_read_cb(int connfd, void *dat, int *remove)
|
||||
|
||||
pthread_mutex_lock(&vsocket->conn_mutex);
|
||||
TAILQ_REMOVE(&vsocket->conn_list, conn, next);
|
||||
if (conn->connfd != -1) {
|
||||
close(conn->connfd);
|
||||
conn->connfd = -1;
|
||||
}
|
||||
pthread_mutex_unlock(&vsocket->conn_mutex);
|
||||
|
||||
free(conn);
|
||||
@ -736,6 +739,7 @@ rte_vhost_driver_unregister(const char *path)
|
||||
pthread_mutex_lock(&vsocket->conn_mutex);
|
||||
TAILQ_FOREACH(conn, &vsocket->conn_list, next) {
|
||||
close(conn->connfd);
|
||||
conn->connfd = -1;
|
||||
}
|
||||
pthread_mutex_unlock(&vsocket->conn_mutex);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user