Long-outstanding commit. (Hopefully) Final version before running experiments for...
[distributedratelimiting.git] / drl / config.c
index 1c56ce8..42f4472 100644 (file)
@@ -79,10 +79,13 @@ int get_eligible_leaves(drl_instance_t *instance) {
 
         return ENOMEM;
     }
+    memset(leaves, 0, count * sizeof(leaf_t));
 
     for (i = 0; i < count; ++i) {
         leaves[i].xid = atoi(names[i]->d_name);
         leaves[i].parent = NULL;
+        leaves[i].drop_prob = 0.0;
+        leaves[i].delay = 0;
         
         free(names[i]);
 
@@ -105,7 +108,9 @@ static int parse_common(xmlDocPtr doc, xmlNodePtr ident, ident_config *common) {
     xmlChar *branch;
     xmlChar *accounting;
     xmlChar *ewma;
-    xmlChar *intervals;
+    xmlChar *mainloop_intervals;
+    xmlChar *communication_intervals;
+    xmlChar *independent;
     xmlNodePtr fields = ident->children;
     ident_peer *current = NULL;
 
@@ -168,6 +173,8 @@ static int parse_common(xmlDocPtr doc, xmlNodePtr ident, ident_config *common) {
             common->accounting = ACT_SAMPLEHOLD;
         } else if (!xmlStrcmp(accounting, (const xmlChar *) "SIMPLE")) {
             common->accounting = ACT_SIMPLE;
+        } else if (!xmlStrcmp(accounting, (const xmlChar *) "MULTIPLEINTERVAL")) {
+            common->accounting = ACT_MULTIPLE;
         } else {
             printlog(LOG_CRITICAL, "Unknown/invalid accounting table.\n");
             xmlFree(accounting);
@@ -185,13 +192,30 @@ static int parse_common(xmlDocPtr doc, xmlNodePtr ident, ident_config *common) {
         xmlFree(ewma);
     }
 
-    intervals = xmlGetProp(ident, (const xmlChar *) "intervals");
-    if (intervals == NULL) {
-        printlog(LOG_CRITICAL, "Ident missing interval count.\n");
-        return EINVAL;
+    mainloop_intervals = xmlGetProp(ident, (const xmlChar *) "loop_intervals");
+    if (mainloop_intervals == NULL) {
+        printlog(LOG_WARN, "Ident id: %d missing loop_intervals, assuming 1.\n", common->id);
+        common->mainloop_intervals = 1;
+    } else {
+        common->mainloop_intervals = atoi((const char *) mainloop_intervals);
+        xmlFree(mainloop_intervals);
+    }
+
+    communication_intervals = xmlGetProp(ident, (const xmlChar *) "comm_intervals");
+    if (communication_intervals == NULL) {
+        printlog(LOG_WARN, "Ident id: %d missing comm_intervals, assuming 1.\n", common->id);
+        common->communication_intervals = 1;
+    } else {
+        common->communication_intervals = atoi((const char *) communication_intervals);
+        xmlFree(communication_intervals);
+    }
+
+    independent = xmlGetProp(ident, (const xmlChar *) "independent");
+    if (independent == NULL) {
+        common->independent = 0;
     } else {
-        common->intervals = atoi((const char *) intervals);
-        xmlFree(intervals);
+        common->independent = atoi((const char *) independent);
+        xmlFree(independent);
     }
 
     while (fields != NULL) {