static void __ep_destruct()

in prov/gni/src/gnix_ep.c [1618:1780]


static void __ep_destruct(void *obj)
{
	int ret;
	struct gnix_fid_domain *domain;
	struct gnix_fid_av *av;
	gnix_ht_key_t *key_ptr;
	struct gnix_fid_ep *ep = (struct gnix_fid_ep *) obj;

	GNIX_TRACE(FI_LOG_EP_CTRL, "\n");

	if (ep->type == FI_EP_MSG) {
		if (GNIX_EP_CONNECTED(ep)) {
			assert(ep->vc);
			ret = _gnix_vc_destroy(ep->vc);
			if (ret != FI_SUCCESS) {
				GNIX_WARN(FI_LOG_EP_CTRL,
					  "_gnix_vc_destroy returned %s\n",
					  fi_strerror(-ret));
			}
		}
	} else if (ep->av) {
		/* Remove EP from CM NIC lookup list. */
		key_ptr = (gnix_ht_key_t *)&ep->src_addr.gnix_addr;
		ret =  _gnix_ht_remove(ep->cm_nic->addr_to_ep_ht,
				       *key_ptr);
		if (ret != FI_SUCCESS) {
			GNIX_WARN(FI_LOG_EP_CTRL,
				  "_gnix_ht_remove returned %s\n",
				  fi_strerror(-ret));
		}

		/* Destroy EP VC storage. */
		ret = __gnix_ep_fini_vc(ep);
		if (ret != FI_SUCCESS) {
			GNIX_WARN(FI_LOG_EP_CTRL,
				  "_gnix_ht_remove returned %s\n",
				  fi_strerror(-ret));
		}
	}

	if (ep->eq) {
		_gnix_eq_poll_obj_rem(ep->eq, &ep->ep_fid.fid);
		_gnix_ref_put(ep->eq);
	}

	if (ep->send_cq) {
		_gnix_cq_poll_obj_rem(ep->send_cq, ep->nic,
				      _gnix_nic_progress);
		if (ep->cm_nic) /* No CM NIC for MSG EPs */
			_gnix_cq_poll_obj_rem(ep->send_cq, ep->cm_nic,
					      _gnix_cm_nic_progress);
		_gnix_ref_put(ep->send_cq);
	}

	if (ep->recv_cq) {
		_gnix_cq_poll_obj_rem(ep->recv_cq, ep->nic,
				       _gnix_nic_progress);
		if (ep->cm_nic) /* No CM NIC for MSG EPs */
			_gnix_cq_poll_obj_rem(ep->recv_cq, ep->cm_nic,
					      _gnix_cm_nic_progress);
		_gnix_ref_put(ep->recv_cq);
	}

	if (ep->send_cntr) {
		_gnix_cntr_poll_obj_rem(ep->send_cntr, ep->nic,
					_gnix_nic_progress);
		if (ep->cm_nic) /* No CM NIC for MSG EPs */
			_gnix_cntr_poll_obj_rem(ep->send_cntr, ep->cm_nic,
						_gnix_cm_nic_progress);
		_gnix_ref_put(ep->send_cntr);
	}

	if (ep->recv_cntr) {
		_gnix_cntr_poll_obj_rem(ep->recv_cntr, ep->nic,
					_gnix_nic_progress);
		if (ep->cm_nic) /* No CM NIC for MSG EPs */
			_gnix_cntr_poll_obj_rem(ep->recv_cntr, ep->cm_nic,
						_gnix_cm_nic_progress);
		_gnix_ref_put(ep->recv_cntr);
	}

	if (ep->write_cntr) {
		_gnix_cntr_poll_obj_rem(ep->write_cntr, ep->nic,
					_gnix_nic_progress);
		if (ep->cm_nic) /* No CM NIC for MSG EPs */
			_gnix_cntr_poll_obj_rem(ep->write_cntr, ep->cm_nic,
						_gnix_cm_nic_progress);
		_gnix_ref_put(ep->write_cntr);
	}

	if (ep->read_cntr) {
		_gnix_cntr_poll_obj_rem(ep->read_cntr, ep->nic,
					_gnix_nic_progress);
		if (ep->cm_nic) /* No CM NIC for MSG EPs */
			_gnix_cntr_poll_obj_rem(ep->read_cntr, ep->cm_nic,
						_gnix_cm_nic_progress);
		_gnix_ref_put(ep->read_cntr);
	}

	if (ep->rwrite_cntr) {
		_gnix_cntr_poll_obj_rem(ep->rwrite_cntr, ep->nic,
					_gnix_nic_progress);
		if (ep->cm_nic) /* No CM NIC for MSG EPs */
			_gnix_cntr_poll_obj_rem(ep->rwrite_cntr, ep->cm_nic,
						_gnix_cm_nic_progress);
		_gnix_ref_put(ep->rwrite_cntr);
	}

	if (ep->rread_cntr) {
		_gnix_cntr_poll_obj_rem(ep->rread_cntr, ep->nic,
					_gnix_nic_progress);
		if (ep->cm_nic) /* No CM NIC for MSG EPs */
			_gnix_cntr_poll_obj_rem(ep->rread_cntr, ep->cm_nic,
						_gnix_cm_nic_progress);
		_gnix_ref_put(ep->rread_cntr);
	}

	if (ep->stx_ctx)
		_gnix_ref_put(ep->stx_ctx);

	if (ep->xpmem_hndl) {
		ret = _gnix_xpmem_handle_destroy(ep->xpmem_hndl);
		if (ret != FI_SUCCESS)
			GNIX_WARN(FI_LOG_EP_CTRL,
				  "_gnix_xpmem_handle_destroy returned %s\n",
				  fi_strerror(-ret));
	}

	domain = ep->domain;
	assert(domain != NULL);
	_gnix_ref_put(domain);

	av = ep->av;
	if (av != NULL)
		_gnix_ref_put(av);

	if (ep->nic) {
		ret = _gnix_nic_free(ep->nic);
		if (ret != FI_SUCCESS)
			GNIX_FATAL(FI_LOG_EP_CTRL,
				   "_gnix_nic_free failed: %d\n");
	}

	if (ep->cm_nic) {
		ret = _gnix_cm_nic_free(ep->cm_nic);
		if (ret != FI_SUCCESS)
			GNIX_FATAL(FI_LOG_EP_CTRL,
				   "_gnix_cm_nic_free failed: %d\n");
	}

	__destruct_tag_storages(ep);

	/*
	 * Free fab_reqs
	 */

	__fr_freelist_destroy(ep);
	_gnix_ep_int_tx_pool_fini(ep);

	fi_freeinfo(ep->info);

	free(ep);
}