diff options
author | Amitay Isaacs <amitay@gmail.com> | 2013-10-04 15:37:24 +1000 |
---|---|---|
committer | Amitay Isaacs <amitay@gmail.com> | 2013-10-04 15:43:31 +1000 |
commit | 0205d52657e17246121039d5312708810e94bc73 (patch) | |
tree | 9e594a20ab447facb1b96ba222f653c7121e9d03 /ctdb | |
parent | be33efa3e441281ad81a66ffcb78935aef61b05b (diff) | |
download | samba-0205d52657e17246121039d5312708810e94bc73.tar.gz samba-0205d52657e17246121039d5312708810e94bc73.tar.xz samba-0205d52657e17246121039d5312708810e94bc73.zip |
client: Add functions to handle server_id structure
server_id records are stored in g_lock.tdb for persistent transactions.
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
(This used to be ctdb commit 55f91ea4373c54ddb5faad87fa2826d86a4b6172)
Diffstat (limited to 'ctdb')
-rw-r--r-- | ctdb/client/ctdb_client.c | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/ctdb/client/ctdb_client.c b/ctdb/client/ctdb_client.c index 997a234973..0757246ef0 100644 --- a/ctdb/client/ctdb_client.c +++ b/ctdb/client/ctdb_client.c @@ -3730,6 +3730,72 @@ int ctdb_ctrl_getcapabilities(struct ctdb_context *ctdb, struct timeval timeout, return ret; } +struct server_id { + uint64_t pid; + uint32_t task_id; + uint32_t vnn; + uint64_t unique_id; +}; + +static struct server_id server_id_get(struct ctdb_context *ctdb, uint32_t reqid) +{ + struct server_id id; + + id.pid = getpid(); + id.task_id = reqid; + id.vnn = ctdb_get_pnn(ctdb); + id.unique_id = id.vnn; + id.unique_id = (id.unique_id << 32) | reqid; + + return id; +} + +static bool server_id_equal(struct server_id *id1, struct server_id *id2) +{ + if (id1->pid != id2->pid) { + return false; + } + + if (id1->task_id != id2->task_id) { + return false; + } + + if (id1->vnn != id2->vnn) { + return false; + } + + if (id1->unique_id != id2->unique_id) { + return false; + } + + return true; +} + +static bool server_id_exists(struct ctdb_context *ctdb, struct server_id *id) +{ + struct ctdb_server_id sid; + int ret; + uint32_t result; + + sid.type = SERVER_TYPE_SAMBA; + sid.pnn = id->vnn; + sid.server_id = id->pid; + + ret = ctdb_ctrl_check_server_id(ctdb, timeval_current_ofs(3,0), + id->vnn, &sid, &result); + if (ret != 0) { + /* If control times out, assume server_id exists. */ + return true; + } + + if (result) { + return true; + } + + return false; +} + + /** * check whether a transaction is active on a given db on a given node */ |