1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-13 13:18:06 +03:00

paraoid check for empty db on attach

(This used to be ctdb commit f46ecc15d8d6520a7bce721d915897deba84a54f)
This commit is contained in:
Andrew Tridgell 2007-05-25 18:48:49 +10:00
parent 613c6b9c4c
commit 3c3ed0989e

View File

@ -317,6 +317,20 @@ int ctdb_ltdb_lock_fetch_requeue(struct ctdb_db_context *ctdb_db,
}
/*
paraoid check to see if the db is empty
*/
static void ctdb_check_db_empty(struct ctdb_db_context *ctdb_db)
{
struct tdb_context *tdb = ctdb_db->ltdb->tdb;
int count = tdb_traverse_read(tdb, NULL, NULL);
if (count != 0) {
DEBUG(0,(__location__ " tdb '%s' not empty on attach! aborting\n",
ctdb_db->db_path));
ctdb_fatal(ctdb_db->ctdb, "database not empty on attach");
}
}
/*
a client has asked to attach a new database
*/
@ -384,6 +398,8 @@ int32_t ctdb_control_db_attach(struct ctdb_context *ctdb, TDB_DATA indata,
return -1;
}
ctdb_check_db_empty(ctdb_db);
DLIST_ADD(ctdb->db_list, ctdb_db);
/*