ctdb-protocol: Fix marshalling for struct ctdb_rec_data
authorAmitay Isaacs <amitay@gmail.com>
Fri, 6 Nov 2015 06:07:35 +0000 (17:07 +1100)
committerMartin Schwenke <martins@samba.org>
Wed, 25 Nov 2015 12:21:47 +0000 (13:21 +0100)
commit1ee7053180057ea526870182b5619a206b4d103b
tree6350ffe6cd265e3676c01b200c4e22aad1106219
parent8ded8e81b0f0da8a3ea79d63d575b6493e4a87f3
ctdb-protocol: Fix marshalling for struct ctdb_rec_data

If the header is specified, then the datalen should be incremented.

There are two ways of marshalling ctdb_rec_data:

1. ctdb_rec_data->header is NULL and ctdb_rec_data->data embeds both
   the header and the value. Used in recovery for push/pull of records.

2. ctdb_rec_data->header is not NULL and ctdb_rec_data->data embeds
   only the value.  Used everywhere else.

In both cases, the wire format includes the header and the value.
There is nothing in the wire format to inform the unmarshalling code
whether to extract the header separately or not.

In the current code the header is extracted depending on whether the
header argument to the extractor routine is NULL or not.  This is insane
and highly error-prone.

So in the new API, unmarshalling code never extracts the header.  If the
caller requires the header, then it can be extracted separately using
special function ctdb_ltdb_header_extract().

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Wed Nov 25 13:21:48 CET 2015 on sn-devel-104
ctdb/protocol/protocol_types.c
ctdb/tests/src/protocol_types_test.c