ctdbd_conn: move CTDB_CONTROL_ENABLE_SEQNUM control to db_open_ctdb
authorRalph Boehme <slow@samba.org>
Tue, 11 Jul 2017 18:36:35 +0000 (20:36 +0200)
committerRalph Boehme <slow@samba.org>
Wed, 12 Jul 2017 07:01:19 +0000 (09:01 +0200)
No change in behaviour.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=12891

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
source3/lib/ctdbd_conn.c
source3/lib/dbwrap/dbwrap_ctdb.c

index d38789aa8612fccd7657f4519f3e46f458f95608..70d3d83f031ef74bb4cb554d615f6ef5193a2568 100644 (file)
@@ -847,21 +847,6 @@ int ctdbd_db_attach(struct ctdbd_connection *conn,
        *db_id = *(uint32_t *)data.dptr;
        talloc_free(data.dptr);
 
-       if (!(tdb_flags & TDB_SEQNUM)) {
-               return 0;
-       }
-
-       data.dptr = (uint8_t *)db_id;
-       data.dsize = sizeof(*db_id);
-
-       ret = ctdbd_control_local(conn, CTDB_CONTROL_ENABLE_SEQNUM, 0, 0, data,
-                                 NULL, NULL, &cstatus);
-       if ((ret != 0) || cstatus != 0) {
-               DEBUG(0, (__location__ " ctdb_control for enable seqnum "
-                         "failed: %s\n", strerror(ret)));
-               return (ret == 0) ? EIO : ret;
-       }
-
        return 0;
 }
 
index 8e303e6e1c478da64829276fdb3caceee2921426..001d2c42fb2d27752279b2c47240b2250533b5db 100644 (file)
@@ -1779,6 +1779,7 @@ struct db_context *db_open_ctdb(TALLOC_CTX *mem_ctx,
        struct db_ctdb_ctx *db_ctdb;
        char *db_path;
        struct loadparm_context *lp_ctx;
+       TDB_DATA data;
        int32_t cstatus;
        int ret;
 
@@ -1818,6 +1819,21 @@ struct db_context *db_open_ctdb(TALLOC_CTX *mem_ctx,
                return NULL;
        }
 
+       if (tdb_flags & TDB_SEQNUM) {
+               data.dptr = (uint8_t *)&db_ctdb->db_id;
+               data.dsize = sizeof(db_ctdb->db_id);
+
+               ret = ctdbd_control_local(conn, CTDB_CONTROL_ENABLE_SEQNUM,
+                                         0, 0, data,
+                                         NULL, NULL, &cstatus);
+               if ((ret != 0) || cstatus != 0) {
+                       DBG_ERR("ctdb_control for enable seqnum "
+                               "failed: %s\n", strerror(ret));
+                       TALLOC_FREE(result);
+                       return NULL;
+               }
+       }
+
        db_path = ctdbd_dbpath(db_ctdb->conn, db_ctdb, db_ctdb->db_id);
 
        result->persistent = ((tdb_flags & TDB_CLEAR_IF_FIRST) == 0);