* Unregister the specified vhost socket */
| 1074 | * Unregister the specified vhost socket |
| 1075 | */ |
| 1076 | int |
| 1077 | rte_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 | |
| 1086 | again: |
| 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); |
no test coverage detected