ADD_DEFINITIONS("-DLOCALEDIR=\"${LOCALEDIR}\"")
ADD_DEFINITIONS("-DBUS_TYPE=G_BUS_TYPE_SYSTEM") # G_BUS_TYPE_SESSION
-ADD_DEFINITIONS("-DSERVICE_INTERFACE=\"com.samsung.dataprovider.server\"")
-ADD_DEFINITIONS("-DSERVICE_NAME=\"com.samsung.dataprovider.serviceinterface\"")
-ADD_DEFINITIONS("-DOBJECT_PATH=\"/com/samsung/dataprovider/serviceobject\"")
+
+ADD_DEFINITIONS("-DMASTER_OBJECT_PATH=\"/com/samsung/masterprovider/serviceobject\"")
+ADD_DEFINITIONS("-DMASTER_SERVICE_INTERFACE=\"com.samsung.masterprovider.server\"")
+ADD_DEFINITIONS("-DMASTER_SERVICE_NAME=\"com.samsung.masterprovider.serviceinterface\"")
+
+ADD_DEFINITIONS("-DSLAVE_OBJECT_PATH=\"/com/samsung/slaveprovider/serviceobject\"")
+ADD_DEFINITIONS("-DSLAVE_SERVICE_INTERFACE=\"com.samsung.slaveprovider.server\"")
+ADD_DEFINITIONS("-DSLAVE_SERVICE_NAME=\"com.samsung.slaveprovider.serviceinterface\"")
+
+ADD_DEFINITIONS("-DCLIENT_OBJECT_PATH=\"/com/samsung/liveboxviewer/serviceobject\"")
+ADD_DEFINITIONS("-DCLIENT_SERVICE_INTERFACE=\"com.samsung.liveboxviewer.server\"")
+ADD_DEFINITIONS("-DCLIENT_SERVICE_NAME=\"com.samsung.liveboxviewer.serviceinterface\"")
ADD_DEFINITIONS("-DSLAVE_PKGNAME=\"com.samsung.data-provider-slave\"")
+data-provider-master (0.3.2) unstable; urgency=low
+
+ * Git: slp/pkgs/d/data-provider-master
+ * Tag: data-provider-master_0.3.2
+
+ -- Sung-jae Park <nicesj.park@samsung.com> Tue, 12 Jun 2012 19:17:41 +0900
+
data-provider-master (0.3.1) unstable; urgency=low
* Git: slp/pkgs/d/data-provider-master
* To check the slave's activation state
*/
extern int slave_is_activated(struct slave_node *slave);
+extern int slave_activated(struct slave_node *slave);
/*!
* To mangage the unexpected termination of a slave
extern int util_check_ext(const char *filename, const char *check_ptr);
extern int util_validate_livebox_package(const char *pkgname);
extern int util_unlink(const char *filename);
+extern char *util_slavename(void);
/* End of a file */
Name: com.samsung.data-provider-master
Summary: Master data provider
-Version: 0.3.1
+Version: 0.3.2
Release: 1
Group: main/app
License: Samsung Proprietary License
if (client->faulted)
return 0;
- DbgPrint("Client is faulted! refcnt(%d), pid(%d)\n", client_refcnt(client), client->pid);
+ DbgPrint("Client is faulted! refcnt(%d), pid(%d)\n", client->refcnt, client->pid);
client->faulted = 1;
client->pid = (pid_t)-1;
if (client->faulted)
return 0;
- DbgPrint("Client is faulted(%d), pid(%d)\n", client_refcnt(client), client->pid);
+ DbgPrint("Client is faulted(%d), pid(%d)\n", client->refcnt, client->pid);
client->faulted = 1;
client->pid = (pid_t)-1;
} s_info = {
.node_info = NULL,
.owner_id = 0,
- .xml_data = "<node name ='" OBJECT_PATH "'>"
- "<interface name='" SERVICE_INTERFACE "'>"
+ .xml_data = "<node name ='" MASTER_OBJECT_PATH "'>"
+ "<interface name='" MASTER_SERVICE_INTERFACE "'>"
/* From client */
" <method name='acquire'>"
sender = g_dbus_method_invocation_get_sender(inv);
- param = g_variant_new("(i)", 0);
- if (!param)
- ErrPrint("Failed to create variant\n");
-
- g_dbus_method_invocation_return_value(inv, param);
-
conn = g_dbus_method_invocation_get_connection(inv);
if (!conn) {
ErrPrint("Failed to get connection object\n");
return;
}
+ DbgPrint("sender: %s\n", sender);
g_dbus_proxy_new(conn,
G_DBUS_PROXY_FLAGS_NONE,
NULL,
sender,
- OBJECT_PATH,
- SERVICE_INTERFACE,
+ SLAVE_OBJECT_PATH,
+ SLAVE_SERVICE_INTERFACE,
NULL,
slave_proxy_prepared_cb, slave);
+
+ param = g_variant_new("(i)", 0);
+ if (!param)
+ ErrPrint("Failed to create variant\n");
+
+ g_dbus_method_invocation_return_value(inv, param);
+
}
}
ret = 0;
} else if (script_handler_is_loaded(instance_pd_handle(inst))) {
ret = script_handler_parse_desc(pkgname, id, descfile, 1);
+ DbgPrint("DESC for PD is updated (%d - %s)\n", ret, pkgname);
} else {
ret = 0;
}
if (package_lb_type(instance_package(inst)) == LB_TYPE_SCRIPT) {
script_handler_resize(instance_lb_handle(inst), w, h);
ret = script_handler_parse_desc(pkgname, id, id, 0);
+ DbgPrint("DESC for LB is updated (%d - %s)\n", ret, pkgname);
} else {
/*!
* \check
}
out:
- param = g_variant_new("(i)", ret);
- if (!param)
- ErrPrint("Failed to create variant\n");
-
- g_dbus_method_invocation_return_value(inv, param);
-
if (ret == 0) {
GDBusConnection *conn;
const char *sender;
}
sender = g_dbus_method_invocation_get_sender(inv);
+ DbgPrint("sender: %s\n", sender);
g_dbus_proxy_new(conn,
G_DBUS_PROXY_FLAGS_NONE,
NULL,
sender,
- OBJECT_PATH,
- SERVICE_INTERFACE,
+ CLIENT_OBJECT_PATH,
+ CLIENT_SERVICE_INTERFACE,
NULL,
client_proxy_prepared_cb, client);
}
+
+ param = g_variant_new("(i)", ret);
+ if (!param)
+ ErrPrint("Failed to create variant\n");
+
+ g_dbus_method_invocation_return_value(inv, param);
+
}
static void method_release(GDBusMethodInvocation *inv, GVariant *param)
err = NULL;
s_info.reg_id = g_dbus_connection_register_object(conn,
- OBJECT_PATH,
+ MASTER_OBJECT_PATH,
s_info.node_info->interfaces[0],
&iface_vtable,
NULL,
if (s_info.reg_id <= 0) {
if (err) {
- ErrPrint("register %s - %s\n", OBJECT_PATH, err->message);
+ ErrPrint("register %s - %s\n", MASTER_OBJECT_PATH, err->message);
g_error_free(err);
}
g_dbus_node_info_unref(s_info.node_info);
int r;
r = g_bus_own_name(BUS_TYPE,
- SERVICE_NAME,
+ MASTER_SERVICE_NAME,
G_BUS_NAME_OWNER_FLAGS_NONE,
on_bus_acquired,
on_name_acquired,
NULL, /* user_data */
NULL /* GDestroyNotify */ );
if (r <= 0) {
- ErrPrint("Failed to get a name: %s\n", SERVICE_NAME);
+ ErrPrint("Failed to get a name: %s\n", MASTER_SERVICE_NAME);
return -EFAULT;
}
free(info->script);
free(info->abi);
free(info->pkgname);
- slave_event_callback_del(info->slave, SLAVE_EVENT_DEACTIVATE, slave_deactivated_cb, info);
- slave_event_callback_del(info->slave, SLAVE_EVENT_ACTIVATE, slave_activated_cb, info);
+
+ if (info->slave) {
+ slave_unload_package(info->slave);
+ slave_event_callback_del(info->slave, SLAVE_EVENT_DEACTIVATE, slave_deactivated_cb, info);
+ slave_event_callback_del(info->slave, SLAVE_EVENT_ACTIVATE, slave_activated_cb, info);
+ }
+
free(info);
}
if (!info->secured)
info->slave = slave_find_available();
+ package_ref(info);
+
if (!info->slave) {
- char slavename[BUFSIZ];
- snprintf(slavename, sizeof(slavename), "%lf", util_timestamp());
+ char *slavename;
+ slavename = util_slavename();
+ if (!slavename) {
+ package_destroy(info);
+ return NULL;
+ }
+
+ DbgPrint("New slave name is %s assigned for %s\n", slavename, pkgname);
info->slave = slave_create(slavename, info->secured);
+ free(slavename);
/*!
* \note
* Slave is not activated yet.
*/
+ } else {
+ DbgPrint("Slave %s is assigned for %s\n", slave_name(info->slave), pkgname);
}
if (!info->slave) {
return NULL;
}
+ slave_load_package(info->slave);
slave_event_callback_add(info->slave, SLAVE_EVENT_DEACTIVATE, slave_deactivated_cb, info);
slave_event_callback_add(info->slave, SLAVE_EVENT_ACTIVATE, slave_activated_cb, info);
- package_ref(info);
s_info.pkg_list = eina_list_append(s_info.pkg_list, info);
return info;
}
return -EFAULT;
}
+ DbgPrint("send %s %s %s\n", "script", signal, part);
ret = slave_rpc_async_request(slave, pkgname, filename, "script", param, NULL, NULL);
return ret;
}
block = NULL;
inst = package_find_instance_by_id(pkgname, filename);
- if (!inst)
- return -EINVAL;
+ if (!inst) {
+ ErrPrint("Instance is not exists\n");
+ return -ENOENT;
+ }
fp = fopen(descfile, "rt");
if (!fp) {
return -EIO;
}
+ DbgPrint("descfile: %s\n", descfile);
+
state = UNKNOWN;
field_idx = 0;
lineno = 1;
break;
}
- if (!isspace(ch)) {
+ if (!isspace(ch) && ch != EOF) {
+ ErrPrint("%d: Syntax error: Desc is not started with '{' or space - (%c = 0x%x)\n", lineno, ch, ch);
fclose(fp);
return -EINVAL;
}
break;
if (ch != '\n') {
- ErrPrint("Syntax error: New line must has to be started right after '{'\n");
+ ErrPrint("%d: Syntax error: New line must has to be started right after '{'\n", lineno);
goto errout;
}
if (ch == '=') {
if (field_name[field_idx][idx] != '\0') {
- ErrPrint("Syntax error: Unrecognized field\n");
+ ErrPrint("%d: Syntax error: Unrecognized field\n", lineno);
goto errout;
}
idx = 0;
break;
default:
- ErrPrint("Syntax error: Unrecognized field\n");
+ ErrPrint("%d: Syntax error: Unrecognized field\n", lineno);
goto errout;
}
field_idx++;
if (field_name[field_idx] == NULL) {
- ErrPrint("Syntax error: Unrecognized field\n");
+ ErrPrint("%d: Syntax error: Unrecognized field\n", lineno);
goto errout;
}
block->type =
realloc(block->type, block->type_len);
if (!block->type) {
- ErrPrint("Failed to allocate memory\n");
+ ErrPrint("Heap: %s\n", strerror(errno));
goto errout;
}
}
block->part =
realloc(block->part, block->part_len);
if (!block->part) {
- ErrPrint("Failed to allocate memory\n");
+ ErrPrint("Heap: %s\n", strerror(errno));
goto errout;
}
}
block->data =
realloc(block->data, block->data_len);
if (!block->data) {
- ErrPrint("Failed to allocate memory\n");
+ ErrPrint("Heap: %s\n", strerror(errno));
goto errout;
}
}
block->file =
realloc(block->file, block->file_len);
if (!block->file) {
- ErrPrint("Failed to allocate memory\n");
+ ErrPrint("Heap: %s\n", strerror(errno));
goto errout;
}
}
block->group = realloc(block->group,
block->group_len);
if (!block->group) {
- ErrPrint("Failed to allocate memory\n");
+ ErrPrint("Heap: %s\n", strerror(errno));
goto errout;
}
}
block->id_len += 256;
block->id = realloc(block->id, block->id_len);
if (!block->id) {
- ErrPrint("Failed to allocate memory\n");
+ ErrPrint("Heap: %s\n", strerror(errno));
goto errout;
}
}
if (!block->file) {
block->file = strdup(filename);
if (!block->file) {
- ErrPrint("Failed to allocate memory\n");
+ ErrPrint("Heap: %s\n", strerror(errno));
goto errout;
}
}
}
if (!handlers[i].type)
- ErrPrint("Unknown block type: %s\n", block->type);
+ ErrPrint("%d: Unknown block type: %s\n", lineno, block->type);
free(block->file);
free(block->type);
} /* while */
if (state != UNKNOWN) {
- ErrPrint("Unknown state\n");
+ ErrPrint("%d: Unknown state\n", lineno);
goto errout;
}
int refcnt;
int fault_count;
enum pause_state {
+ /*!
+ * Launch the slave but not yet receives "hello" packet
+ */
+ SLAVE_REQUEST_TO_LAUNCH,
+
+ /*!
+ * \note
+ * Terminate the slave but not yet receives dead signal
+ */
+ SLAVE_REQUEST_TO_TERMINATE,
+
+ /*!
+ * \note
+ * No slave process exists, just slave object created
+ */
+ SLAVE_TERMINATED,
+
+ /*!
+ * \note
+ * State change request is sent,
+ */
SLAVE_REQUEST_TO_PAUSE,
SLAVE_REQUEST_TO_RESUME,
+ /*!
+ * \note
+ * SLAVE_ACTIVATED = { SLAVE_PAUSED, SLAVE_RESUMED }
+ */
SLAVE_PAUSED,
SLAVE_RESUMED,
} state;
slave->secured = is_secured;
slave->pid = (pid_t)-1;
- slave->state = SLAVE_RESUMED;
+ slave->state = SLAVE_TERMINATED;
s_info.slave_list = eina_list_append(s_info.slave_list, slave);
DbgPrint("slave data is created %p\n", slave);
bundle_free(param);
if (slave->pid < 0) {
- ErrPrint("Failed to launch a new slave %s\n", slave->name);
+ ErrPrint("Failed to launch a new slave %s (%d)\n", slave->name, slave->pid);
+ slave->pid = (pid_t)-1;
return -EFAULT;
}
DbgPrint("Slave launched %d\n", slave->pid);
+ slave->state = SLAVE_REQUEST_TO_LAUNCH;
/*!
* \note
* Increase the refcnt of a slave,
*/
slave_ref(slave);
- invoke_activate_cb(slave);
- slave_check_pause_or_resume();
+ return 0;
+}
+int slave_activated(struct slave_node *slave)
+{
slave->state = SLAVE_RESUMED;
+ invoke_activate_cb(slave);
+ slave_check_pause_or_resume();
return 0;
}
*/
pid = slave->pid;
slave->pid = (pid_t)-1;
+
DbgPrint("Terminate PID: %d\n", pid);
if (aul_terminate_pid(pid) < 0)
ErrPrint("Terminate failed. pid %d\n", pid);
slave_rpc_reset_proxy(slave);
invoke_deactivate_cb(slave);
- slave->state = SLAVE_PAUSED;
+ slave->state = SLAVE_TERMINATED;
slave_unref(slave);
}
slave_rpc_reset_proxy(slave);
invoke_deactivate_cb(slave);
- slave->state = SLAVE_PAUSED;
+ slave->state = SLAVE_TERMINATED;
slave_unref(slave);
}
if (slave->secured)
continue;
- if (slave->loaded_package == g_conf.slave_max_load)
- continue;
-
- return slave;
+ DbgPrint("slave[%s] %d\n", slave_name(slave), slave->loaded_package);
+ if (slave->loaded_package < g_conf.slave_max_load)
+ return slave;
}
return NULL;
}
if (rpc->proxy)
- ErrPrint("RPC proxy is already exists\n");
+ ErrPrint("proxy %p is already exists (%s %d) (replaced with %p)\n", rpc->proxy, slave_name(slave), slave_pid(slave), proxy);
+ else
+ ErrPrint("proxy %p is updated (%s %d)\n", proxy, slave_name(slave), slave_pid(slave));
rpc->proxy = proxy;
- slave_reset_fault(slave);
EINA_LIST_FREE(rpc->pending_request_list, packet) {
push_packet(packet);
rpc->ping_count = 0;
rpc->next_ping_count = 1;
+ if (rpc->pong_timer)
+ ecore_timer_del(rpc->pong_timer);
+
rpc->pong_timer = ecore_timer_add(g_conf.ping_time, ping_timeout_cb, slave);
if (!rpc->pong_timer)
ErrPrint("Failed to add ping timer\n");
+ slave_activated(slave);
+
+ slave_reset_fault(slave);
return 0;
}
return 0;
}
+char *util_slavename(void)
+{
+ char slavename[BUFSIZ];
+ static unsigned long idx = 0;
+
+ snprintf(slavename, sizeof(slavename), "%lu_%lf", idx++, util_timestamp());
+ return strdup(slavename);
+}
+
/* End of a file */