Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of lwip by
Revision 16:a61070aa2e98, committed 2014-04-10
- Comitter:
- donatien
- Date:
- Thu Apr 10 17:37:32 2014 +0000
- Parent:
- 15:e5bb25d5506f
- Commit message:
- Fixed race condition in PPP
Changed in this revision
| netif/ppp/ppp.c | Show annotated file Show diff for this revision Revisions of this file |
--- a/netif/ppp/ppp.c Wed Mar 12 20:22:30 2014 +0000
+++ b/netif/ppp/ppp.c Thu Apr 10 17:37:32 2014 +0000
@@ -252,6 +252,7 @@
static PPPControl pppControl[NUM_PPP] __attribute((section("AHBSRAM1"))); /* The PPP interface control blocks. */
+static sys_mutex_t pppMtx; //Used to prevent concurrent access from user thread (pppStop) and input thread (pppInproc)
static sys_mbox_t pppMboxStart; //Used to signal PPP thread that a PPP session begins
static sys_mbox_t pppMboxStopped; //Used to signal remote thread that a PPP session has stopped
@@ -449,6 +450,7 @@
subnetMask = PP_HTONL(0xffffff00UL);
+ sys_mutex_new(&pppMtx);
sys_mbox_new(&pppMboxStart, 1);
sys_mbox_new(&pppMboxStopped, 1);
@@ -662,7 +664,9 @@
int st = 0;
PPPDEBUG(LOG_DEBUG, ("pppClose() called\n"));
-
+
+ sys_mutex_lock(&pppMtx);
+
/* Disconnect */
#if PPPOE_SUPPORT
if(pc->ethif) {
@@ -681,6 +685,8 @@
pppRecvWakeup(pd);
#endif /* PPPOS_SUPPORT */
}
+
+ sys_mutex_unlock(&pppMtx);
void* pcrx;
sys_arch_mbox_fetch(&pppMboxStopped, (void**)&pcrx, 0); //Wait indefinitely for link to become dead
@@ -1525,7 +1531,9 @@
while (lcp_phase[pcrx->pd] != PHASE_DEAD) {
count = sio_read(pcrx->fd, pcrx->rxbuf, PPPOS_RX_BUFSIZE);
if(count > 0) {
+ sys_mutex_lock(&pppMtx);
pppInProc(pcrx, pcrx->rxbuf, count);
+ sys_mutex_unlock(&pppMtx);
} else {
/* nothing received, give other tasks a chance to run */
sys_msleep(1);
