X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_vhost%2Fsocket.c;h=bb8d0d78019e363a05296eb3a67ffbe00a0e2dde;hb=0fd5608ef97f9c467f1ecc926463cf793189443e;hp=ece9d5d1d81b5e5da7cfffcf362ee87377e5cd3f;hpb=74f45f872ce642156e3cec10f35575b8e61397de;p=dpdk.git diff --git a/lib/librte_vhost/socket.c b/lib/librte_vhost/socket.c index ece9d5d1d8..bb8d0d7801 100644 --- a/lib/librte_vhost/socket.c +++ b/lib/librte_vhost/socket.c @@ -127,7 +127,8 @@ read_fd_message(int sockfd, char *buf, int buflen, int *fds, int max_fds, ret = recvmsg(sockfd, &msgh, 0); if (ret <= 0) { - VHOST_LOG_CONFIG(ERR, "recvmsg failed\n"); + if (ret) + VHOST_LOG_CONFIG(ERR, "recvmsg failed\n"); return ret; } @@ -318,16 +319,16 @@ vhost_user_read_cb(int connfd, void *dat, int *remove) vhost_destroy_device(conn->vid); + if (vsocket->reconnect) { + create_unix_socket(vsocket); + vhost_user_start_client(vsocket); + } + pthread_mutex_lock(&vsocket->conn_mutex); TAILQ_REMOVE(&vsocket->conn_list, conn, next); pthread_mutex_unlock(&vsocket->conn_mutex); free(conn); - - if (vsocket->reconnect) { - create_unix_socket(vsocket); - vhost_user_start_client(vsocket); - } } } @@ -877,6 +878,7 @@ rte_vhost_driver_register(const char *path, uint64_t flags) "error: failed to init connection mutex\n"); goto out_free; } + vsocket->vdpa_dev_id = -1; vsocket->dequeue_zero_copy = flags & RTE_VHOST_USER_DEQUEUE_ZERO_COPY; vsocket->extbuf = flags & RTE_VHOST_USER_EXTBUF_SUPPORT; vsocket->linearbuf = flags & RTE_VHOST_USER_LINEARBUF_SUPPORT; @@ -924,6 +926,12 @@ rte_vhost_driver_register(const char *path, uint64_t flags) ret = -1; goto out_mutex; } + if (!vsocket->is_server) { + VHOST_LOG_CONFIG(ERR, + "error: zero copy is incompatible with vhost client mode\n"); + ret = -1; + goto out_mutex; + } vsocket->supported_features &= ~(1ULL << VIRTIO_F_IN_ORDER); vsocket->features &= ~(1ULL << VIRTIO_F_IN_ORDER); @@ -1051,9 +1059,10 @@ again: next = TAILQ_NEXT(conn, next); /* - * If r/wcb is executing, release the - * conn_mutex lock, and try again since - * the r/wcb may use the conn_mutex lock. + * If r/wcb is executing, release vsocket's + * conn_mutex and vhost_user's mutex locks, and + * try again since the r/wcb may use the + * conn_mutex and mutex locks. */ if (fdset_try_del(&vhost_user.fdset, conn->connfd) == -1) { @@ -1074,8 +1083,17 @@ again: pthread_mutex_unlock(&vsocket->conn_mutex); if (vsocket->is_server) { - fdset_del(&vhost_user.fdset, - vsocket->socket_fd); + /* + * If r/wcb is executing, release vhost_user's + * mutex lock, and try again since the r/wcb + * may use the mutex lock. + */ + if (fdset_try_del(&vhost_user.fdset, + vsocket->socket_fd) == -1) { + pthread_mutex_unlock(&vhost_user.mutex); + goto again; + } + close(vsocket->socket_fd); unlink(path); } else if (vsocket->reconnect) {