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; }
int sock_conn_map_init(struct sock_ep *ep, int init_size) { struct sock_conn_map *map = &ep->attr->cmap; map->table = calloc(init_size, sizeof(*map->table)); if (!map->table) return -FI_ENOMEM; if (fi_epoll_create(&map->epoll_set) < 0) { SOCK_LOG_ERROR("failed to create epoll set\n"); free(map->table); return -FI_ENOMEM; } fastlock_init(&map->lock); map->used = 0; map->size = init_size; return 0; }