ctdb-client: Factor out ctdb_client_get_server_id function
authorAmitay Isaacs <amitay@gmail.com>
Tue, 19 Apr 2016 05:24:11 +0000 (15:24 +1000)
committerMartin Schwenke <martins@samba.org>
Tue, 5 Jul 2016 08:53:14 +0000 (10:53 +0200)
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
ctdb/client/client.h
ctdb/client/client_db.c
ctdb/client/client_util.c

index 1f1fedad4453ade2845533a06e5c36f32f2275c1..3ad098fd699297cf144d2abfac1b3a2eb377933c 100644 (file)
@@ -854,6 +854,10 @@ int ctdb_ctrl_modflags(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
                       uint32_t destnode, struct timeval timeout,
                       uint32_t set, uint32_t clear);
 
+struct ctdb_server_id ctdb_client_get_server_id(
+                               struct ctdb_client_context *client,
+                               uint32_t task_id);
+
 bool ctdb_server_id_equal(struct ctdb_server_id *sid1,
                          struct ctdb_server_id *sid2);
 
index d5633d7704353c610b9372fe0062b7b481ae0054..09d9f23ecac5386c8749297aa20748db279ba690 100644 (file)
@@ -1747,13 +1747,9 @@ struct tevent_req *ctdb_transaction_start_send(TALLOC_CTX *mem_ctx,
        h->readonly = readonly;
        h->updated = false;
 
-       /* SRVID is unique for databases, so client can have transactions active
-        * for multiple databases */
-       h->sid.pid = getpid();
-       h->sid.task_id = db->db_id;
-       h->sid.vnn = state->destnode;
-       h->sid.unique_id = h->sid.task_id;
-       h->sid.unique_id = (h->sid.unique_id << 32) | h->sid.pid;
+       /* SRVID is unique for databases, so client can have transactions
+        * active for multiple databases */
+       h->sid = ctdb_client_get_server_id(client, db->db_id);
 
        h->recbuf = ctdb_rec_buffer_init(h, db->db_id);
        if (tevent_req_nomem(h->recbuf, req)) {
index c4dbe04b9d55a9736ef248bb0e392c7f769a7787..1ba1e7d10e858ec1199271e8553949763d3ab719 100644 (file)
@@ -112,6 +112,21 @@ int ctdb_ctrl_modflags(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
        return ret;
 }
 
+struct ctdb_server_id ctdb_client_get_server_id(
+                               struct ctdb_client_context *client,
+                               uint32_t task_id)
+{
+       struct ctdb_server_id sid;
+
+       sid.pid = getpid();
+       sid.task_id = task_id;
+       sid.vnn = ctdb_client_pnn(client);
+       sid.unique_id = task_id;
+       sid.unique_id = (sid.unique_id << 32) | sid.pid;
+
+       return sid;
+}
+
 bool ctdb_server_id_equal(struct ctdb_server_id *sid1,
                          struct ctdb_server_id *sid2)
 {