From f25e25114ab2ef7e3019bfe4ff9b65ff93c41b90 Mon Sep 17 00:00:00 2001 From: Tadao Tanikawa Date: Thu, 19 Jul 2018 11:56:51 +0000 Subject: Fix timer In 32bit environment, timer would be overflow. This causes that HomeScreen doesn't show on 32bit environment. Bug-AGL: SPEC-1471 Change-Id: I427da3a6e6ea76af05cee45a13b51754728a0cc5 Signed-off-by: Tadao Tanikawa --- src/window_manager.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/window_manager.cpp b/src/window_manager.cpp index eadf7ff..5b86af8 100644 --- a/src/window_manager.cpp +++ b/src/window_manager.cpp @@ -30,7 +30,7 @@ extern "C" namespace wm { -static const unsigned kTimeOut = 3000000UL; /* 3s */ +static const uint64_t kTimeOut = 3ULL; /* 3s */ /* DrawingArea name used by "{layout}.{area}" */ const char kNameLayoutNormal[] = "normal"; @@ -1452,12 +1452,18 @@ void WindowManager::emitScreenUpdated(unsigned req_num) void WindowManager::setTimer() { + struct timespec ts; + if (clock_gettime(CLOCK_BOOTTIME, &ts) != 0) { + HMI_ERROR("wm", "Could't set time (clock_gettime() returns with error"); + return; + } + HMI_SEQ_DEBUG(g_app_list.currentRequestNumber(), "Timer set activate"); if (g_timer_ev_src == nullptr) { // firsttime set into sd_event int ret = sd_event_add_time(afb_daemon_get_event_loop(), &g_timer_ev_src, - CLOCK_REALTIME, time(NULL) * (1000000UL) + kTimeOut, 1, processTimerHandler, this); + CLOCK_BOOTTIME, (uint64_t)(ts.tv_sec + kTimeOut) * 1000000ULL, 1, processTimerHandler, this); if (ret < 0) { HMI_ERROR("wm", "Could't set timer"); @@ -1466,7 +1472,7 @@ void WindowManager::setTimer() else { // update timer limitation after second time - sd_event_source_set_time(g_timer_ev_src, time(NULL) * (1000000UL) + kTimeOut); + sd_event_source_set_time(g_timer_ev_src, (uint64_t)(ts.tv_sec + kTimeOut) * 1000000ULL); sd_event_source_set_enabled(g_timer_ev_src, SD_EVENT_ONESHOT); } } -- cgit 1.2.3-korg