summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSung-jae Park <nicesj.park@samsung.com>2013-09-23 23:33:01 (GMT)
committerSung-jae Park <nicesj.park@samsung.com>2013-09-23 23:33:01 (GMT)
commit21607ac560ba3d0965503b15dab6f426d2d9f45e (patch)
tree0ad2548b5cb54ec04bc55f68b558bfbd9944d26f
parent2b898b7ec721d4dd5b8988cbc1e95e6ea406b774 (diff)
downloaddata-provider-master-21607ac560ba3d0965503b15dab6f426d2d9f45e.zip
data-provider-master-21607ac560ba3d0965503b15dab6f426d2d9f45e.tar.gz
data-provider-master-21607ac560ba3d0965503b15dab6f426d2d9f45e.tar.bz2
Update slave_activate_all/deactivate_all function.
counting call. signal & low mem callback uses these API. Change-Id: I565eda19feb94308011abf3f87b366a8cc3e685f
-rw-r--r--src/setting.c41
-rw-r--r--src/slave_life.c14
2 files changed, 55 insertions, 0 deletions
diff --git a/src/setting.c b/src/setting.c
index 4e6d1c6..07e86d1 100644
--- a/src/setting.c
+++ b/src/setting.c
@@ -15,6 +15,7 @@
*/
#include <stdio.h>
+#include <malloc.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
@@ -45,6 +46,12 @@
int errno;
+static struct {
+ int deactivated;
+} s_info = {
+ .deactivated = 0,
+};
+
static void lcd_state_cb(keynode_t *node, void *user_data)
{
if (!node) {
@@ -211,6 +218,30 @@ out:
DbgFree(event);
}
+static void low_mem_cb(keynode_t *node, void *user_data)
+{
+ int val;
+
+ val = vconf_keynode_get_int(node);
+
+ if (val >= VCONFKEY_SYSMAN_LOW_MEMORY_SOFT_WARNING) {
+ CRITICAL_LOG("Low memory: level %d\n", val);
+ if (s_info.deactivated == 0) {
+ s_info.deactivated = 1;
+ slave_deactivate_all(0, 1);
+ malloc_trim(0);
+ ErrPrint("Fall into the low mem status\n");
+ }
+ } else {
+ CRITICAL_LOG("Normal memory: level %d\n", val);
+ if (s_info.deactivated == 1) {
+ s_info.deactivated = 0;
+ slave_activate_all();
+ ErrPrint("Recover from the low mem status\n");
+ }
+ }
+}
+
HAPI int setting_init(void)
{
int ret;
@@ -240,6 +271,11 @@ HAPI int setting_init(void)
ErrPrint("Failed to add vconf for ail info state: %d\n", ret);
}
+ ret = vconf_notify_key_changed(VCONFKEY_SYSMAN_LOW_MEMORY, low_mem_cb, NULL);
+ if (ret < 0) {
+ ErrPrint("Failed to add vconf for low mem monitor: %d\n", ret);
+ }
+
lang_changed_cb(NULL, NULL);
region_changed_cb(NULL, NULL);
return ret;
@@ -249,6 +285,11 @@ HAPI int setting_fini(void)
{
int ret;
+ ret = vconf_ignore_key_changed(VCONFKEY_SYSMAN_LOW_MEMORY, low_mem_cb);
+ if (ret < 0) {
+ ErrPrint("Failed to ignore vconf key (%d)\n", ret);
+ }
+
ret = vconf_ignore_key_changed(VCONFKEY_REGIONFORMAT, region_changed_cb);
if (ret < 0) {
ErrPrint("Failed to ignore vconf key (%d)\n", ret);
diff --git a/src/slave_life.c b/src/slave_life.c
index f5710f6..383c8cc 100644
--- a/src/slave_life.c
+++ b/src/slave_life.c
@@ -97,8 +97,10 @@ struct priv_data {
static struct {
Eina_List *slave_list;
+ int deactivate_all_refcnt;
} s_info = {
.slave_list = NULL,
+ .deactivate_all_refcnt = 0,
};
static Eina_Bool slave_ttl_cb(void *data)
@@ -1495,6 +1497,12 @@ HAPI int slave_deactivate_all(int reactivate, int reactivate_instances)
struct slave_node *slave;
int cnt = 0;
+ s_info.deactivate_all_refcnt++;
+ if (s_info.deactivate_all_refcnt > 1) {
+ return 0;
+ }
+ DbgPrint("Deactivate all\n");
+
EINA_LIST_FOREACH_SAFE(s_info.slave_list, l, n, slave) {
slave_set_reactivate_instances(slave, reactivate_instances);
slave_set_reactivation(slave, reactivate);
@@ -1515,6 +1523,12 @@ HAPI int slave_activate_all(void)
struct slave_node *slave;
int cnt = 0;
+ s_info.deactivate_all_refcnt--;
+ if (s_info.deactivate_all_refcnt > 0) {
+ return 0;
+ }
+ DbgPrint("Activate all\n");
+
EINA_LIST_FOREACH(s_info.slave_list, l, slave) {
slave_activate(slave);
cnt++;