client: refuse to do record_store() on a persistent tdb.
authorMichael Adam <obnox@samba.org>
Mon, 20 Jul 2009 14:34:56 +0000 (16:34 +0200)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Wed, 29 Jul 2009 01:17:07 +0000 (11:17 +1000)
Only allow stores wrapped in transactions on persistent dbs.

Michael

client/ctdb_client.c

index 19a935023f4d31a1e5d45d547d2ed2e134973697..f6dbc73a6972cc27e35b19e491b48d35c4350934 100644 (file)
@@ -644,46 +644,12 @@ again:
 */
 int ctdb_record_store(struct ctdb_record_handle *h, TDB_DATA data)
 {
-       int ret;
-       int32_t status;
-       struct ctdb_rec_data *rec;
-       TDB_DATA recdata;
-
        if (h->ctdb_db->persistent) {
-               h->header.rsn++;
-       }
-
-       ret = ctdb_ltdb_store(h->ctdb_db, h->key, &h->header, data);
-       if (ret != 0) {
-               return ret;
-       }
-
-       /* don't need the persistent_store control for non-persistent databases */
-       if (!h->ctdb_db->persistent) {
-               return 0;
-       }
-
-       rec = ctdb_marshall_record(h, h->ctdb_db->db_id, h->key, &h->header, data);
-       if (rec == NULL) {
-               DEBUG(DEBUG_ERR,("Unable to marshall record in ctdb_record_store\n"));
-               return -1;
-       }
-
-       recdata.dptr = (uint8_t *)rec;
-       recdata.dsize = rec->length;
-
-       ret = ctdb_control(h->ctdb_db->ctdb, CTDB_CURRENT_NODE, 0, 
-                          CTDB_CONTROL_PERSISTENT_STORE, 0,
-                          recdata, NULL, NULL, &status, NULL, NULL);
-
-       talloc_free(rec);
-
-       if (ret != 0 || status != 0) {
-               DEBUG(DEBUG_ERR,("Failed persistent store in ctdb_record_store\n"));
+               DEBUG(DEBUG_ERR, (__location__ " ctdb_record_store prohibited for persistent dbs\n"));
                return -1;
        }
 
-       return 0;
+       return ctdb_ltdb_store(h->ctdb_db, h->key, &h->header, data);
 }
 
 /*