diff --git a/src/connection.cpp b/src/connection.cpp index 0959fa2..060bb81 100644 --- a/src/connection.cpp +++ b/src/connection.cpp @@ -58,6 +58,10 @@ u_int64_t PackList::sumanddel(timeval t) { PackListNode *previous = NULL; while (current != NULL) { + if(current->is_sum == false){ + retval += current->val->len; + current->is_sum = true; + } // std::cout << "Comparing " << current->val->time.tv_sec << " <= " << // t.tv_sec - PERIOD << endl; if (current->val->time.tv_sec <= t.tv_sec - PERIOD) { @@ -68,7 +72,6 @@ u_int64_t PackList::sumanddel(timeval t) { delete current; return retval; } - retval += current->val->len; previous = current; current = current->next; } diff --git a/src/connection.h b/src/connection.h index 1d3b224..c78bd06 100644 --- a/src/connection.h +++ b/src/connection.h @@ -30,6 +30,7 @@ public: PackListNode(Packet *m_val, PackListNode *m_next = NULL) { val = m_val; next = m_next; + is_sum = false; } ~PackListNode() { delete val; @@ -38,6 +39,7 @@ public: } PackListNode *next; Packet *val; + bool is_sum; }; class PackList {