Cleaned up a lot of printing.
authorKevin Webb <kcwebb@ucsd.edu>
Wed, 12 Nov 2008 19:13:18 +0000 (19:13 +0000)
committerKevin Webb <kcwebb@ucsd.edu>
Wed, 12 Nov 2008 19:13:18 +0000 (19:13 +0000)
drl/drl_state.c
drl/estimate.c
drl/peer_comm.c
drl/samplehold.c
drl/standard.c
drl/ulogd_DRL.c
drl/util.c
drl/util.h

index a30337b..eba79ba 100644 (file)
@@ -134,6 +134,7 @@ int read_comm(comm_t *comm, double *aggregate, double decayto) {
              * we start to make the peer's value approach decayto, getting
              * half of the way there each time. */
             if (remote->awol >= REMOTE_AWOL_THRESHOLD) {
+                printlog(LOG_WARN, "AWOL remote limiter detected.\n");
                 remote->rate += ((decayto - remote->rate) / 2);
             } else {
                 remote->awol++;
index ed08447..e55639b 100644 (file)
@@ -20,6 +20,7 @@
 
 static int underlimit_flowcount_count = 0;
 static int underlimit_normal_count = 0;
+extern uint8_t system_loglevel;
 
 /**
  * Called for each identity each estimate interval.  Uses flow table information
@@ -228,8 +229,10 @@ static uint32_t allocate_fps(identity_t *ident, double total_weight) {
 
     printlog(LOG_DEBUG, "%.3f %.3f IdealUnd IdealOve\n",ideal_under,ideal_over);
 
-    printf("local_rate: %d, idealweight: %.3f, localweight: %.3f, total_weight: %.3f\n",
+    if (system_loglevel == LOG_DEBUG) {
+        printf("local_rate: %d, idealweight: %.3f, localweight: %.3f, total_weight: %.3f\n",
             local_rate, idealweight, ident->localweight, total_weight);
+    }
 
     //printf("Dampen: %d, dampen_increase: %d, peer_weights: %.3f, regime: %d\n",
     //       dampen, dampen_increase, peer_weights, regime);
@@ -260,8 +263,10 @@ static double allocate_grd(identity_t *ident, double aggdemand) {
         dropprob = 0.0;
     }
     
-    printf("local rate: %d, aggregate demand: %.3f, drop prob: %.3f\n",
+    if (system_loglevel == LOG_DEBUG) {
+        printf("local rate: %d, aggregate demand: %.3f, drop prob: %.3f\n",
            ident->common.rate, aggdemand, dropprob);
+    }
 
     return dropprob;
 }
@@ -358,7 +363,9 @@ static void enforce(limiter_t *limiter, identity_t *ident) {
                 ident->locallimit = limiter->nodelimit;
             }
 
-            printf("FPS: Setting local limit to %d\n", ident->locallimit);
+            if (system_loglevel == LOG_DEBUG) {
+                printf("FPS: Setting local limit to %d\n", ident->locallimit);
+            }
             printlog(LOG_DEBUG, "%d Limit ID:%d\n", ident->locallimit, ident->id);
 
             snprintf(cmd, CMD_BUFFER_SIZE,
index cb30657..869cde9 100644 (file)
@@ -409,9 +409,9 @@ int send_udp_mesh(comm_t *comm, uint32_t id, int sock) {
         toaddr.sin_addr.s_addr = remote->addr; /* Already in network byte order. */
         toaddr.sin_port = remote->port;
         if (sendto(sock, &msg, sizeof(msg), 0, (struct sockaddr *) &toaddr, sizeof(struct sockaddr_in)) < 0) {
-            printlog(LOG_CRITICAL, "ERR: limiter_send_mesh: sento failed.\n");
+            printlog(LOG_WARN, "WARN: limiter_send_mesh: sento failed.\n");
             result = errno;
-            printlog(LOG_CRITICAL, "  - The error was |%d|\n", strerror(result));
+            printlog(LOG_WARN, "  - The error was |%d|\n", strerror(result));
             break;
         }
     }
@@ -476,7 +476,7 @@ int send_udp_gossip(comm_t *comm, uint32_t id, int sock) {
         message_to_nbo(&msg);
 
         if (sendto(sock, &msg, sizeof(msg), 0, (struct sockaddr *) &toaddr, sizeof(struct sockaddr_in)) < 0) {
-            printlog(LOG_CRITICAL, "ERR: limiter_send_gossip: sento failed.\n");
+            printlog(LOG_WARN, "WARN: limiter_send_gossip: sento failed.\n");
             result = errno;
             break;
         }
index 4b79f3e..8ebab9d 100644 (file)
@@ -9,6 +9,7 @@
 
 #include "common_accounting.h"
 #include "samplehold.h"
+#include "logging.h"
 
 static int match(const key_flow *key, const sampled_flow *flow) {
     if (flow->state != FLOW_USED)
@@ -167,7 +168,7 @@ int sampled_table_sample(sampled_flow_table table, const key_flow *key) {
 
         if (lookup == NULL) {
             /* Table is full!?! */
-            printf("Full table!\n");
+            printlog(LOG_WARN, "samplehold.c: Table full!\n");
             return 0;
         }
 
index cadafee..099e6cd 100644 (file)
@@ -75,8 +75,7 @@ standard_flow *standard_table_lookup(standard_flow_table table, const key_flow *
     if (flow == NULL) {
         flow = malloc(sizeof(standard_flow));
         if (flow == NULL) {
-            printf("Malloc returned null.\n");
-            printlog(LOG_CRITICAL, "ALLOC: Malloc returned NULL.\n");
+            printlog(LOG_CRITICAL, "standard.c: Malloc returned NULL.\n");
             return NULL;
         }
 
@@ -267,8 +266,6 @@ void standard_table_update_flows(standard_flow_table table, struct timeval now,
     table->common->bytes_since = 0;
     table->common->last_update = now;
 
-    //printf("Flows: ");
-
     /* Update per-flow information. */
     for (current = table->flows_head; current; current = current->next) {
         time_delta = timeval_subtract(now, current->last_update);
@@ -295,8 +292,6 @@ void standard_table_update_flows(standard_flow_table table, struct timeval now,
             maxflowrate = current->rate;
         }
 
-        //printf("%d, ", current->rate);
-
         src.s_addr = ntohl(current->source_ip);
         dst.s_addr = ntohl(current->dest_ip);
         strcpy(sip, inet_ntoa(src));
@@ -307,7 +302,6 @@ void standard_table_update_flows(standard_flow_table table, struct timeval now,
                 current->rate);
     }
 
-    //printf("\n");
     printlog(LOG_DEBUG, "FLOW:--\n--\n");
 
     table->common->max_flow_rate = maxflowrate;
index ef2a17b..0d734a7 100644 (file)
@@ -896,18 +896,20 @@ static void print_instance(drl_instance_t *instance) {
     leaf_t *leaf = NULL;
     identity_t *ident = NULL;
 
-    map_reset_iterate(instance->leaf_map);
-    while ((leaf = (leaf_t *) map_next(instance->leaf_map))) {
-        printf("%x:", leaf->xid);
-        ident = leaf->parent;
-        while (ident) {
-            printf("%d:",ident->id);
-            ident = ident->parent;
+    if (system_loglevel == LOG_DEBUG) {
+        map_reset_iterate(instance->leaf_map);
+        while ((leaf = (leaf_t *) map_next(instance->leaf_map))) {
+            printf("%x:", leaf->xid);
+            ident = leaf->parent;
+            while (ident) {
+                printf("%d:",ident->id);
+                ident = ident->parent;
+            }
+            printf("Leaf's parent pointer is %p\n", leaf->parent);
         }
-        printf("Leaf's parent pointer is %p\n", leaf->parent);
-    }
 
-    printf("instance->last_machine is %p\n", instance->last_machine);
+        printf("instance->last_machine is %p\n", instance->last_machine);
+    }
 }
 
 static int assign_htb_hierarchy(drl_instance_t *instance) {
@@ -922,7 +924,7 @@ static int assign_htb_hierarchy(drl_instance_t *instance) {
         } else {
             /* Pointerific! */
             instance->machines[i]->htb_parent =
-                        instance->machines[i]->parent->htb_node;
+                instance->machines[i]->parent->htb_node;
         }
 
         instance->machines[i]->htb_node = next_node;
@@ -1120,8 +1122,7 @@ static int setup_tc_grd(drl_instance_t *instance) {
                 instance->leaves[i].xid, instance->leaves[i].xid);
 
         if (execute_cmd(cmd)) {
-            //FIXME: remove this print and do a log.
-            printf("GRD: pfifo qdisc wasn't there!\n");
+            printlog(LOG_DEBUG, "GRD: pfifo qdisc wasn't there!\n");
         }
 
         /* Add the netem qdisc. */
@@ -1142,8 +1143,7 @@ static int setup_tc_grd(drl_instance_t *instance) {
     sprintf(cmd, "/sbin/tc qdisc del dev eth0 parent 1:1000 handle 1000 pfifo");
 
     if (execute_cmd(cmd)) {
-        //FIXME: remove this print and do a log.
-        printf("GRD: pfifo qdisc wasn't there!\n");
+        printlog(LOG_DEBUG, "GRD: pfifo qdisc wasn't there!\n");
     }
 
     /* Add the netem qdisc. */
@@ -1160,8 +1160,7 @@ static int setup_tc_grd(drl_instance_t *instance) {
     sprintf(cmd, "/sbin/tc qdisc del dev eth0 parent 1:1fff handle 1fff pfifo");
 
     if (execute_cmd(cmd)) {
-        //FIXME: remove this print and do a log.
-        printf("GRD: pfifo qdisc wasn't there!\n");
+        printlog(LOG_DEBUG, "GRD: pfifo qdisc wasn't there!\n");
     }
 
     /* Add the netem qdisc. */
@@ -1525,8 +1524,7 @@ static void _drl_reg_op(void)
      * see estimate.c
      */
     if (pthread_create(&estimate_thread, NULL, (void*(*)(void*)) &handle_estimation, &limiter)!=0) {
-        ulogd_log(ULOGD_ERROR, "couldn't start estimate thread for 0x%x %s\n",limiter.localaddr,
-                limiter.ip);
+        printlog(LOG_CRITICAL, "Couldn't start estimate thread.\n");
         fprintf(stderr, "An error has occured starting ulogd_DRL.  Refer to your logfile (%s) for additional information.\n", drl_logfile.u.string);
         exit(EXIT_FAILURE);
     }
index 9f5706a..4bf3d04 100644 (file)
@@ -347,14 +347,3 @@ int my_lg(int x) {
 
     return c;
 }
-
-/* print out some error information if a system call failes */
-void print_system_error(int ret){
-    if (WIFSIGNALED(ret) &&
-            (WTERMSIG(ret) == SIGINT || WTERMSIG(ret) == SIGQUIT)){
-        /* received some kind of signal during program execution */
-        printf("enforce received signal during program execution.");
-    } else {
-        perror("enforce failed (ret==-1):");
-    }
-}
index ffe3321..9d0eaba 100644 (file)
@@ -56,8 +56,4 @@ void* map_remove(map_handle map,void *key, int keylen);
 void map_insert(map_handle map, void *key, int keylen, void *value);
 int map_size(map_handle map);
 
-/* sundry items */
-void print_system_error(int ret);
-
-
 #endif