changeset 2251:e711597543e5

* src/sys-ecos.c (cyg_ppp_up): Bring semaphore init earlier to avoid race condition if pppd thread is higher priority than the current thread.
author jlarmour
date Tue, 18 Jul 2006 17:24:56 +0000
parents 0830ae6acddc
children 528ad6cc97bf
files packages/net/ppp/current/ChangeLog packages/net/ppp/current/src/sys-ecos.c
diffstat 2 files changed, 10 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/packages/net/ppp/current/ChangeLog
+++ b/packages/net/ppp/current/ChangeLog
@@ -1,3 +1,9 @@
+2006-07-18  John Paul King  <john.king@transdatainc.com>
+
+	* src/sys-ecos.c (cyg_ppp_up): Bring semaphore init earlier to avoid
+	race condition if pppd thread is higher priority than the current
+	thread.
+
 2005-11-23  Andrew Lunn  <andrew.lunn@ascom.ch>
 
 	* cdl/ppp.cdl: Require CYGPKG_POSIX_CLOCKS not *_TIMERS
--- a/packages/net/ppp/current/src/sys-ecos.c
+++ b/packages/net/ppp/current/src/sys-ecos.c
@@ -558,7 +558,7 @@ static void cyg_ppp_tx_thread(CYG_ADDRWO
 
     // Wait for the PPPD thread to get going and start the PPP
     // initialization phase.
-    while(phase == PHASE_DEAD )
+    while(phase == PHASE_DEAD)
         cyg_thread_delay(100);
 
     // Now loop until the link goes back down.
@@ -1702,6 +1702,8 @@ externC cyg_ppp_handle_t cyg_ppp_up( con
 
     ppp_tty.options = options;
 
+    cyg_semaphore_init( &ppp_tty.tx_sem,  0 );
+
     // Start the PPPD thread
     cyg_thread_create(CYGNUM_PPP_PPPD_THREAD_PRIORITY,
                       cyg_pppd_main,
@@ -1715,8 +1717,6 @@ externC cyg_ppp_handle_t cyg_ppp_up( con
     cyg_thread_resume(ppp_tty.pppd_thread);
 
     // Start the TX thread
-    cyg_semaphore_init( &ppp_tty.tx_sem,  0 );
-    
     cyg_thread_create(CYGNUM_PPP_PPPD_THREAD_PRIORITY+1,
                       cyg_ppp_tx_thread,
                       (CYG_ADDRWORD)&ppp_tty,
@@ -1730,7 +1730,7 @@ externC cyg_ppp_handle_t cyg_ppp_up( con
 
     // Wait for the PPPD thread to get going and start the PPP
     // initialization phase.
-    while(phase == PHASE_DEAD )
+    while(phase == PHASE_DEAD)
         cyg_thread_delay(100);
     
     return (cyg_ppp_handle_t)&ppp_tty;