recoverd: Set explicit default value when getting tunable from nodes
authorMartin Schwenke <martin@meltin.net>
Thu, 23 May 2013 09:01:01 +0000 (19:01 +1000)
committerMartin Schwenke <martin@meltin.net>
Fri, 24 May 2013 06:04:57 +0000 (16:04 +1000)
Both of the current defaults are implicitly 0.  It is better to make
the defaults obvious.

Signed-off-by: Martin Schwenke <martin@meltin.net>
server/ctdb_takeover.c

index a8ca72182e2a1a9a9b70a53035ca4c54e5cde9d3..a978ec833cb13cc57c0f2b38c22ae4cc6176f31f 100644 (file)
@@ -2267,16 +2267,22 @@ static void get_tunable_callback(struct ctdb_context *ctdb, uint32_t pnn,
 static uint32_t *get_tunable_from_nodes(struct ctdb_context *ctdb,
                                        TALLOC_CTX *tmp_ctx,
                                        struct ctdb_node_map *nodemap,
-                                       const char *tunable)
+                                       const char *tunable,
+                                       uint32_t default_value)
 {
        TDB_DATA data;
        struct ctdb_control_get_tunable *t;
        uint32_t *nodes;
        uint32_t *tvals;
        struct get_tunable_callback_data callback_data;
+       int i;
 
-       tvals = talloc_zero_array(tmp_ctx, uint32_t, nodemap->num);
+       tvals = talloc_array(tmp_ctx, uint32_t, nodemap->num);
        CTDB_NO_MEMORY_NULL(ctdb, tvals);
+       for (i=0; i<nodemap->num; i++) {
+               tvals[i] = default_value;
+       }
+               
        callback_data.out = tvals;
        callback_data.tunable = tunable;
 
@@ -2366,15 +2372,16 @@ static struct ctdb_ipflags *set_ipflags(struct ctdb_context *ctdb,
        struct ctdb_ipflags *ipflags;
 
        tval_noiptakeover = get_tunable_from_nodes(ctdb, tmp_ctx, nodemap,
-                                                  "NoIPTakeover");
+                                                  "NoIPTakeover", 0);
        if (tval_noiptakeover == NULL) {
                return NULL;
        }
 
        tval_noiphostonalldisabled =
                get_tunable_from_nodes(ctdb, tmp_ctx, nodemap,
-                                      "NoIPHostOnAllDisabled");
+                                      "NoIPHostOnAllDisabled", 0);
        if (tval_noiphostonalldisabled == NULL) {
+               /* Caller frees tmp_ctx */
                return NULL;
        }