static void client_recv_connresp(struct util_wait *wait, struct tcpx_cm_context *cm_ctx) { struct fi_eq_err_entry err_entry = { 0 }; struct tcpx_ep *ep; ssize_t ret; assert(cm_ctx->fid->fclass == FI_CLASS_EP); ep = container_of(cm_ctx->fid, struct tcpx_ep, util_ep.ep_fid.fid); ret = ofi_wait_fd_del(wait, ep->conn_fd); if (ret) { FI_WARN(&tcpx_prov, FI_LOG_EP_CTRL, "Could not remove fd from wait\n"); goto err; } ret = proc_conn_resp(cm_ctx, ep); if (ret) goto err; FI_DBG(&tcpx_prov, FI_LOG_EP_CTRL, "Received Accept from server\n"); free(cm_ctx); return; err: err_entry.fid = cm_ctx->fid; err_entry.context = cm_ctx->fid->context; err_entry.err = -ret; if (cm_ctx->cm_data_sz) { err_entry.err_data = calloc(1, cm_ctx->cm_data_sz); if (OFI_LIKELY(err_entry.err_data != NULL)) { memcpy(err_entry.err_data, cm_ctx->cm_data, cm_ctx->cm_data_sz); err_entry.err_data_size = cm_ctx->cm_data_sz; } } FI_DBG(&tcpx_prov, FI_LOG_EP_CTRL, "fi_eq_write the conn refused %"PRId64"\n", ret); free(cm_ctx); /* `err_entry.err_data` must live until it is passed to user */ ret = fi_eq_write(&ep->util_ep.eq->eq_fid, FI_NOTIFY, &err_entry, sizeof(err_entry), UTIL_FLAG_ERROR); if (OFI_UNLIKELY(ret < 0)) { free(err_entry.err_data); } }
static void handle_connect(struct poll_fd_mgr *poll_mgr, int index) { struct tcpx_ep *ep; struct poll_fd_info *poll_info = &poll_mgr->poll_info[index]; struct fi_eq_err_entry err_entry; int ret; assert(poll_info->fid->fclass == FI_CLASS_EP); ep = container_of(poll_info->fid, struct tcpx_ep, util_ep.ep_fid.fid); switch (poll_info->state) { case ESTABLISH_CONN: ret = send_conn_req(poll_mgr, poll_info, ep, index); if (ret) goto err; poll_info->state = RCV_RESP; poll_mgr->poll_fds[index].events = POLLIN; break; case RCV_RESP: ret = proc_conn_resp(poll_mgr, poll_info, ep, index); if (ret) goto err; poll_info->state = CONNECT_DONE; break; default: FI_WARN(&tcpx_prov, FI_LOG_EP_CTRL, "Invalid connection state\n"); ret = -FI_EINVAL; goto err; } return; err: memset(&err_entry, 0, sizeof err_entry); err_entry.fid = poll_info->fid; err_entry.context = poll_info->fid->context; err_entry.err = ret; poll_info->state = CONNECT_DONE; fi_eq_write(&ep->util_ep.eq->eq_fid, FI_SHUTDOWN, &err_entry, sizeof(err_entry), UTIL_FLAG_ERROR); }