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

Function vhost_user_client_reconnect

dpdk/lib/vhost/socket.c:459–501  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

457}
458
459static uint32_t
460vhost_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);
491remove_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
503static int
504vhost_user_reconnect_init(void)

Callers

nothing calls this directly

Calls 6

pthread_mutex_lockFunction · 0.85
pthread_mutex_unlockFunction · 0.85
closeFunction · 0.50
freeFunction · 0.50

Tested by

no test coverage detected