rxgen: Tidy up server side freeing
authorSimon Wilkinson <sxw@your-file-system.com>
Thu, 5 Jan 2012 10:51:06 +0000 (10:51 +0000)
committerDerrick Brashear <shadow@dementix.org>
Mon, 9 Apr 2012 01:13:33 +0000 (18:13 -0700)
commite202822b8efd7511f8652064cd8831c0a049dce6
treec87ed13fc7dab0a99d5dc438a24c898558261e20
parent709a6358e1d1f6cc0b025522e1e595c50bb2b733
rxgen: Tidy up server side freeing

The way in which rxgen handles freeing of objects allocated by the RPC
stub has evolved over the years. Originally, there appears to have been
a "somefrees" parameter which was used to track whether objects required
freeing or not. However, this parameter has fallen in to disuse, as
support for typedefs and unions were added, and which parameters
require freed is now tracked within the description structures
themselves. So, get rid of somefrees, as it is now just confusing.

The generated code to free a set of RPC arguments currently looks
something like:

fail:
        z_xdrs->x_op = XDR_FREE;
        if (!xdr_string(z_xdrs, &Name, AFSNAMEMAX)) goto fail1;
        if (!xdr_string(z_xdrs, &OfflineMsg, AFSOPAQUEMAX)) goto fail1;
        if (!xdr_string(z_xdrs, &Motd, AFSOPAQUEMAX)) goto fail1;
        if (rx_enable_stats) {
            rx_RecordCallStatistics(z_call, RXAFS_STATINDEX,
                19, RXAFS_NO_OF_STAT_FUNCS, 0);
        }

        return z_result;
fail1:
        if (rx_enable_stats) {
            rx_RecordCallStatistics(z_call, RXAFS_STATINDEX,
                19, RXAFS_NO_OF_STAT_FUNCS, 0);
        }

        return RXGEN_SS_XDRFREE;

Which isn't very efficient, or easy to modify. So, change the code
generator to produce code that looks like:

fail:
        z_xdrs->x_op = XDR_FREE;
        if ((!xdr_string(z_xdrs, &Name, AFSNAMEMAX))
            || (!xdr_string(z_xdrs, &OfflineMsg, AFSOPAQUEMAX))
            || (!xdr_string(z_xdrs, &Motd, AFSOPAQUEMAX)))
                z_result = RXGEN_SS_XDRFREE;

        if (rx_enable_stats) {
            rx_RecordCallStatistics(z_call, RXAFS_STATINDEX,
                19, RXAFS_NO_OF_STAT_FUNCS, 0);
        }

        return z_result;

This does the same thing, but is easier to read and is more consistent
with the way that we structure marshalling and unmarshalling.

Change-Id: I8b56f320c05c5d4270daf409d57514cbe8d076f5
Reviewed-on: http://gerrit.openafs.org/7005
Reviewed-by: Derrick Brashear <shadow@dementix.org>
Tested-by: Derrick Brashear <shadow@dementix.org>
src/rxgen/rpc_parse.c