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

Function vhost_user_start_client

dpdk/lib/vhost/socket.c:528–565  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

526}
527
528static int
529vhost_user_start_client(struct vhost_user_socket *vsocket)
530{
531 int ret;
532 int fd = vsocket->socket_fd;
533 const char *path = vsocket->path;
534 struct vhost_user_reconnect *reconn;
535
536 ret = vhost_user_connect_nonblock(vsocket->path, fd, (struct sockaddr *)&vsocket->un,
537 sizeof(vsocket->un));
538 if (ret == 0) {
539 vhost_user_add_connection(fd, vsocket);
540 return 0;
541 }
542
543 VHOST_LOG_CONFIG(path, WARNING, "failed to connect: %s\n", strerror(errno));
544
545 if (ret == -2 || !vsocket->reconnect) {
546 close(fd);
547 return -1;
548 }
549
550 VHOST_LOG_CONFIG(path, INFO, "reconnecting...\n");
551 reconn = malloc(sizeof(*reconn));
552 if (reconn == NULL) {
553 VHOST_LOG_CONFIG(path, ERR, "failed to allocate memory for reconnect\n");
554 close(fd);
555 return -1;
556 }
557 reconn->un = vsocket->un;
558 reconn->fd = fd;
559 reconn->vsocket = vsocket;
560 pthread_mutex_lock(&reconn_list.mutex);
561 TAILQ_INSERT_TAIL(&reconn_list.head, reconn, next);
562 pthread_mutex_unlock(&reconn_list.mutex);
563
564 return 0;
565}
566
567static struct vhost_user_socket *
568find_vhost_user_socket(const char *path)

Callers 2

vhost_user_read_cbFunction · 0.85
rte_vhost_driver_startFunction · 0.85

Calls 6

mallocFunction · 0.85
pthread_mutex_lockFunction · 0.85
pthread_mutex_unlockFunction · 0.85
closeFunction · 0.50

Tested by

no test coverage detected