MPPP: Fix discarding algorithm
authorBenjamin Cama <benoar@dolka.fr>
Thu, 26 Jan 2012 22:44:14 +0000 (23:44 +0100)
committerBenjamin Cama <benoar@dolka.fr>
Thu, 26 Jan 2012 22:44:14 +0000 (23:44 +0100)
ppp.c

diff --git a/ppp.c b/ppp.c
index 036292a..afbffd8 100644 (file)
--- a/ppp.c
+++ b/ppp.c
@@ -2012,7 +2012,7 @@ discard_lost_frames:
                uint16_t index = M_index;
                uint8_t end_or_hole_found = 0;
 
-               for (;;)
+               while (index != this_fragmentation->start_index)
                {
                        fragmentt *this_frag;
 
@@ -2022,17 +2022,23 @@ discard_lost_frames:
 
                                // before a MP_BEGIN, there must be a MP_END
                                if (front_frag->length && (front_frag->flags & MP_BEGIN))
+                               {
                                        end_or_hole_found = 1;
+                                       end_index = index;
+                               }
+                       }
 
-                               index = (index + (MAXFRAGNUM-1)) & MAXFRAGNUM_MASK;
-                               this_frag = &this_fragmentation->frag[index];
+                       index = (index + (MAXFRAGNUM-1)) & MAXFRAGNUM_MASK;
+                       this_frag = &this_fragmentation->frag[index];
 
+                       if (!end_or_hole_found)
+                       {
                                // we are a hole or a MP_END
                                if (!this_frag->length || (this_frag->flags & MP_END))
+                               {
                                        end_or_hole_found = 1;
-
-                               if (end_or_hole_found)
                                        end_index = index;
+                               }
                        }
 
                        if (end_or_hole_found)
@@ -2040,9 +2046,6 @@ discard_lost_frames:
                                this_frag->flags = 0;
                                this_frag->length = 0;
                        }
-
-                       if (index == this_fragmentation->start_index)
-                               break;
                }
 
                this_fragmentation->start_index = (end_index + 1) & MAXFRAGNUM_MASK;