ReadOnly: Check the readonly flag instead of whether the tdb pointer is NULL or not
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Tue, 23 Aug 2011 00:41:52 +0000 (10:41 +1000)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Tue, 23 Aug 2011 00:41:52 +0000 (10:41 +1000)
server/ctdb_call.c
server/ctdb_daemon.c
server/ctdb_ltdb_server.c
server/ctdb_recover.c

index fbce276df35924992550289f8f8dea905e02e159..9e8642221c462dc42531e3a08cc60f990acdcf62 100644 (file)
@@ -507,7 +507,7 @@ void ctdb_request_call(struct ctdb_context *ctdb, struct ctdb_req_header *hdr)
        }
 
        /* Dont do READONLY if we dont have a tracking database */
-       if ((c->flags & CTDB_WANT_READONLY) && ctdb_db->rottdb == NULL) {
+       if ((c->flags & CTDB_WANT_READONLY) && !ctdb_db->readonly) {
                c->flags &= ~CTDB_WANT_READONLY;
        }
 
index 742170a690c895ed98cc9ec749ed1fefae149617..88d12103f77606a9fe67ec8750a4c7608b0bf723 100644 (file)
@@ -425,7 +425,7 @@ static void daemon_request_call_from_client(struct ctdb_client *client,
        }
 
        /* Dont do READONLY if we dont have a tracking database */
-       if ((c->flags & CTDB_WANT_READONLY) && ctdb_db->rottdb == NULL) {
+       if ((c->flags & CTDB_WANT_READONLY) && !ctdb_db->readonly) {
                c->flags &= ~CTDB_WANT_READONLY;
        }
 
index 82ed0f2b7c087328be6bf48eb0fe6b94da70e38f..3c41bb1ab70c5432f6683e8c5e64e94286530ff7 100644 (file)
@@ -937,6 +937,7 @@ again:
                ropath = talloc_asprintf(ctdb_db, "%s.RO", ctdb_db->db_path);
                if (ropath == NULL) {
                        DEBUG(DEBUG_CRIT,("Failed to asprintf the tracking database\n"));
+                       ctdb_db->readonly = false;
                        talloc_free(ctdb_db);
                        return -1;
                }
@@ -946,6 +947,7 @@ again:
                                      O_CREAT|O_RDWR, 0);
                if (ctdb_db->rottdb == NULL) {
                        DEBUG(DEBUG_CRIT,("Failed to open/create the tracking database '%s'\n", ropath));
+                       ctdb_db->readonly = false;
                        talloc_free(ctdb_db);
                        return -1;
                }
index 85b44b4734e327fa11f2972d84dc9570ca19b75b..f865dbadfbecd11f29160325da452fcca3376b76 100644 (file)
@@ -497,6 +497,7 @@ int32_t ctdb_control_push_db(struct ctdb_context *ctdb, TDB_DATA indata)
                        ctdb_db->readonly = false;
                        tdb_close(ctdb_db->rottdb);
                        ctdb_db->rottdb = NULL;
+                       ctdb_db->readonly = false;
                }
                while (ctdb_db->revokechild_active != NULL) {
                        talloc_free(ctdb_db->revokechild_active);