]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_TCP_WIN.c
Fix some build issues in older kernel demo projects.
[freertos] / FreeRTOS-Plus / Source / FreeRTOS-Plus-TCP / FreeRTOS_TCP_WIN.c
index a73cc5dcaf2a459f8e348996a1f3f98ffc1de742..11dc00f01db16e1fd862361444c1a403aaf289ad 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- * FreeRTOS+TCP V2.0.0\r
+ * FreeRTOS+TCP V2.0.7\r
  * Copyright (C) 2017 Amazon.com, Inc. or its affiliates.  All Rights Reserved.\r
  *\r
  * Permission is hereby granted, free of charge, to any person obtaining a copy of\r
@@ -10,8 +10,7 @@
  * subject to the following conditions:\r
  *\r
  * The above copyright notice and this permission notice shall be included in all\r
- * copies or substantial portions of the Software. If you wish to use our Amazon\r
- * FreeRTOS name, please do so in a fair use way that does not cause confusion.\r
+ * copies or substantial portions of the Software.\r
  *\r
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
  *\r
- * http://www.FreeRTOS.org\r
  * http://aws.amazon.com/freertos\r
- *\r
- * 1 tab == 4 spaces!\r
+ * http://www.FreeRTOS.org\r
  */\r
 \r
 /*\r
@@ -295,7 +292,7 @@ void vListInsertGeneric( List_t * const pxList, ListItem_t * const pxNewListItem
        pxWhere->pxPrevious = pxNewListItem;\r
 \r
        /* Remember which list the item is in. */\r
-       pxNewListItem->pvContainer = ( void * ) pxList;\r
+       pxNewListItem->pvContainer = ( void * ) pxList; /* If this line fails to build then ensure configENABLE_BACKWARD_COMPATIBILITY is set to 1 in FreeRTOSConfig.h. */\r
 \r
        ( pxList->uxNumberOfItems )++;\r
 }\r
@@ -600,12 +597,12 @@ void vTCPWindowCreate( TCPWindow_t *pxWindow, uint32_t ulRxWindowLength,
                        prvCreateSectors();\r
                }\r
 \r
-               vListInitialise( &( pxWindow->xTxSegments ) );\r
-               vListInitialise( &( pxWindow->xRxSegments ) );\r
+               vListInitialise( &pxWindow->xTxSegments );\r
+               vListInitialise( &pxWindow->xRxSegments );\r
 \r
-               vListInitialise( &( pxWindow->xPriorityQueue ) );       /* Priority queue: segments which must be sent immediately */\r
-               vListInitialise( &( pxWindow->xTxQueue ) );                     /* Transmit queue: segments queued for transmission */\r
-               vListInitialise( &( pxWindow->xWaitQueue ) );           /* Waiting queue:  outstanding segments */\r
+               vListInitialise( &pxWindow->xPriorityQueue );                   /* Priority queue: segments which must be sent immediately */\r
+               vListInitialise( &pxWindow->xTxQueue   );                       /* Transmit queue: segments queued for transmission */\r
+               vListInitialise( &pxWindow->xWaitQueue );                       /* Waiting queue:  outstanding segments */\r
        }\r
        #endif /* ipconfigUSE_TCP_WIN == 1 */\r
 \r
@@ -791,16 +788,20 @@ const int32_t l500ms = 500;
                                {\r
                                        ulSavedSequenceNumber = ulCurrentSequenceNumber;\r
 \r
-                                       /* See if (part of) this segment has been stored already,\r
-                                       but this rarely happens. */\r
-                                       pxFound = xTCPWindowRxConfirm( pxWindow, ulSequenceNumber, ulLength );\r
-                                       if( pxFound != NULL )\r
-                                       {\r
-                                               ulCurrentSequenceNumber = pxFound->ulSequenceNumber + ( ( uint32_t ) pxFound->lDataLength );\r
-\r
-                                               /* Remove it because it will be passed to user directly. */\r
-                                               vTCPWindowFree( pxFound );\r
-                                       }\r
+                    /* Clean up all sequence received between ulSequenceNumber and ulSequenceNumber + ulLength since they are duplicated.\r
+                    If the server is forced to retransmit packets several time in a row it might send a batch of concatenated packet for speed.\r
+                    So we cannot rely on the packets between ulSequenceNumber and ulSequenceNumber + ulLength to be sequential and it is better to just\r
+                    clean them out. */\r
+                    do\r
+                    {\r
+                        pxFound = xTCPWindowRxConfirm( pxWindow, ulSequenceNumber, ulLength );\r
+\r
+                        if ( pxFound != NULL )\r
+                        {\r
+                            /* Remove it because it will be passed to user directly. */\r
+                            vTCPWindowFree( pxFound );\r
+                        }\r
+                    } while ( pxFound );\r
 \r
                                        /*  Check for following segments that are already in the\r
                                        queue and increment ulCurrentSequenceNumber. */\r