}
}
+static void ctdb_initialise_vnn_map(struct ctdb_context *ctdb)
+{
+ int i, j, count;
+
+ /* initialize the vnn mapping table, skipping any deleted nodes */
+ ctdb->vnn_map = talloc(ctdb, struct ctdb_vnn_map);
+ CTDB_NO_MEMORY_FATAL(ctdb, ctdb->vnn_map);
+
+ count = 0;
+ for (i = 0; i < ctdb->num_nodes; i++) {
+ if ((ctdb->nodes[i]->flags & NODE_FLAGS_DELETED) == 0) {
+ count++;
+ }
+ }
+
+ ctdb->vnn_map->generation = INVALID_GENERATION;
+ ctdb->vnn_map->size = count;
+ ctdb->vnn_map->map = talloc_array(ctdb->vnn_map, uint32_t, ctdb->vnn_map->size);
+ CTDB_NO_MEMORY_FATAL(ctdb, ctdb->vnn_map->map);
+
+ for(i=0, j=0; i < ctdb->vnn_map->size; i++) {
+ if (ctdb->nodes[i]->flags & NODE_FLAGS_DELETED) {
+ continue;
+ }
+ ctdb->vnn_map->map[j] = i;
+ j++;
+ }
+}
+
/*
start the protocol going as a daemon
*/
}
}
+ ctdb_initialise_vnn_map(ctdb);
/* attach to existing databases */
if (ctdb_attach_databases(ctdb) != 0) {
{
char **lines;
int nlines;
- int i, j, num_present;
+ int i;
talloc_free(ctdb->nodes);
ctdb->nodes = NULL;
nlines--;
}
- num_present = 0;
for (i=0; i < nlines; i++) {
char *node;
talloc_free(lines);
return -1;
}
- num_present++;
}
- /* initialize the vnn mapping table now that we have the nodes list,
- skipping any deleted nodes
- */
- ctdb->vnn_map = talloc(ctdb, struct ctdb_vnn_map);
- CTDB_NO_MEMORY(ctdb, ctdb->vnn_map);
-
- ctdb->vnn_map->generation = INVALID_GENERATION;
- ctdb->vnn_map->size = num_present;
- ctdb->vnn_map->map = talloc_array(ctdb->vnn_map, uint32_t, ctdb->vnn_map->size);
- CTDB_NO_MEMORY(ctdb, ctdb->vnn_map->map);
-
- for(i=0, j=0; i < ctdb->vnn_map->size; i++) {
- if (ctdb->nodes[i]->flags & NODE_FLAGS_DELETED) {
- continue;
- }
- ctdb->vnn_map->map[j] = i;
- j++;
- }
-
talloc_free(lines);
return 0;
}