This is the mail archive of the ecos-patches@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [ECOS] EcosCentric PPP Stack blocking problem


"Retallack, Mark (Siemens)" <mark.retallack@siemens.com> writes:

> I think have found a problem with the new ecoscentric ppp stack. The
> wait_input function sometimes blocks even if a packet is available for
> processing in the tty queue. 
> 
> If more than one packet is waiting in the serial driver, then one call to
> wait_input can place more than one packet on to the tty queue. This will
> cause wait_input to exit and enter get_input where only one packet is read
> from the queue and processed. After that has finished wait_input is entered
> again, and if no data is waiting in the serial driver, it will block until
> more data is received or a timeout.
> 
> I have attached a patch to make wait_input check if there is data in the
> 'tty' queue before checking the serial driver. This stops it blocking until
> there is no packets available. 
> 

This looks reasonable. I've committed a slightly tidied up version:


Index: net/ppp/current/ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/ppp/current/ChangeLog,v
retrieving revision 1.4
diff -u -5 -r1.4 ChangeLog
--- net/ppp/current/ChangeLog	6 May 2004 13:54:56 -0000	1.4
+++ net/ppp/current/ChangeLog	6 May 2004 14:33:11 -0000
@@ -1,5 +1,14 @@
+2004-05-06  Mark Retallack <mark.retallack@siemens.com>
+
+	* src/ppp_io.c: 
+	* src/sys-ecos.c: 	
+	* src/ppp_io.h:	
+	The wait_input function sometimes blocked even if a packet was
+	available for processing. Now checks the tty queue and then the 
+	serial driver before blocking.
+
 2004-05-06  Jonathan Larmour  <jifl@eCosCentric.com>
 
 	* src/auth.c: Don't use non-eCos <paths.h>
 	* src/pppd.c: Don't use non-eCos <sys/wait.h> and <sys/resource.h>
 	* src/sys-ecos.c: netmask must be extern - not all tools have
Index: net/ppp/current/include/ppp_io.h
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/ppp/current/include/ppp_io.h,v
retrieving revision 1.2
diff -u -5 -r1.2 ppp_io.h
--- net/ppp/current/include/ppp_io.h	17 Apr 2004 03:13:06 -0000	1.2
+++ net/ppp/current/include/ppp_io.h	6 May 2004 14:33:13 -0000
@@ -144,10 +144,12 @@
 
 extern int	cyg_ppp_pppread __P((struct tty *tp, struct uio *uio, int flag));
 
 extern int	cyg_ppp_pppclose __P((struct tty *tp, int flag));
 
+extern int	cyg_ppp_pppcheck __P((struct tty *tp));
+
 // ====================================================================
 // Start PPP transmission. This is called from the TX thread to cause
 // any pending packets to be sent.
 
 extern int	cyg_ppp_pppstart __P((struct tty *tp));
Index: net/ppp/current/src/ppp_io.c
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/ppp/current/src/ppp_io.c,v
retrieving revision 1.2
diff -u -5 -r1.2 ppp_io.c
--- net/ppp/current/src/ppp_io.c	17 Apr 2004 03:13:06 -0000	1.2
+++ net/ppp/current/src/ppp_io.c	6 May 2004 14:33:30 -0000
@@ -289,10 +289,47 @@
 register struct ppp_softc *sc;
 {
     db_printf("%s called\n", __PRETTY_FUNCTION__);
 }
 
+
+
+//==========================================================================
+/*
+ * function to check if data is available
+ */
+ 
+int
+cyg_ppp_pppcheck(tp)
+    register struct tty *tp;
+{
+    register struct ppp_softc *sc = (struct ppp_softc *)tp->t_sc;	
+    int status = 0;  
+    register int s;    
+	
+    s = spltty();
+
+    if (tp != (struct tty *) sc->sc_devp ) {
+        splx(s);
+        return 0;
+    }
+    if (sc->sc_inq.ifq_head == NULL)
+    {
+        splx(s);
+        return 0;
+    }	
+	
+    // if the queue is not empty
+    if ( IF_IS_EMPTY(&sc->sc_inq) == false)
+        status = 1;
+	
+    splx(s);
+
+    return(status);
+}
+
+
 //==========================================================================
 /*
  * Line specific (tty) read routine.
  * called at zero spl from the device driver in the response to user-level
  * reads on the tty file descriptor (ie: pppd).
Index: net/ppp/current/src/sys-ecos.c
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/ppp/current/src/sys-ecos.c,v
retrieving revision 1.3
diff -u -5 -r1.3 sys-ecos.c
--- net/ppp/current/src/sys-ecos.c	6 May 2004 13:54:57 -0000	1.3
+++ net/ppp/current/src/sys-ecos.c	6 May 2004 14:33:43 -0000
@@ -591,10 +591,15 @@
  */
 void
 wait_input(timo)
     struct timeval *timo;
 {
+    // If there are any packets still waiting on the input queue then
+    // return immediately to let the PPPD handle them.
+    if (cyg_ppp_pppcheck(&ppp_tty) != 0)
+        return;
+
     if( timo != NULL )
     {
         cyg_tick_count_t trigger = timo->tv_sec*ppp_rtc_resolution.divisor;
 
         // If the timeval has a microseconds value, just add another


-- 
Nick Garnett                    eCos Kernel Architect
http://www.ecoscentric.com      The eCos and RedBoot experts


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]