merged vnn map broadcast from ronnie
[vlendec/samba-autobuild/.git] / ctdb / common / cmdline.c
index 1a3937af12ea687715aab04ab3551be56d6be640..6a8cdb51f31038c224f06d03a2a37efe81625fd3 100644 (file)
@@ -37,6 +37,7 @@ static struct {
        const char *db_dir;
        int torture;
        const char *logfile;
+       const char *events;
 } ctdb_cmdline = {
        .nlist = NULL,
        .transport = "tcp",
@@ -45,11 +46,26 @@ static struct {
        .self_connect = 0,
        .db_dir = NULL,
        .torture = 0,
-       .logfile = NULL
+       .logfile = NULL,
 };
 
+enum {OPT_EVENTSYSTEM=1};
+
+static void ctdb_cmdline_callback(poptContext con, 
+                                 enum poptCallbackReason reason,
+                                 const struct poptOption *opt,
+                                 const char *arg, const void *data)
+{
+       switch (opt->val) {
+       case OPT_EVENTSYSTEM:
+               event_set_default_backend(arg);
+               break;
+       }
+}
+
 
 struct poptOption popt_ctdb_cmdline[] = {
+       { NULL, 0, POPT_ARG_CALLBACK, (void *)ctdb_cmdline_callback },  
        { "nlist", 0, POPT_ARG_STRING, &ctdb_cmdline.nlist, 0, "node list file", "filename" },
        { "listen", 0, POPT_ARG_STRING, &ctdb_cmdline.myaddress, 0, "address to listen on", "address" },
        { "socket", 0, POPT_ARG_STRING, &ctdb_cmdline.socketname, 0, "local socket name", "filename" },
@@ -59,6 +75,7 @@ struct poptOption popt_ctdb_cmdline[] = {
        { "dbdir", 0, POPT_ARG_STRING, &ctdb_cmdline.db_dir, 0, "directory for the tdb files", NULL },
        { "torture", 0, POPT_ARG_NONE, &ctdb_cmdline.torture, 0, "enable nastiness in library", NULL },
        { "logfile", 0, POPT_ARG_STRING, &ctdb_cmdline.logfile, 0, "log file location", "filename" },
+       { "events", 0, POPT_ARG_STRING, NULL, OPT_EVENTSYSTEM, "event system", NULL },
        { NULL }
 };
 
@@ -141,18 +158,13 @@ XXX Once we have recovery working we should initialize this always to
 XXX generation==0 (==invalid) and let the recovery tool populate this 
 XXX table for the daemons. 
 */
-       ctdb->vnn_map = talloc_zero(ctdb, struct ctdb_vnn_map);
+       ctdb->vnn_map = talloc_zero_size(ctdb, offsetof(struct ctdb_vnn_map, map) + 4*ctdb->num_nodes);
        if (ctdb->vnn_map == NULL) {
                DEBUG(0,(__location__ " Unable to allocate vnn_map structure\n"));
                exit(1);
        }
        ctdb->vnn_map->generation = 1;
        ctdb->vnn_map->size = ctdb->num_nodes;
-       ctdb->vnn_map->map = talloc_array(ctdb->vnn_map, uint32_t, ctdb->vnn_map->size);
-       if (ctdb->vnn_map->map == NULL) {
-               DEBUG(0,(__location__ " Unable to allocate vnn_map->map structure\n"));
-               exit(1);
-       }
        for(i=0;i<ctdb->vnn_map->size;i++){
                ctdb->vnn_map->map[i] = i%ctdb->num_nodes;
        }