From 52f700f18c9cfd0ed5370602c37473bda3a12baa Mon Sep 17 00:00:00 2001 From: "kibak.yoon" Date: Thu, 19 May 2016 16:11:49 +0900 Subject: [PATCH] sensord: terminate sensord if there is no sensor Change-Id: Ib4d2fe95691662fa8d750493b0c80067eaddd764 Signed-off-by: kibak.yoon --- src/server/main.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/server/main.cpp b/src/server/main.cpp index b136d69..d19c744 100644 --- a/src/server/main.cpp +++ b/src/server/main.cpp @@ -26,6 +26,8 @@ #define CAL_NODE_PATH "/sys/class/sensors/ssp_sensor/set_cal_data" #define SET_CAL 1 +#define TIMEOUT 10 + static void sig_term_handler(int signo, siginfo_t *info, void *data) { char proc_name[NAME_MAX]; @@ -73,6 +75,18 @@ static void set_cal_data(void) return; } +static gboolean terminate(gpointer data) +{ + std::vector sensors = sensor_loader::get_instance().get_sensors(ALL_SENSOR); + + if (sensors.size() == 0) { + _I("Terminating sensord.."); + server::get_instance().stop(); + } + + return FALSE; +} + int main(int argc, char *argv[]) { _I("Sensord started"); @@ -81,8 +95,9 @@ int main(int argc, char *argv[]) set_cal_data(); - /* TODO: loader has to be moved to server */ + /* TODO: loading sequence has to be moved to server */ sensor_loader::get_instance().load(); + g_timeout_add_seconds(TIMEOUT, terminate, NULL); server::get_instance().run(); server::get_instance().stop(); -- 2.7.4