Exemplo n.º 1
0
Arquivo: init.c Projeto: keeely/libnfs
void rpc_destroy_context(struct rpc_context *rpc)
{
	struct rpc_pdu *pdu;
	unsigned int i;

	assert(rpc->magic == RPC_CONTEXT_MAGIC);

        /* If we are a server context, free all registered endpoints. */
        while (rpc->endpoints != NULL) {
                struct rpc_endpoint *next = rpc->endpoints->next;

                free(rpc->endpoints);
                rpc->endpoints = next;
        }

	while((pdu = rpc->outqueue.head) != NULL) {
		pdu->cb(rpc, RPC_STATUS_CANCEL, NULL, pdu->private_data);
		LIBNFS_LIST_REMOVE(&rpc->outqueue.head, pdu);
		rpc_free_pdu(rpc, pdu);
	}

	for (i = 0; i < HASHES; i++) {
		struct rpc_queue *q = &rpc->waitpdu[i];

		while((pdu = q->head) != NULL) {
			pdu->cb(rpc, RPC_STATUS_CANCEL, NULL, pdu->private_data);
			LIBNFS_LIST_REMOVE(&q->head, pdu);
			rpc_free_pdu(rpc, pdu);
		}
	}

	rpc_free_all_fragments(rpc);

        if (rpc->auth) {
                auth_destroy(rpc->auth);
                rpc->auth =NULL;
        }

	if (rpc->fd != -1) {
 		close(rpc->fd);
	}

	if (rpc->error_string != NULL) {
		free(rpc->error_string);
		rpc->error_string = NULL;
	}

	rpc->magic = 0;
	free(rpc);
}
Exemplo n.º 2
0
void rpc_destroy_context(struct rpc_context *rpc)
{
	struct rpc_pdu *pdu;
	unsigned int i;

	assert(rpc->magic == RPC_CONTEXT_MAGIC);

	while((pdu = rpc->outqueue.head) != NULL) {
		pdu->cb(rpc, RPC_STATUS_CANCEL, NULL, pdu->private_data);
		LIBNFS_LIST_REMOVE(&rpc->outqueue.head, pdu);
		rpc_free_pdu(rpc, pdu);
	}

	for (i = 0; i < HASHES; i++) {
		struct rpc_queue *q = &rpc->waitpdu[i];

		while((pdu = q->head) != NULL) {
			pdu->cb(rpc, RPC_STATUS_CANCEL, NULL, pdu->private_data);
			LIBNFS_LIST_REMOVE(&q->head, pdu);
			rpc_free_pdu(rpc, pdu);
		}
	}

	rpc_free_all_fragments(rpc);

	auth_destroy(rpc->auth);
	rpc->auth =NULL;

	if (rpc->fd != -1) {
 		close(rpc->fd);
	}

	if (rpc->encodebuf != NULL) {
		free(rpc->encodebuf);
		rpc->encodebuf = NULL;
	}

	if (rpc->error_string != NULL) {
		free(rpc->error_string);
		rpc->error_string = NULL;
	}

	if (rpc->udp_dest != NULL) {
		free(rpc->udp_dest);
		rpc->udp_dest = NULL;
	}

	rpc->magic = 0;
	free(rpc);
}