int tcpx_conn_mgr_init(struct tcpx_fabric *tcpx_fabric) { int ret; dlist_init(&tcpx_fabric->poll_mgr.list); fastlock_init(&tcpx_fabric->poll_mgr.lock); ret = fd_signal_init(&tcpx_fabric->poll_mgr.signal); if (ret) { FI_WARN(&tcpx_prov, FI_LOG_FABRIC,"signal init failed\n"); goto err; } tcpx_fabric->poll_mgr.run = 1; ret = pthread_create(&tcpx_fabric->conn_mgr_thread, 0, tcpx_conn_mgr_thread, (void *) tcpx_fabric); if (ret) { FI_WARN(&tcpx_prov, FI_LOG_FABRIC, "Failed creating tcpx connection manager thread"); goto err1; } return 0; err1: fd_signal_free(&tcpx_fabric->poll_mgr.signal); err: fastlock_destroy(&tcpx_fabric->poll_mgr.lock); return ret; }
int ofi_wait_fd_open(struct fid_fabric *fabric_fid, struct fi_wait_attr *attr, struct fid_wait **waitset) { struct util_fabric *fabric; struct util_wait_fd *wait; int ret; fabric = container_of(fabric_fid, struct util_fabric, fabric_fid); ret = util_verify_wait_fd_attr(fabric->prov, attr); if (ret) return ret; wait = calloc(1, sizeof(*wait)); if (!wait) return -FI_ENOMEM; ret = fi_wait_init(fabric, attr, &wait->util_wait); if (ret) goto err1; wait->util_wait.signal = util_wait_fd_signal; wait->util_wait.wait_try = util_wait_fd_try; ret = fd_signal_init(&wait->signal); if (ret) goto err2; ret = fi_epoll_create(&wait->epoll_fd); if (ret) goto err3; ret = fi_epoll_add(wait->epoll_fd, wait->signal.fd[FI_READ_FD], FI_EPOLL_IN, &wait->util_wait.wait_fid.fid); if (ret) goto err4; wait->util_wait.wait_fid.fid.ops = &util_wait_fd_fi_ops; wait->util_wait.wait_fid.ops = &util_wait_fd_ops; dlist_init(&wait->fd_list); fastlock_init(&wait->lock); *waitset = &wait->util_wait.wait_fid; return 0; err4: fi_epoll_close(wait->epoll_fd); err3: fd_signal_free(&wait->signal); err2: fi_wait_cleanup(&wait->util_wait); err1: free(wait); return ret; }