dbwrap_ctdb: Treat empty records as non-existing
authorVolker Lendecke <vl@samba.org>
Wed, 28 Aug 2013 11:34:08 +0000 (11:34 +0000)
committerJeremy Allison <jra@samba.org>
Wed, 28 Aug 2013 21:37:08 +0000 (23:37 +0200)
This is a patch implementing the workaround Christian mentioned in
https://bugzilla.samba.org/show_bug.cgi?id=10008#c5

Bug: https://bugzilla.samba.org/show_bug.cgi?id=10008
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Christian Ambach <ambi@samba.org>
source3/lib/ctdbd_conn.c
source3/lib/dbwrap/dbwrap_ctdb.c

index 4f5dce05dde7d47d966555f19d462be9baf0bb60..f960541c3a2e33967eab99ad7eb32f4e041c5350 100644 (file)
@@ -1474,6 +1474,14 @@ NTSTATUS ctdbd_parse(struct ctdbd_connection *conn, uint32_t db_id,
                goto fail;
        }
 
+       if (reply->datalen == 0) {
+               /*
+                * Treat an empty record as non-existing
+                */
+               status = NT_STATUS_NOT_FOUND;
+               goto fail;
+       }
+
        parser(key, make_tdb_data(&reply->data[0], reply->datalen),
               private_data);
 
index f90e7b80f1ef01b972378e8cb7dec2ae1bac6400..5a473f98afe46a89616d82d6e47574b33cf7f8c1 100644 (file)
@@ -103,6 +103,16 @@ static int db_ctdb_ltdb_parser(TDB_DATA key, TDB_DATA data,
        if (data.dsize < sizeof(struct ctdb_ltdb_header)) {
                return -1;
        }
+       if (data.dsize == sizeof(struct ctdb_ltdb_header)) {
+               /*
+                * Making this a separate case that needs fixing
+                * separately. This is an empty record. ctdbd does not
+                * distinguish between empty and deleted records. Samba right
+                * now can live without empty records, so lets treat zero-size
+                * (i.e. deleted) records as non-existing.
+                */
+               return -1;
+       }
        state->parser(
                key, (struct ctdb_ltdb_header *)data.dptr,
                make_tdb_data(data.dptr + sizeof(struct ctdb_ltdb_header),