Mailing List archive

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

[vdr] Re: Log of Timer Bug



I believe I found what's causing the recent problems with timers
hitting at unexpected times.

Apparently the library function localtime() is not thread safe.
Since VDR uses this function in the foreground thread as well as
in background threads, we need to make sure that there is no
interference. Luckily, there is a thread safe version of this function,
named localtime_r().

At the moment it is a little hard for me to provide a patch for this,
because I'm in the middle of several changes. But the necessary
modifications are pretty straightforward (and for those who have applied
some or all of the other patches out there, doing this one manually
might be the best way, anyway).

Edit the files

config.c
eit.c
recording.c
tools.c

and locate every occurence of a call to localtime().

Insert the line

  struct tm tm_r;

before these calls and change the name

  localtime

to

  localtime_r

Finally add the second parameter '&tm_r' to the localtime_r() call.
For instance, the line

  struct tm *now = localtime(&t);

would become

  struct tm tm_r;
  struct tm *now = localtime_r(&t, &tm_r);

Note that in the cTimer::cTimer(const cEventInfo *EventInfo) function there
are _two_ calls to localtime. You only need to define 'struct tm tm_r;' _once_
and can use the variable in both calls there.

Hope this helps.
If anybody still encounters timers that don't work as expected,
please let me know.

Klaus
-- 
_______________________________________________________________

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
_______________________________________________________________



Home | Main Index | Thread Index