summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSung-jae Park <nicesj.park@samsung.com>2013-02-15 08:49:40 (GMT)
committerSung-jae Park <nicesj.park@samsung.com>2013-02-15 08:49:40 (GMT)
commitc7607ae6cfe01a2e0a602b3905cb83fa3f61f98e (patch)
tree4192df499cd2ccb059cec194da4ee4270b157af0
parent7e19325259752ec58f4df731c2ca1d40c7a39300 (diff)
downloaddata-provider-master-c7607ae6cfe01a2e0a602b3905cb83fa3f61f98e.zip
data-provider-master-c7607ae6cfe01a2e0a602b3905cb83fa3f61f98e.tar.gz
data-provider-master-c7607ae6cfe01a2e0a602b3905cb83fa3f61f98e.tar.bz2
Update the provider launching code.
Waiting its response in CONSTANT time. (default 30 secs) Change-Id: Ie0e8228834c93092c8edd8daffbc58676306ebc0
-rw-r--r--data/conf.ini1
-rw-r--r--include/conf.h2
-rw-r--r--packaging/org.tizen.data-provider-master.spec2
-rw-r--r--src/conf.c14
-rw-r--r--src/slave_life.c46
5 files changed, 62 insertions, 3 deletions
diff --git a/data/conf.ini b/data/conf.ini
index 73b31d7..586d1a0 100644
--- a/data/conf.ini
+++ b/data/conf.ini
@@ -10,6 +10,7 @@ default_content=default
minimum_space=5242880
replace_tag=/APPID/
slave_ttl=30.0
+slave_activate_time=30.0
max_log_line=1000
max_log_file=3
sqilte_flush_max=1048576
diff --git a/include/conf.h b/include/conf.h
index adf0cf5..a1b27dd 100644
--- a/include/conf.h
+++ b/include/conf.h
@@ -48,6 +48,7 @@ struct conf {
char *replace_tag;
double slave_ttl;
+ double slave_activate_time;
int max_log_line;
int max_log_file;
@@ -127,6 +128,7 @@ extern int conf_loader(void);
#define REPLACE_TAG_APPID g_conf.replace_tag
#define SLAVE_TTL g_conf.slave_ttl
+#define SLAVE_ACTIVATE_TIME g_conf.slave_activate_time
#define MAX_LOG_LINE g_conf.max_log_line
#define MAX_LOG_FILE g_conf.max_log_file
diff --git a/packaging/org.tizen.data-provider-master.spec b/packaging/org.tizen.data-provider-master.spec
index de0d650..a3deb09 100644
--- a/packaging/org.tizen.data-provider-master.spec
+++ b/packaging/org.tizen.data-provider-master.spec
@@ -1,6 +1,6 @@
Name: org.tizen.data-provider-master
Summary: Master service provider for liveboxes.
-Version: 0.16.4
+Version: 0.16.5
Release: 1
Group: framework/livebox
License: Flora License
diff --git a/src/conf.c b/src/conf.c
index e16e1d5..ca57d98 100644
--- a/src/conf.c
+++ b/src/conf.c
@@ -54,6 +54,7 @@ HAPI struct conf g_conf = {
.replace_tag = "/APPID/",
.slave_ttl = 30.0f,
+ .slave_activate_time = 30.0f,
.max_log_line = 1000,
.max_log_file = 3,
@@ -215,7 +216,14 @@ static void slave_ttl_handler(char *buffer)
{
if (sscanf(buffer, "%lf", &g_conf.slave_ttl) != 1)
ErrPrint("Failed to parse the slave_ttl\n");
- DbgPrint("Slave TTL: %s\n", g_conf.slave_ttl);
+ DbgPrint("Slave TTL: %lf\n", g_conf.slave_ttl);
+}
+
+static void slave_activate_time_handler(char *buffer)
+{
+ if (sscanf(buffer, "%lf", &g_conf.slave_activate_time) != 1)
+ ErrPrint("Failed to parse the slave_activate_time\n");
+ DbgPrint("Slave activate time: %lf\n", g_conf.slave_activate_time);
}
static void max_log_line_handler(char *buffer)
@@ -377,6 +385,10 @@ HAPI int conf_loader(void)
.handler = slave_ttl_handler,
},
{
+ .name = "slave_activate_time",
+ .handler = slave_activate_time_handler,
+ },
+ {
.name = "max_log_line",
.handler = max_log_line_handler,
},
diff --git a/src/slave_life.c b/src/slave_life.c
index c04ab5d..3665b4d 100644
--- a/src/slave_life.c
+++ b/src/slave_life.c
@@ -73,6 +73,7 @@ struct slave_node {
Eina_List *data_list;
Ecore_Timer *ttl_timer; /* Time to live */
+ Ecore_Timer *activate_timer; /* Waiting hello packet for this time */
struct timeval activated_at;
};
@@ -236,6 +237,9 @@ static inline void destroy_slave_node(struct slave_node *slave)
if (slave->ttl_timer)
ecore_timer_del(slave->ttl_timer);
+ if (slave->activate_timer)
+ ecore_timer_del(slave->activate_timer);
+
DbgFree(slave->abi);
DbgFree(slave->name);
DbgFree(slave->pkgname);
@@ -367,6 +371,29 @@ static inline void invoke_activate_cb(struct slave_node *slave)
}
}
+static Eina_Bool activate_timer_cb(void *data)
+{
+ struct slave_node *slave = data;
+
+ slave->fault_count++;
+ invoke_fault_cb(slave);
+
+ slave_set_reactivation(slave, 0);
+ slave_set_reactivate_instances(slave, 0);
+
+ slave->activate_timer = NULL;
+ if (slave->pid > 0) {
+ int ret;
+ DbgPrint("Try to terminate PID: %d\n", slave->pid);
+ ret = aul_terminate_pid(slave->pid);
+ if (ret < 0)
+ ErrPrint("Terminate failed, pid %d\n", slave->pid);
+ }
+ slave = slave_deactivated(slave);
+ ErrPrint("Slave is not activated in %lf sec (slave: %p)\n", SLAVE_ACTIVATE_TIME, slave);
+ return ECORE_CALLBACK_CANCEL;
+}
+
HAPI int slave_activate(struct slave_node *slave)
{
@@ -407,6 +434,10 @@ HAPI int slave_activate(struct slave_node *slave)
return -EFAULT;
}
DbgPrint("Slave launched %d for %s\n", slave->pid, slave->name);
+
+ slave->activate_timer = ecore_timer_add(SLAVE_ACTIVATE_TIME, activate_timer_cb, slave);
+ if (!slave->activate_timer)
+ ErrPrint("Failed to register an activate timer\n");
}
slave->state = SLAVE_REQUEST_TO_LAUNCH;
@@ -476,6 +507,12 @@ HAPI int slave_activated(struct slave_node *slave)
if (gettimeofday(&slave->activated_at, NULL) < 0)
ErrPrint("Failed to get time of day: %s\n", strerror(errno));
+
+ if (slave->activate_timer) {
+ ecore_timer_del(slave->activate_timer);
+ slave->activate_timer = NULL;
+ }
+
return 0;
}
@@ -544,11 +581,17 @@ HAPI struct slave_node *slave_deactivated(struct slave_node *slave)
slave->pid = (pid_t)-1;
slave->state = SLAVE_TERMINATED;
+
if (slave->ttl_timer) {
ecore_timer_del(slave->ttl_timer);
slave->ttl_timer = NULL;
}
+ if (slave->activate_timer) {
+ ecore_timer_del(slave->activate_timer);
+ slave->activate_timer = NULL;
+ }
+
reactivate = invoke_deactivate_cb(slave);
slave = slave_unref(slave);
@@ -637,10 +680,11 @@ HAPI struct slave_node *slave_deactivated_by_fault(struct slave_node *slave)
HAPI const int const slave_is_activated(struct slave_node *slave)
{
switch (slave->state) {
- case SLAVE_REQUEST_TO_LAUNCH:
case SLAVE_REQUEST_TO_TERMINATE:
case SLAVE_TERMINATED:
return 0;
+ case SLAVE_REQUEST_TO_LAUNCH:
+ /* Not yet launched. but the slave incurred an unexpected error */
case SLAVE_REQUEST_TO_PAUSE:
case SLAVE_REQUEST_TO_RESUME:
case SLAVE_PAUSED: