Exemplo n.º 1
0
void xio_context_destroy(struct xio_context *ctx)
{
	int found;

	found = xio_idr_lookup_uobj(usr_idr, ctx);
	if (found) {
		xio_idr_remove_uobj(usr_idr, ctx);
	} else {
		ERROR_LOG("context not found:%p\n", ctx);
		xio_set_error(XIO_E_USER_OBJ_NOT_FOUND);
		return;
	}

	ctx->run_private = 0;
	xio_observable_notify_all_observers(&ctx->observable,
					    XIO_CONTEXT_EVENT_CLOSE, NULL);
	/* allow internally to run the loop for final cleanup */
	if (ctx->run_private)
		xio_context_run_loop(ctx);
	if (ctx->run_private == 0)
		xio_destroy_context_continue(&ctx->destroy_ctx_work.work);
}
Exemplo n.º 2
0
/*---------------------------------------------------------------------------*/
int xio_unbind(struct xio_server *server)
{
	int retval = 0;
	int found;

	if (!server)
		return -1;

	found = xio_idr_lookup_uobj(usr_idr, server);
	if (found) {
		xio_idr_remove_uobj(usr_idr, server);
	} else {
		ERROR_LOG("server not found:%p\n", server);
		xio_set_error(XIO_E_USER_OBJ_NOT_FOUND);
		return -1;
	}
	/* notify all observers that the server wishes to exit */
	xio_observable_notify_all_observers(&server->nexus_observable,
					    XIO_SERVER_EVENT_CLOSE, NULL);

	kref_put(&server->kref, xio_server_destroy);

	return retval;
}