s3:dbwrap_ctdb: fix fetch/fetch_locked when samba is built against old ctdb
authorMichael Adam <obnox@samba.org>
Fri, 29 Jun 2012 08:39:07 +0000 (10:39 +0200)
committerMichael Adam <obnox@samba.org>
Fri, 29 Jun 2012 13:21:17 +0000 (15:21 +0200)
The introduction of read only copies has broken the algorithm for
deteting whether we can use the local record copy for fetch_locked
and fetch: For fetch locked the new code always uses the local copy
if there is one...

This patch re-establish the original algorithm for the build against
a ctdb without read only record copies.

Reported-by: Gregor Beck <gbeck@sernet.de>
source3/lib/dbwrap/dbwrap_ctdb.c

index 1062cb0bbdbb1a031f80d271dcfcc060f3721013..01dfacac1a76bb36574bf851ff8fba3853638281 100644 (file)
@@ -1006,9 +1006,7 @@ static int db_ctdb_record_destr(struct db_record* data)
 /* Do I own this record? */
 static bool db_ctdb_own_record(TDB_DATA ctdb_data, bool read_only)
 {
-#ifdef HAVE_CTDB_WANT_READONLY_DECL
        struct ctdb_ltdb_header *hdr;
-#endif
 
        if (ctdb_data.dptr == NULL)
                return false;
@@ -1016,8 +1014,9 @@ static bool db_ctdb_own_record(TDB_DATA ctdb_data, bool read_only)
        if (ctdb_data.dsize < sizeof(struct ctdb_ltdb_header))
                return false;
 
-#ifdef HAVE_CTDB_WANT_READONLY_DECL
        hdr = (struct ctdb_ltdb_header *)ctdb_data.dptr;
+
+#ifdef HAVE_CTDB_WANT_READONLY_DECL
        if (hdr->dmaster != get_my_vnn()) {
                /* If we're not dmaster, it must be r/o copy. */
                return read_only && (hdr->flags & CTDB_REC_RO_HAVE_READONLY);
@@ -1026,7 +1025,7 @@ static bool db_ctdb_own_record(TDB_DATA ctdb_data, bool read_only)
        /* If we want write access, noone can have r/o copies. */
        return read_only || !(hdr->flags & CTDB_REC_RO_HAVE_DELEGATIONS);
 #else
-       return !read_only;
+       return (hdr->dmaster == get_my_vnn());
 #endif
 }