| 457 | } |
| 458 | |
| 459 | static uint32_t |
| 460 | vhost_user_client_reconnect(void *arg __rte_unused) |
| 461 | { |
| 462 | int ret; |
| 463 | struct vhost_user_reconnect *reconn, *next; |
| 464 | |
| 465 | while (1) { |
| 466 | pthread_mutex_lock(&reconn_list.mutex); |
| 467 | |
| 468 | /* |
| 469 | * An equal implementation of TAILQ_FOREACH_SAFE, |
| 470 | * which does not exist on all platforms. |
| 471 | */ |
| 472 | for (reconn = TAILQ_FIRST(&reconn_list.head); |
| 473 | reconn != NULL; reconn = next) { |
| 474 | next = TAILQ_NEXT(reconn, next); |
| 475 | |
| 476 | ret = vhost_user_connect_nonblock(reconn->vsocket->path, reconn->fd, |
| 477 | (struct sockaddr *)&reconn->un, |
| 478 | sizeof(reconn->un)); |
| 479 | if (ret == -2) { |
| 480 | close(reconn->fd); |
| 481 | VHOST_LOG_CONFIG(reconn->vsocket->path, ERR, |
| 482 | "reconnection for fd %d failed\n", |
| 483 | reconn->fd); |
| 484 | goto remove_fd; |
| 485 | } |
| 486 | if (ret == -1) |
| 487 | continue; |
| 488 | |
| 489 | VHOST_LOG_CONFIG(reconn->vsocket->path, INFO, "connected\n"); |
| 490 | vhost_user_add_connection(reconn->fd, reconn->vsocket); |
| 491 | remove_fd: |
| 492 | TAILQ_REMOVE(&reconn_list.head, reconn, next); |
| 493 | free(reconn); |
| 494 | } |
| 495 | |
| 496 | pthread_mutex_unlock(&reconn_list.mutex); |
| 497 | sleep(1); |
| 498 | } |
| 499 | |
| 500 | return 0; |
| 501 | } |
| 502 | |
| 503 | static int |
| 504 | vhost_user_reconnect_init(void) |
nothing calls this directly
no test coverage detected