- static char reply_buf[MAX_RPC_MSGSIZE];
- XDR xdr_out;
- xdrmem_create(&xdr_out, reply_buf, MAX_RPC_MSGSIZE, XDR_ENCODE);
- if (result != NULL && !_xdr_result(&xdr_out, result)) {
- async_rpc_send_failure(req, SYSTEM_ERR);
- }
-
- struct rpc_reply header;
- header.xid = htonl(xid);
- header.type = htonl(1); /* REPLY */
- header.stat = htonl(MSG_ACCEPTED);
- header.verf_flavor = 0;
- header.verf_len = 0;
- header.accept_stat = 0;
-
- gsize msg_size = xdr_out.x_ops->x_getpostn(&xdr_out);
- printf("Have an RPC reply of size %zd bytes\n", msg_size);
- uint32_t fragment = htonl((msg_size + sizeof(header)) | 0x80000000);
- async_rpc_write(connection, (const char *)&fragment, sizeof(fragment));
- async_rpc_write(connection, (const char *)&header, sizeof(header));
- async_rpc_write(connection, reply_buf, msg_size);
- g_io_channel_flush(connection->channel, NULL);
-
- /* Clean up. */
- xdr_in.x_op = XDR_FREE;
- if (!_xdr_argument(&xdr_in, (caddr_t)req->args)) {
- fprintf (stderr, "%s", "unable to free arguments");
- exit (1);
- }
- g_free(req->args);