Andrew Boyson / net

Dependents:   oldheating gps motorhome heating

Revision:
78:9d8fc88df405
Parent:
75:603b10404183
Child:
79:f50e02fb5c94
diff -r 6cb7d92c37f3 -r 9d8fc88df405 tcp/tcpsend.c
--- a/tcp/tcpsend.c	Wed Oct 31 20:22:01 2018 +0000
+++ b/tcp/tcpsend.c	Mon Nov 05 19:27:19 2018 +0000
@@ -170,8 +170,18 @@
 }
 int TcpPollForPacketToSend(int* pSize, void* pPacket, int ipType, int* pRemArIndex)
 {
-    struct tcb* pTcb = TcbGetNext(); //This loops around the TCBs
+     //This loops around the TCBs
+     //struct tcb* pTcb = TcbGetOld();
+     static struct tcb* pTcb = NULL; //Passing a pointer containing NULL to TcbGetNext causes it to return the first TCB
+     TcbGetNext(&pTcb);
+    
+    //Ignore empty TCBs
+    if (!pTcb->state) return DO_NOTHING;
+    
+    //Ignore TCBs of a different IP type
     if (pTcb->ipType != ipType) return DO_NOTHING;
+    
+    //Return the remote AR index
     *pRemArIndex = pTcb->remArIndex;
     
     //Check if have unacknowledged bytes longer than a time out