Skip to content

Commit

Permalink
vhost: remove check around pthread_mutex_init
Browse files Browse the repository at this point in the history
> pthread_mutex_init always returns 0. The other mutex functions
> return 0 on success and a non-zero error code on error.

Link: https://man7.org/linux/man-pages/man3/pthread_mutex_lock.3.html
Bugzilla ID: 1586
Cc: Maxime Coquelin <maxime.coquelin@redhat.com>
Cc: Chenbo Xia <chenbox@nvidia.com>
Signed-off-by: Ariel Otilibili <otilibil@eurecom.fr>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
  • Loading branch information
ariel-anieli authored and shemminger committed Jan 17, 2025
1 parent 6876703 commit b32b20b
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions lib/vhost/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -497,11 +497,7 @@ vhost_user_reconnect_init(void)
{
int ret;

ret = pthread_mutex_init(&reconn_list.mutex, NULL);
if (ret < 0) {
VHOST_CONFIG_LOG("thread", ERR, "%s: failed to initialize mutex", __func__);
return ret;
}
pthread_mutex_init(&reconn_list.mutex, NULL);
TAILQ_INIT(&reconn_list.head);

ret = rte_thread_create_internal_control(&reconn_tid, "vhost-reco",
Expand Down Expand Up @@ -920,11 +916,7 @@ rte_vhost_driver_register(const char *path, uint64_t flags)
goto out;
}
TAILQ_INIT(&vsocket->conn_list);
ret = pthread_mutex_init(&vsocket->conn_mutex, NULL);
if (ret) {
VHOST_CONFIG_LOG(path, ERR, "failed to init connection mutex");
goto out_free;
}
pthread_mutex_init(&vsocket->conn_mutex, NULL);

if (!strncmp("/dev/vduse/", path, strlen("/dev/vduse/")))
vsocket->is_vduse = true;
Expand Down Expand Up @@ -1033,8 +1025,6 @@ rte_vhost_driver_register(const char *path, uint64_t flags)
if (pthread_mutex_destroy(&vsocket->conn_mutex)) {
VHOST_CONFIG_LOG(path, ERR, "failed to destroy connection mutex");
}
out_free:
vhost_user_socket_mem_free(vsocket);
out:
pthread_mutex_unlock(&vhost_user.mutex);

Expand Down

0 comments on commit b32b20b

Please sign in to comment.