mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-27 07:23:09 +02:00
CTimeThread: sectionsd.cpp: use thread save localtime_r
This commit is contained in:
@@ -37,7 +37,7 @@
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include <time.h>
|
||||
#include <connection/basicsocket.h>
|
||||
#include <connection/basicserver.h>
|
||||
|
||||
@@ -1370,12 +1370,12 @@ void CTimeThread::waitForTimeset(void)
|
||||
void CTimeThread::setSystemTime(time_t tim)
|
||||
{
|
||||
struct timeval tv;
|
||||
|
||||
struct tm t;
|
||||
time_t now = time(NULL);
|
||||
struct tm *tmTime = localtime(&now);
|
||||
struct tm *tmTime = localtime_r(&now, &t);
|
||||
|
||||
gettimeofday(&tv, NULL);
|
||||
timediff = (int64_t)tim * (int64_t)1000000 - (tv.tv_usec + tv.tv_sec * (int64_t)1000000);
|
||||
timediff = int64_t(tim * 1000000 - (tv.tv_usec + tv.tv_sec * 1000000));
|
||||
|
||||
xprintf("%s: timediff %" PRId64 ", current: %02d.%02d.%04d %02d:%02d:%02d, dvb: %s", name.c_str(), timediff,
|
||||
tmTime->tm_mday, tmTime->tm_mon+1, tmTime->tm_year+1900,
|
||||
@@ -1392,8 +1392,8 @@ void CTimeThread::setSystemTime(time_t tim)
|
||||
return;
|
||||
if (timeset && abs(tim - tv.tv_sec) < 120) { /* abs() is int */
|
||||
struct timeval oldd;
|
||||
tv.tv_sec = timediff / 1000000LL;
|
||||
tv.tv_usec = timediff % 1000000LL;
|
||||
tv.tv_sec = time_t(timediff / 1000000LL);
|
||||
tv.tv_usec = suseconds_t(timediff % 1000000LL);
|
||||
if (adjtime(&tv, &oldd))
|
||||
xprintf("adjtime(%d, %d) failed: %m\n", (int)tv.tv_sec, (int)tv.tv_usec);
|
||||
else {
|
||||
|
Reference in New Issue
Block a user