]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
when sending back a fetch lock reply to a client
authorRonnie sahlberg <ronniesahlberg@gmail.com>
Thu, 12 Apr 2007 11:14:41 +0000 (21:14 +1000)
committerRonnie sahlberg <ronniesahlberg@gmail.com>
Thu, 12 Apr 2007 11:14:41 +0000 (21:14 +1000)
we cant peek in state->c since this is uninitialized
and even if it were not it would be wrong

create a new structure to pass BOTH client and also the reqid to respond back to
the client with

(This used to be ctdb commit e1a0da3dfbb4a927e8d98723b5e51a201c2a3428)

ctdb/common/ctdb_daemon.c

index ad9bb325e10ea109a33a986a8d355e31718ae576..824cfed936cda969cc0e522f6a5d91f55464fda3 100644 (file)
@@ -140,10 +140,15 @@ static struct ctdb_call_state *ctdb_fetch_lock_send(struct ctdb_db_context *ctdb
        return state;
 }
 
+struct client_fetch_lock_data {
+       struct ctdb_client *client;
+       uint32_t reqid;
+};
 static void daemon_fetch_lock_complete(struct ctdb_call_state *state)
 {
        struct ctdb_reply_fetch_lock *r;
-       struct ctdb_client *client = talloc_get_type(state->async.private, struct ctdb_client);
+       struct client_fetch_lock_data *data = talloc_get_type(state->async.private, struct client_fetch_lock_data);
+       struct ctdb_client *client = talloc_get_type(data->client, struct ctdb_client);
        int length, res;
 
        length = offsetof(struct ctdb_reply_fetch_lock, data) + state->call.reply_data.dsize;
@@ -157,7 +162,7 @@ static void daemon_fetch_lock_complete(struct ctdb_call_state *state)
        r->hdr.ctdb_magic   = CTDB_MAGIC;
        r->hdr.ctdb_version = CTDB_VERSION;
        r->hdr.operation    = CTDB_REPLY_FETCH_LOCK;
-       r->hdr.reqid        = state->c->hdr.reqid;
+       r->hdr.reqid        = data->reqid;
        r->state            = state->state;
        r->datalen          = state->call.reply_data.dsize;
        memcpy(&r->data[0], state->call.reply_data.dptr, r->datalen);
@@ -178,6 +183,7 @@ static void daemon_request_fetch_lock(struct ctdb_client *client,
        struct ctdb_call_state *state;
        TDB_DATA key, *data;
        struct ctdb_db_context *ctdb_db;
+       struct client_fetch_lock_data *fl_data;
 
        ctdb_db = find_ctdb_db(client->ctdb, f->db_id);
 
@@ -191,8 +197,11 @@ static void daemon_request_fetch_lock(struct ctdb_client *client,
        state = ctdb_fetch_lock_send(ctdb_db, client, key, data);
        talloc_steal(state, data);
 
+       fl_data = talloc(state, struct client_fetch_lock_data);
+       fl_data->client = client;
+       fl_data->reqid  = f->hdr.reqid;
        state->async.fn = daemon_fetch_lock_complete;
-       state->async.private = client;
+       state->async.private = fl_data;
 }
 
 /*