/* * Dispose of the transaction streams. If the heap has not been * preserved, we can destroy it here. */ static void ndr_xa_destruct(ndr_client_t *clnt, ndr_xa_t *mxa) { nds_destruct(&mxa->recv_nds); nds_destruct(&mxa->send_nds); if (!clnt->heap_preserved) { ndr_heap_destroy(mxa->heap); mxa->heap = NULL; clnt->heap = NULL; } }
/* * Process one server-side RPC request. */ static int ndr_pipe_process(ndr_pipe_t *np, ndr_xa_t *mxa) { ndr_stream_t *recv_nds; ndr_stream_t *send_nds; int rc = ENOMEM; mxa->pipe = np; mxa->binding_list = np->np_binding; if ((mxa->heap = ndr_heap_create()) == NULL) goto out1; recv_nds = &mxa->recv_nds; rc = nds_initialize(recv_nds, 0, NDR_MODE_CALL_RECV, mxa->heap); if (rc != 0) goto out2; send_nds = &mxa->send_nds; rc = nds_initialize(send_nds, 0, NDR_MODE_RETURN_SEND, mxa->heap); if (rc != 0) goto out3; rc = ndr_recv_request(mxa); if (rc != 0) goto out4; (void) ndr_svc_process(mxa); (void) ndr_send_reply(mxa); rc = 0; out4: nds_destruct(&mxa->send_nds); out3: nds_destruct(&mxa->recv_nds); out2: ndr_heap_destroy(mxa->heap); out1: return (rc); }
/* * The following functions provide the client callback interface. * If the caller hasn't provided a heap, create one here. */ static int ndr_xa_init(ndr_client_t *clnt, ndr_xa_t *mxa) { ndr_stream_t *recv_nds = &mxa->recv_nds; ndr_stream_t *send_nds = &mxa->send_nds; ndr_heap_t *heap = clnt->heap; int rc; if (heap == NULL) { if ((heap = ndr_heap_create()) == NULL) return (-1); clnt->heap = heap; } mxa->heap = heap; rc = nds_initialize(send_nds, 0, NDR_MODE_CALL_SEND, heap); if (rc == 0) rc = nds_initialize(recv_nds, NDR_PDU_SIZE_HINT_DEFAULT, NDR_MODE_RETURN_RECV, heap); if (rc != 0) { nds_destruct(&mxa->recv_nds); nds_destruct(&mxa->send_nds); ndr_heap_destroy(mxa->heap); mxa->heap = NULL; clnt->heap = NULL; return (-1); } if (clnt->nonull) NDS_SETF(send_nds, NDS_F_NONULL); return (0); }