diff options
author | Ronnie Sahlberg <ronniesahlberg@gmail.com> | 2011-11-30 10:00:07 +1100 |
---|---|---|
committer | Ronnie Sahlberg <ronniesahlberg@gmail.com> | 2011-11-30 10:00:07 +1100 |
commit | 11f3c947e6189994bd43a9fcd1301a1dc6251c78 (patch) | |
tree | f0f430e05b1cfa7295d36a5a3cdabaa8bbb429f2 /ctdb/libctdb | |
parent | 5a1e8df45187bcc4cf64b9135e174cc858a88c0a (diff) | |
download | samba-11f3c947e6189994bd43a9fcd1301a1dc6251c78.tar.gz samba-11f3c947e6189994bd43a9fcd1301a1dc6251c78.tar.xz samba-11f3c947e6189994bd43a9fcd1301a1dc6251c78.zip |
LibCTDB: add support for the check-srvids control
(This used to be ctdb commit c32604fd0016de0df14845a2f222edaa3c52a4fa)
Diffstat (limited to 'ctdb/libctdb')
-rw-r--r-- | ctdb/libctdb/control.c | 44 | ||||
-rw-r--r-- | ctdb/libctdb/sync.c | 18 |
2 files changed, 62 insertions, 0 deletions
diff --git a/ctdb/libctdb/control.c b/ctdb/libctdb/control.c index 70c8e51950e..419238101c8 100644 --- a/ctdb/libctdb/control.c +++ b/ctdb/libctdb/control.c @@ -25,6 +25,7 @@ #undef ctdb_getrecmaster_send #undef ctdb_getrecmode_send #undef ctdb_getpnn_send +#undef ctdb_check_message_handlers_send #undef ctdb_getnodemap_send #undef ctdb_getpublicips_send #undef ctdb_getdbseqnum_send @@ -240,3 +241,46 @@ struct ctdb_request *ctdb_getdbseqnum_send(struct ctdb_connection *ctdb, destnode, &indata, sizeof(uint64_t), callback, private_data); } + +bool ctdb_check_message_handlers_recv(struct ctdb_connection *ctdb, + struct ctdb_request *req, + uint32_t num, uint8_t *result) +{ + struct ctdb_reply_control *reply; + int i, count; + + reply = unpack_reply_control(req, CTDB_CONTROL_CHECK_SRVIDS); + if (!reply) { + return false; + } + if (reply->status == -1) { + DEBUG(ctdb, LOG_ERR, "ctdb_check_message_handlers_recv: status -1"); + return false; + } + + count = (num + 7) / 8; + if (count != reply->datalen) { + DEBUG(ctdb, LOG_ERR, "ctdb_check_message_handlers_recv: wrong amount of data returned, expected %d bytes for %d srvids but received %d bytes", count, num, reply->datalen); + return false; + } + + for (i = 0; i < num; i++) { + result[i] = !!(reply->data[i / 8] & (1 << (i % 8))); + } + + return true; +} + +struct ctdb_request * +ctdb_check_message_handlers_send(struct ctdb_connection *ctdb, + uint32_t destnode, + uint32_t num, + uint64_t *mhs, + ctdb_callback_t callback, + void *private_data) +{ + return new_ctdb_control_request(ctdb, CTDB_CONTROL_CHECK_SRVIDS, + destnode, + mhs, num * sizeof(uint64_t) , + callback, private_data); +} diff --git a/ctdb/libctdb/sync.c b/ctdb/libctdb/sync.c index 7c9949464b8..6696283f04c 100644 --- a/ctdb/libctdb/sync.c +++ b/ctdb/libctdb/sync.c @@ -136,6 +136,24 @@ bool ctdb_getpnn(struct ctdb_connection *ctdb, return ret; } +bool ctdb_check_message_handlers(struct ctdb_connection *ctdb, + uint32_t destnode, uint32_t num, + uint64_t *mhs, uint8_t *result) +{ + struct ctdb_request *req; + bool done = false; + bool ret = false; + + req = synchronous(ctdb, + ctdb_check_message_handlers_send(ctdb, destnode, num, mhs, set, &done), + &done); + if (req != NULL) { + ret = ctdb_check_message_handlers_recv(ctdb, req, num, result); + ctdb_request_free(req); + } + return ret; +} + bool ctdb_getnodemap(struct ctdb_connection *ctdb, uint32_t destnode, struct ctdb_node_map **nodemap) { |