Modification to work two socket servers at the same time

Fork of lwip by mbed official

Revision:
4:f71f5d9d5846
Parent:
0:51ac1d130fd4
--- a/netif/ppp/ppp.c	Fri Jun 22 13:39:39 2012 +0000
+++ b/netif/ppp/ppp.c	Fri Jun 22 15:08:59 2012 +0000
@@ -249,7 +249,9 @@
 /******************************/
 u_long subnetMask;
 
-static PPPControl pppControl[NUM_PPP]; /* The PPP interface control blocks. */
+static PPPControl pppControl[NUM_PPP] __attribute((section("AHBSRAM1"))); /* The PPP interface control blocks. */
+
+sys_mbox_t pppMbox; //Used to signal PPP thread that a PPP session begins
 
 /*
  * PPP Data Link Layer "protocol" table.
@@ -279,7 +281,7 @@
  * Buffers for outgoing packets.  This must be accessed only from the appropriate
  * PPP task so that it doesn't need to be protected to avoid collisions.
  */
-u_char outpacket_buf[NUM_PPP][PPP_MRU+PPP_HDRLEN];
+u_char outpacket_buf[NUM_PPP][PPP_MRU+PPP_HDRLEN] __attribute((section("AHBSRAM1")));
 
 
 /*****************************/
@@ -448,6 +450,9 @@
       (*protp->init)(i);
     }
   }
+
+  sys_mbox_new(&pppMbox, 1);
+  sys_thread_new(PPP_THREAD_NAME, pppInputThread, (void*)NULL, PPP_THREAD_STACKSIZE, PPP_THREAD_PRIO); //Create PPP thread here
 }
 
 void
@@ -573,7 +578,7 @@
     PPPDEBUG(LOG_INFO, ("pppOverSerialOpen: unit %d: Connecting\n", pd));
     pppStart(pd);
 #if PPP_INPROC_OWNTHREAD
-    sys_thread_new(PPP_THREAD_NAME, pppInputThread, (void*)&pc->rx, PPP_THREAD_STACKSIZE, PPP_THREAD_PRIO);
+    sys_mbox_post(&pppMbox, (void*)&pc->rx);
 #endif
   }
 
@@ -1508,6 +1513,10 @@
   int count;
   PPPControlRx *pcrx = arg;
 
+  do
+  {
+  sys_arch_mbox_fetch(&pppMbox, (void**)&pcrx, 0); //Wait indefinitely
+
   while (lcp_phase[pcrx->pd] != PHASE_DEAD) {
     count = sio_read(pcrx->fd, pcrx->rxbuf, PPPOS_RX_BUFSIZE);
     if(count > 0) {
@@ -1517,6 +1526,7 @@
       sys_msleep(1);
     }
   }
+  } while(1); //Never terminates
 }
 #endif /* PPPOS_SUPPORT && PPP_INPROC_OWNTHREAD */