Added a check to see if the sending rate is within 1% of the limit rather than
[distributedratelimiting.git] / drl / standard.c
index cadafee..93cb663 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;
         }
 
@@ -170,7 +169,10 @@ void standard_table_remove(standard_flow_table table, standard_flow *flow) {
             }
         }
 
-        assert(current != NULL);
+        //assert(current != NULL);
+        if (current == NULL) {
+            printlog(LOG_WARN, "Flow %p disappeared?\n", current);
+        }
     }
 
     /* Remove the flow from the linked list. */
@@ -267,8 +269,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 +295,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 +305,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;