return ret;
}
-/*
- * Are we active (i.e. not banned or stopped?)
- */
-static bool ctdbd_working(struct ctdbd_connection *conn, uint32_t vnn)
+static int ctdbd_control_get_nodemap(struct ctdbd_connection *conn,
+ TALLOC_CTX *mem_ctx,
+ struct ctdb_node_map_old **_nodemap)
{
int32_t cstatus=-1;
TDB_DATA outdata = {0};
- struct ctdb_node_map_old *m;
- bool ok = false;
- uint32_t i;
int ret;
ret = ctdbd_control_local(conn, CTDB_CONTROL_GET_NODEMAP, 0, 0,
- tdb_null, talloc_tos(), &outdata, &cstatus);
+ tdb_null, mem_ctx, &outdata, &cstatus);
if (ret != 0) {
DEBUG(1, ("ctdbd_control failed: %s\n", strerror(ret)));
- return false;
+ return ret;
}
if ((cstatus != 0) || (outdata.dptr == NULL)) {
DEBUG(2, ("Received invalid ctdb data\n"));
- goto fail;
+ return EINVAL;
}
- m = (struct ctdb_node_map_old *)outdata.dptr;
+ *_nodemap = (struct ctdb_node_map_old *)outdata.dptr;
+ return 0;
+}
+
+/*
+ * Are we active (i.e. not banned or stopped?)
+ */
+static bool ctdbd_working(struct ctdbd_connection *conn, uint32_t vnn)
+{
+ struct ctdb_node_map_old *m = NULL;
+ bool ok = false;
+ uint32_t i;
+ int ret;
+
+ ret = ctdbd_control_get_nodemap(conn, talloc_tos(), &m);
+ if (ret != 0) {
+ DEBUG(1, ("ctdbd_control_get_nodemap() failed: %s\n", strerror(ret)));
+ return false;
+ }
for (i=0; i<m->num; i++) {
if (vnn == m->nodes[i].pnn) {
ok = true;
fail:
- TALLOC_FREE(outdata.dptr);
+ TALLOC_FREE(m);
return ok;
}