diff options
author | Sung-jae Park <nicesj.park@samsung.com> | 2013-09-26 10:50:08 +0900 |
---|---|---|
committer | Sung-jae Park <nicesj.park@samsung.com> | 2013-09-26 10:50:08 +0900 |
commit | 91d6529ccef84f3f63634898afc45307a610bc35 (patch) | |
tree | cd0d77fbe02dd184edb118fcc25446eea5c0ba5f | |
parent | 21607ac560ba3d0965503b15dab6f426d2d9f45e (diff) | |
download | data-provider-master-91d6529ccef84f3f63634898afc45307a610bc35.tar.gz data-provider-master-91d6529ccef84f3f63634898afc45307a610bc35.tar.bz2 data-provider-master-91d6529ccef84f3f63634898afc45307a610bc35.zip |
Replace gettimeofday with ecore_time_get
Change-Id: I42075e0f216e525c5f7def389246ef0bead558d9
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | include/event.h | 4 | ||||
-rw-r--r-- | packaging/data-provider-master.spec | 2 | ||||
-rw-r--r-- | src/event.c | 27 | ||||
-rw-r--r-- | src/instance.c | 6 | ||||
-rw-r--r-- | src/slave_life.c | 35 | ||||
-rw-r--r-- | src/util.c | 14 |
7 files changed, 85 insertions, 5 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 60e28df..d9e79d4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,6 +65,8 @@ ADD_DEFINITIONS("-DBADGE_SMACK_LABEL=\"data-provider-master::badge\"") ADD_DEFINITIONS("-DDEFAULT_MASTER_CONF=\"/usr/share/data-provider-master/conf.ini\"") ADD_DEFINITIONS("-DNDEBUG") + +ADD_DEFINITIONS("-D_USE_ECORE_TIME_GET") #ADD_DEFINITIONS("-DFLOG") ADD_DEFINITIONS(${pkg_CFLAGS}) ADD_DEFINITIONS(${pkg_LDFLAGS}) diff --git a/include/event.h b/include/event.h index 5d554d0..acc5bdc 100644 --- a/include/event.h +++ b/include/event.h @@ -28,7 +28,11 @@ struct event_data { int minor; } width; int distance; /* Hovering */ +#if defined(_USE_ECORE_TIME_GET) + double tv; +#else struct timeval tv; +#endif }; enum event_state { diff --git a/packaging/data-provider-master.spec b/packaging/data-provider-master.spec index fe2df9f..18d8de2 100644 --- a/packaging/data-provider-master.spec +++ b/packaging/data-provider-master.spec @@ -1,6 +1,6 @@ Name: data-provider-master Summary: Master service provider for liveboxes. -Version: 0.25.14 +Version: 0.25.15 Release: 1 Group: HomeTF/Livebox License: Flora License diff --git a/src/event.c b/src/event.c index 37ea6a6..0802ea0 100644 --- a/src/event.c +++ b/src/event.c @@ -83,7 +83,11 @@ struct event_listener { enum event_state state; +#if defined(_USE_ECORE_TIME_GET) + double tv; +#else struct timeval tv; /* Recording Activate / Deactivate time */ +#endif int x; /* RelX */ int y; /* RelY */ }; @@ -132,9 +136,13 @@ static inline int processing_input_event(struct input_event *event) if (item) { char event_ch = EVENT_CH; +#if defined(_USE_ECORE_TIME_GET) + s_info.event_data.tv = ecore_time_get(); +#else if (gettimeofday(&s_info.event_data.tv, NULL) < 0) { ErrPrint("gettimeofday: %s\n", strerror(errno)); } +#endif memcpy(item, &s_info.event_data, sizeof(*item)); @@ -376,21 +384,36 @@ static Eina_Bool event_read_cb(void *data, Ecore_Fd_Handler *handler) EINA_LIST_FOREACH_SAFE(s_info.event_listener_list, l, n, listener) { switch (listener->state) { case EVENT_STATE_ACTIVATE: +#if defined(_USE_ECORE_TIME_GET) + if (listener->tv > item->tv) { + continue; + } +#else if (timercmp(&listener->tv, &item->tv, >)) { /* Ignore previous events before activating this listener */ continue; } +#endif next_state = EVENT_STATE_ACTIVATED; cur_state = listener->state; break; case EVENT_STATE_DEACTIVATE: +#if defined(_USE_ECORE_TIME_GET) + if (listener->tv > item->tv) { + /* Consuming all events occurred while activating this listener */ + cur_state = EVENT_STATE_ACTIVATED; + next_state = EVENT_STATE_ACTIVATED; + break; + } +#else if (timercmp(&listener->tv, &item->tv, >)) { /* Consuming all events occurred while activating this listener */ cur_state = EVENT_STATE_ACTIVATED; next_state = EVENT_STATE_ACTIVATED; break; } +#endif cur_state = listener->state; next_state = EVENT_STATE_DEACTIVATED; @@ -536,11 +559,15 @@ HAPI int event_activate(int x, int y, int (*event_cb)(enum event_state state, st return LB_STATUS_ERROR_MEMORY; } +#if defined(_USE_ECORE_TIME_GET) + listener->tv = ecore_time_get(); +#else if (gettimeofday(&listener->tv, NULL) < 0) { ErrPrint("gettimeofday: %s\n", strerror(errno)); DbgFree(listener); return LB_STATUS_ERROR_FAULT; } +#endif listener->event_cb = event_cb; listener->cbdata = data; diff --git a/src/instance.c b/src/instance.c index 0afe99b..beaa65b 100644 --- a/src/instance.c +++ b/src/instance.c @@ -183,19 +183,23 @@ static inline void timer_thaw(struct inst_info *inst) static inline void timer_freeze(struct inst_info *inst) { - struct timeval tv; ecore_timer_freeze(inst->update_timer); if (ecore_timer_interval_get(inst->update_timer) <= 1.0f) { return; } +#if defined(_USE_ECORE_TIME_GET) + inst->sleep_at = ecore_time_get(); +#else + struct timeval tv; if (gettimeofday(&tv, NULL) < 0) { ErrPrint("gettimeofday: %s\n", strerror(errno)); tv.tv_sec = 0; tv.tv_usec = 0; } inst->sleep_at = (double)tv.tv_sec + (double)tv.tv_usec / 1000000.0f; +#endif } diff --git a/src/slave_life.c b/src/slave_life.c index 383c8cc..781aefd 100644 --- a/src/slave_life.c +++ b/src/slave_life.c @@ -80,7 +80,11 @@ struct slave_node { Ecore_Timer *relaunch_timer; /* Try to relaunch service app */ int relaunch_count; +#if defined(_USE_ECORE_TIME_GET) + double activated_at; +#else struct timeval activated_at; +#endif }; struct event { @@ -673,11 +677,15 @@ HAPI int slave_activated(struct slave_node *slave) slave_set_reactivation(slave, 0); slave_set_reactivate_instances(slave, 0); +#if defined(_USE_ECORE_TIME_GET) + slave->activated_at = ecore_time_get(); +#else if (gettimeofday(&slave->activated_at, NULL) < 0) { ErrPrint("Failed to get time of day: %s\n", strerror(errno)); slave->activated_at.tv_sec = 0; slave->activated_at.tv_usec = 0; } +#endif if (slave->activate_timer) { ecore_timer_del(slave->activate_timer); @@ -803,7 +811,6 @@ HAPI struct slave_node *slave_deactivated(struct slave_node *slave) HAPI struct slave_node *slave_deactivated_by_fault(struct slave_node *slave) { int ret; - struct timeval faulted_at; int reactivate = 1; int reactivate_instances = 1; @@ -828,6 +835,31 @@ HAPI struct slave_node *slave_deactivated_by_fault(struct slave_node *slave) } } +#if defined(_USE_ECORE_TIME_GET) + double faulted_at; + + faulted_at = ecore_time_get(); + if (faulted_at - slave->activated_at < MINIMUM_REACTIVATION_TIME) { + slave->critical_fault_count++; + if (!slave_loaded_instance(slave) || slave->critical_fault_count >= SLAVE_MAX_LOAD) { + ErrPrint("Reactivation time is too fast and frequently occurred - Stop to auto reactivation\n"); + reactivate = 0; + reactivate_instances = 0; + slave->critical_fault_count = 0; + /*! + * \note + * Fault callback can access the slave information. + */ + invoke_fault_cb(slave); + } else { + slave->critical_fault_count = 0; + } + } else { + ErrPrint("Failed to get time of day: %s\n", strerror(errno)); + } +#else + struct timeval faulted_at; + if (gettimeofday(&faulted_at, NULL) == 0) { struct timeval rtv; @@ -851,6 +883,7 @@ HAPI struct slave_node *slave_deactivated_by_fault(struct slave_node *slave) } else { ErrPrint("Failed to get time of day: %s\n", strerror(errno)); } +#endif slave_set_reactivation(slave, reactivate); slave_set_reactivate_instances(slave, reactivate_instances); @@ -50,8 +50,10 @@ HAPI unsigned long util_string_hash(const char *str) HAPI double util_timestamp(void) { +#if defined(_USE_ECORE_TIME_GET) + return ecore_time_get(); +#else struct timeval tv; - if (gettimeofday(&tv, NULL) < 0) { static unsigned long internal_count = 0; ErrPrint("failed to get time of day: %s\n", strerror(errno)); @@ -60,6 +62,7 @@ HAPI double util_timestamp(void) } return (double)tv.tv_sec + (double)tv.tv_usec / 1000000.0f; +#endif } HAPI int util_check_ext(const char *filename, const char *check_ptr) @@ -354,7 +357,6 @@ HAPI const char *util_uri_to_path(const char *uri) HAPI double util_time_delay_for_compensation(double period) { - struct timeval tv; unsigned long long curtime; unsigned long long _period; unsigned long long remain; @@ -365,12 +367,20 @@ HAPI double util_time_delay_for_compensation(double period) return 0.0f; } +#if defined(_USE_ECORE_TIME_GET) + double tv; + tv = ecore_time_get(); + curtime = tv * 1000000llu; +#else + struct timeval tv; if (gettimeofday(&tv, NULL) < 0){ ErrPrint("gettimeofday: %s\n", strerror(errno)); return period; } curtime = (unsigned long long)tv.tv_sec * 1000000llu + (unsigned long long)tv.tv_usec; +#endif + _period = (unsigned long long)(period * (double)1000000); if (_period == 0llu) { ErrPrint("%lf <> %llu\n", period, _period); |