diff options
author | Volker Lendecke <vl@samba.org> | 2011-10-31 13:29:13 +0100 |
---|---|---|
committer | Ronnie Sahlberg <ronniesahlberg@gmail.com> | 2011-11-30 09:02:26 +1100 |
commit | 5a1da0ac558df99e6b8ee84e6affe810dc966db7 (patch) | |
tree | 382859b63057afa61ea4cccb45cd037c5a3bb5eb | |
parent | 940e9cb7a7c4b566a06b5c3ed03bcafe02f24cd2 (diff) | |
download | samba-5a1da0ac558df99e6b8ee84e6affe810dc966db7.tar.gz samba-5a1da0ac558df99e6b8ee84e6affe810dc966db7.tar.xz samba-5a1da0ac558df99e6b8ee84e6affe810dc966db7.zip |
Add CTDB_CONTROL_CHECK_SRVID
(This used to be ctdb commit ad64ef2c40a2a12b37dbf39142e95c6781c2fc3b)
-rw-r--r-- | ctdb/include/ctdb_private.h | 2 | ||||
-rw-r--r-- | ctdb/include/ctdb_protocol.h | 1 | ||||
-rw-r--r-- | ctdb/server/ctdb_control.c | 3 | ||||
-rw-r--r-- | ctdb/server/ctdb_daemon.c | 36 |
4 files changed, 42 insertions, 0 deletions
diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h index da9ef9fedc..4155bac45b 100644 --- a/ctdb/include/ctdb_private.h +++ b/ctdb/include/ctdb_private.h @@ -967,6 +967,8 @@ int ctdb_dispatch_message(struct ctdb_context *ctdb, uint64_t srvid, TDB_DATA da int daemon_register_message_handler(struct ctdb_context *ctdb, uint32_t client_id, uint64_t srvid); int ctdb_deregister_message_handler(struct ctdb_context *ctdb, uint64_t srvid, void *private_data); int daemon_deregister_message_handler(struct ctdb_context *ctdb, uint32_t client_id, uint64_t srvid); +int daemon_check_srvids(struct ctdb_context *ctdb, TDB_DATA indata, + TDB_DATA *outdata); int32_t ctdb_ltdb_enable_seqnum(struct ctdb_context *ctdb, uint32_t db_id); int32_t ctdb_ltdb_update_seqnum(struct ctdb_context *ctdb, uint32_t db_id, uint32_t srcnode); diff --git a/ctdb/include/ctdb_protocol.h b/ctdb/include/ctdb_protocol.h index f404ec7905..99e3f4fd9e 100644 --- a/ctdb/include/ctdb_protocol.h +++ b/ctdb/include/ctdb_protocol.h @@ -373,6 +373,7 @@ enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS = 0, CTDB_CONTROL_GET_STAT_HISTORY = 127, CTDB_CONTROL_SCHEDULE_FOR_DELETION = 128, CTDB_CONTROL_SET_DB_READONLY = 129, + CTDB_CONTROL_CHECK_SRVIDS = 130, }; /* diff --git a/ctdb/server/ctdb_control.c b/ctdb/server/ctdb_control.c index 667083cf73..602e994b1d 100644 --- a/ctdb/server/ctdb_control.c +++ b/ctdb/server/ctdb_control.c @@ -263,6 +263,9 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb, case CTDB_CONTROL_DEREGISTER_SRVID: return daemon_deregister_message_handler(ctdb, client_id, srvid); + case CTDB_CONTROL_CHECK_SRVIDS: + return daemon_check_srvids(ctdb, indata, outdata); + case CTDB_CONTROL_ENABLE_SEQNUM: CHECK_CONTROL_DATA_SIZE(sizeof(uint32_t)); return ctdb_ltdb_enable_seqnum(ctdb, *(uint32_t *)indata.dptr); diff --git a/ctdb/server/ctdb_daemon.c b/ctdb/server/ctdb_daemon.c index 69fb6fb1f6..8bf435c307 100644 --- a/ctdb/server/ctdb_daemon.c +++ b/ctdb/server/ctdb_daemon.c @@ -205,6 +205,42 @@ int daemon_deregister_message_handler(struct ctdb_context *ctdb, uint32_t client return ctdb_deregister_message_handler(ctdb, srvid, client); } +int daemon_check_srvids(struct ctdb_context *ctdb, TDB_DATA indata, + TDB_DATA *outdata) +{ + uint64_t *ids; + int i, num_ids; + uint8_t *results; + + if ((indata.dsize % sizeof(uint64_t)) != 0) { + DEBUG(DEBUG_ERR, ("Bad indata in daemon_check_srvids, " + "size=%d\n", (int)indata.dsize)); + return -1; + } + + ids = (uint64_t *)indata.dptr; + num_ids = indata.dsize / 8; + + results = talloc_zero_array(outdata, uint8_t, (num_ids+7)/8); + if (results == NULL) { + DEBUG(DEBUG_ERR, ("talloc failed in daemon_check_srvids\n")); + return -1; + } + for (i=0; i<num_ids; i++) { + struct ctdb_message_list *ml; + for (ml=ctdb->message_list; ml; ml=ml->next) { + if (ml->srvid == ids[i]) { + break; + } + } + if (ml != NULL) { + results[i/8] |= (1 << (i%8)); + } + } + outdata->dptr = (uint8_t *)results; + outdata->dsize = talloc_get_size(results); + return 0; +} /* destroy a ctdb_client |