MCPcopy Create free account
hub / github.com/F-Stack/f-stack / rte_vhost_driver_unregister

Function rte_vhost_driver_unregister

dpdk/lib/vhost/socket.c:1076–1154  ·  view source on GitHub ↗

* Unregister the specified vhost socket */

Source from the content-addressed store, hash-verified

1074 * Unregister the specified vhost socket
1075 */
1076int
1077rte_vhost_driver_unregister(const char *path)
1078{
1079 int i;
1080 int count;
1081 struct vhost_user_connection *conn, *next;
1082
1083 if (path == NULL)
1084 return -1;
1085
1086again:
1087 pthread_mutex_lock(&vhost_user.mutex);
1088
1089 for (i = 0; i < vhost_user.vsocket_cnt; i++) {
1090 struct vhost_user_socket *vsocket = vhost_user.vsockets[i];
1091 if (strcmp(vsocket->path, path))
1092 continue;
1093
1094 if (vsocket->is_vduse) {
1095 vduse_device_destroy(path);
1096 } else if (vsocket->is_server) {
1097 /*
1098 * If r/wcb is executing, release vhost_user's
1099 * mutex lock, and try again since the r/wcb
1100 * may use the mutex lock.
1101 */
1102 if (fdset_try_del(&vhost_user.fdset, vsocket->socket_fd) == -1) {
1103 pthread_mutex_unlock(&vhost_user.mutex);
1104 goto again;
1105 }
1106 } else if (vsocket->reconnect) {
1107 vhost_user_remove_reconnect(vsocket);
1108 }
1109
1110 pthread_mutex_lock(&vsocket->conn_mutex);
1111 for (conn = TAILQ_FIRST(&vsocket->conn_list);
1112 conn != NULL;
1113 conn = next) {
1114 next = TAILQ_NEXT(conn, next);
1115
1116 /*
1117 * If r/wcb is executing, release vsocket's
1118 * conn_mutex and vhost_user's mutex locks, and
1119 * try again since the r/wcb may use the
1120 * conn_mutex and mutex locks.
1121 */
1122 if (fdset_try_del(&vhost_user.fdset,
1123 conn->connfd) == -1) {
1124 pthread_mutex_unlock(&vsocket->conn_mutex);
1125 pthread_mutex_unlock(&vhost_user.mutex);
1126 goto again;
1127 }
1128
1129 VHOST_LOG_CONFIG(path, INFO, "free connfd %d\n", conn->connfd);
1130 close(conn->connfd);
1131 vhost_destroy_device(conn->vid);
1132 TAILQ_REMOVE(&vsocket->conn_list, conn, next);
1133 free(conn);

Callers 7

vhost_driver_setupFunction · 0.85
eth_dev_closeFunction · 0.85
free_resourceFunction · 0.85
unregister_driversFunction · 0.85
close_vdpaFunction · 0.85
vhost_blk_ctrlr_destroyFunction · 0.85

Calls 11

pthread_mutex_lockFunction · 0.85
strcmpFunction · 0.85
fdset_try_delFunction · 0.85
pthread_mutex_unlockFunction · 0.85
vhost_destroy_deviceFunction · 0.85
pthread_mutex_destroyFunction · 0.85
vduse_device_destroyFunction · 0.70
closeFunction · 0.50
freeFunction · 0.50

Tested by

no test coverage detected