You should have received a copy of the GNU General Public License
along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
+#include <sys/time.h>
#include <sys/socket.h>
#include <string.h>
#include <ctdb.h>
#undef ctdb_getdbseqnum_send
#undef ctdb_getifaces_send
#undef ctdb_getvnnmap_send
+#undef ctdb_getcapabilities_send
bool ctdb_getrecmaster_recv(struct ctdb_connection *ctdb,
struct ctdb_request *req, uint32_t *recmaster)
DEBUG(ctdb, LOG_ERR, "ctdb_getrecmaster_recv: status -1");
return false;
}
+ /* Note: data is stashed in status - see ctdb_control_dispatch() */
*recmaster = reply->status;
return true;
}
DEBUG(ctdb, LOG_ERR, "ctdb_getrecmode_recv: status -1");
return false;
}
+ /* Note: data is stashed in status - see ctdb_control_dispatch() */
*recmode = reply->status;
return true;
}
DEBUG(ctdb, LOG_ERR, "ctdb_getpnn_recv: status -1");
return false;
}
+ /* Note: data is stashed in status - see ctdb_control_dispatch() */
*pnn = reply->status;
return true;
}
struct ctdb_db_statistics **stat)
{
struct ctdb_reply_control *reply;
- struct ctdb_db_statistics *s;
+ struct ctdb_db_statistics *s, *wire;
+ int i;
+ char *ptr;
reply = unpack_reply_control(req, CTDB_CONTROL_GET_DB_STATISTICS);
if (!reply) {
DEBUG(ctdb, LOG_ERR, "ctdb_getpnn_recv: status -1");
return false;
}
- if (reply->datalen != sizeof(struct ctdb_db_statistics)) {
- DEBUG(ctdb, LOG_ERR, "ctdb_getdbstat_recv: returned data is %d bytes but should be %d", reply->datalen, (int)sizeof(struct ctdb_db_statistics));
+ if (reply->datalen < offsetof(struct ctdb_db_statistics, hot_keys_wire)) {
+ DEBUG(ctdb, LOG_ERR, "ctdb_getdbstat_recv: returned data is %d bytes but should be >= %d", reply->datalen, (int)sizeof(struct ctdb_db_statistics));
return false;
}
+ wire = (struct ctdb_db_statistics *)reply->data;
+
s = malloc(sizeof(struct ctdb_db_statistics));
if (!s) {
return false;
}
- memcpy(s, reply->data, sizeof(struct ctdb_db_statistics));
+
+ *s = *wire;
+ ptr = &wire->hot_keys_wire[0];
+ for (i = 0; i < wire->num_hot_keys; i++) {
+ s->hot_keys[i].key.dptr = malloc(s->hot_keys[i].key.dsize);
+ memcpy(s->hot_keys[i].key.dptr, ptr, s->hot_keys[i].key.dsize);
+ ptr += s->hot_keys[i].key.dsize;
+ }
+
*stat = s;
return true;
void ctdb_free_dbstat(struct ctdb_db_statistics *stat)
{
+ int i;
+
if (stat == NULL) {
return;
}
+
+ for (i = 0; i < stat->num_hot_keys; i++) {
+ if (stat->hot_keys[i].key.dptr != NULL) {
+ free(stat->hot_keys[i].key.dptr);
+ }
+ }
+
free(stat);
}
NULL, 0, callback, private_data);
}
+bool ctdb_getcapabilities_recv(struct ctdb_connection *ctdb,
+ struct ctdb_request *req, uint32_t *capabilities)
+{
+ struct ctdb_reply_control *reply;
+
+ reply = unpack_reply_control(req, CTDB_CONTROL_GET_CAPABILITIES);
+ if (!reply) {
+ return false;
+ }
+ if (reply->status == -1) {
+ DEBUG(ctdb, LOG_ERR, "ctdb_getcapabilities_recv: status -1");
+ return false;
+ }
+ *capabilities = *((uint32_t *)reply->data);
+ return true;
+}
+
+struct ctdb_request *ctdb_getcapabilities_send(struct ctdb_connection *ctdb,
+ uint32_t destnode,
+ ctdb_callback_t callback,
+ void *private_data)
+{
+ return new_ctdb_control_request(ctdb, CTDB_CONTROL_GET_CAPABILITIES,
+ destnode,
+ NULL, 0, callback, private_data);
+}
+