Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[linux-dvb] Possible race condition in tuning



I believe there is a possible race condition in dvb.c's 'mon_tune()'
function.

The function first sets dvb->mon_tuning=2, which triggers mon_zigzag()
to do its zig-zag tuning, and then sets dvb->mon_fstate=1. If the scheduler
switches tasks just after the dvb->mon_tuning=2 and before the dvb->mon_fstate=1,
and if the previous call to mon_zigzag() counted the dvb->mon_fstate all the way
up to 20, mon_zigzag() may fail immediately, instead of doing a zig-zag search.

Therefore I suggest switching the sequence of these two assignments, as shown in
the following diff.

Klaus

--- dvb.c.001   Thu Jul 26 18:12:20 2001
+++ dvb.c       Fri Jul 27 15:16:31 2001
@@ -2549,8 +2549,9 @@
                 mdelay(10);
                 if (fe_lock(dvb))
                         return mon_complete(dvb);
-                dvb->mon_tuning=2;
+                //XXX
                 dvb->mon_fstate=1;
+                dvb->mon_tuning=2;
                 dvb->mon_delay=HZ/10;
                 dvb->front.curfreq=dvb->front.freq;
                 return 0;
@@ -2568,8 +2569,9 @@
                 mdelay(30);
                 if (fe_lock(dvb))
                         return mon_complete(dvb);
+                //XXX
+                dvb->mon_fstate=0; //XXX why '0' with cable and '1' with sat???
                 dvb->mon_tuning=2;
-                dvb->mon_fstate=0;
                 dvb->mon_delay=HZ/2;
                 dvb->front.curfreq=dvb->front.freq;
                 return 0;

-- 
_______________________________________________________________

Klaus Schmidinger                       Phone: +49-8635-6989-10
CadSoft Computer GmbH                   Fax:   +49-8635-6989-40
Hofmark 2                               Email:   kls@cadsoft.de
D-84568 Pleiskirchen, Germany           URL:     www.cadsoft.de
_______________________________________________________________


-- 
Info:
To unsubscribe send a mail to listar@linuxtv.org with "unsubscribe linux-dvb" as subject.



Home | Main Index | Thread Index