ReadOnly: Add an extra flag to ctdb_call_local to specify whether we want to write...
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Wed, 20 Jul 2011 03:30:12 +0000 (13:30 +1000)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Tue, 23 Aug 2011 00:25:05 +0000 (10:25 +1000)
client/ctdb_client.c
include/ctdb_private.h
server/ctdb_call.c

index 2b215d07d1849af8ba7dff78141f3f20b7de8fdf..bcf9b2e89a928cb70bcbc271821ec624e258ee1d 100644 (file)
@@ -72,7 +72,7 @@ struct ctdb_req_header *_ctdbd_allocate_pkt(struct ctdb_context *ctdb,
 */
 int ctdb_call_local(struct ctdb_db_context *ctdb_db, struct ctdb_call *call,
                    struct ctdb_ltdb_header *header, TALLOC_CTX *mem_ctx,
-                   TDB_DATA *data)
+                   TDB_DATA *data, bool updatetdb)
 {
        struct ctdb_call_info *c;
        struct ctdb_registered_call *fn;
@@ -111,7 +111,7 @@ int ctdb_call_local(struct ctdb_db_context *ctdb_db, struct ctdb_call *call,
                c->new_data = &c->record_data;
        }
 
-       if (c->new_data) {
+       if (c->new_data && updatetdb) {
                /* XXX check that we always have the lock here? */
                if (ctdb_ltdb_store(ctdb_db, call->key, header, *c->new_data) != 0) {
                        ctdb_set_error(ctdb, "ctdb_call tdb_store failed\n");
@@ -346,7 +346,7 @@ int ctdb_call_recv(struct ctdb_client_call_state *state, struct ctdb_call *call)
        call->status = state->call->status;
        talloc_free(state);
 
-       return 0;
+       return call->status;
 }
 
 
@@ -387,7 +387,7 @@ static struct ctdb_client_call_state *ctdb_client_call_local_send(struct ctdb_db
        *(state->call) = *call;
        state->ctdb_db = ctdb_db;
 
-       ret = ctdb_call_local(ctdb_db, state->call, header, state, data);
+       ret = ctdb_call_local(ctdb_db, state->call, header, state, data, true);
 
        return state;
 }
index d0f0dc4972f44f01924cead559eb945444537e6a..f7ab821b166cc87825216743ef4ffe9b9194b181 100644 (file)
@@ -791,7 +791,7 @@ struct ctdb_call_state *ctdb_daemon_call_send_remote(struct ctdb_db_context *ctd
 
 int ctdb_call_local(struct ctdb_db_context *ctdb_db, struct ctdb_call *call,
                    struct ctdb_ltdb_header *header, TALLOC_CTX *mem_ctx,
-                   TDB_DATA *data);
+                   TDB_DATA *data, bool updatetdb);
 
 #define ctdb_reqid_find(ctdb, reqid, type)     (type *)_ctdb_reqid_find(ctdb, reqid, #type, __location__)
 
index 0ea76bf44fdaac0f380a13b67a24ca7797f08b26..eb5e2582b9c510091300fe9d0d4c81d16a2d0144 100644 (file)
@@ -339,7 +339,7 @@ static void ctdb_become_dmaster(struct ctdb_db_context *ctdb_db,
                return;
        }
 
-       ctdb_call_local(ctdb_db, state->call, &header, state, &data);
+       ctdb_call_local(ctdb_db, state->call, &header, state, &data, true);
 
        ret = ctdb_ltdb_unlock(ctdb_db, state->call->key);
        if (ret != 0) {
@@ -543,7 +543,11 @@ void ctdb_request_call(struct ctdb_context *ctdb, struct ctdb_req_header *hdr)
                }
        }
 
-       ctdb_call_local(ctdb_db, call, &header, hdr, &data);
+       ret = ctdb_call_local(ctdb_db, call, &header, hdr, &data, true);
+       if (ret != 0) {
+               DEBUG(DEBUG_ERR,(__location__ " ctdb_call_local failed\n"));
+               call->status = -1;
+       }
 
        ret = ctdb_ltdb_unlock(ctdb_db, call->key);
        if (ret != 0) {
@@ -766,7 +770,7 @@ struct ctdb_call_state *ctdb_call_local_send(struct ctdb_db_context *ctdb_db,
        *(state->call) = *call;
        state->ctdb_db = ctdb_db;
 
-       ret = ctdb_call_local(ctdb_db, state->call, header, state, data);
+       ret = ctdb_call_local(ctdb_db, state->call, header, state, data, true);
 
        event_add_timed(ctdb->ev, state, timeval_zero(), call_local_trigger, state);