summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSung-jae Park <nicesj.park@samsung.com>2013-02-15 08:49:40 +0000
committerSung-jae Park <nicesj.park@samsung.com>2013-02-15 08:49:40 +0000
commitc7607ae6cfe01a2e0a602b3905cb83fa3f61f98e (patch)
tree4192df499cd2ccb059cec194da4ee4270b157af0 /src
parent7e19325259752ec58f4df731c2ca1d40c7a39300 (diff)
downloaddata-provider-master-c7607ae6cfe01a2e0a602b3905cb83fa3f61f98e.tar.gz
data-provider-master-c7607ae6cfe01a2e0a602b3905cb83fa3f61f98e.tar.bz2
data-provider-master-c7607ae6cfe01a2e0a602b3905cb83fa3f61f98e.zip
Update the provider launching code.
Waiting its response in CONSTANT time. (default 30 secs) Change-Id: Ie0e8228834c93092c8edd8daffbc58676306ebc0
Diffstat (limited to 'src')
-rw-r--r--src/conf.c14
-rw-r--r--src/slave_life.c46
2 files changed, 58 insertions, 2 deletions
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: