#include <pwd.h>
#include <glib.h>
+#include <gio/gio.h>
#include <sqlite3.h>
#include <tzplatform_config.h>
return PM_PARSER_R_OK;
}
+#define RESOURCED_BUS_NAME "org.tizen.resourced"
+#define RESOURCED_PROC_PATH "/Org/Tizen/ResourceD/Process"
+#define RESOURCED_PROC_INTERFACE "org.tizen.resourced.process"
+#define RESOURCED_PROC_METHOD "ProcExclude"
+static void __send_wakeup_signal_to_resourced(pid_t pid)
+{
+ GError *error = NULL;
+ GDBusConnection *conn;
+ GDBusProxy *proxy;
+ GVariant *reply;
+
+ conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+ if (conn == NULL) {
+ _LOGE("Failed to connect to dbus: %s", error->message);
+ g_error_free(error);
+ return;
+ }
+
+ proxy = g_dbus_proxy_new_sync(conn,
+ G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
+ NULL, RESOURCED_BUS_NAME,
+ RESOURCED_PROC_PATH, RESOURCED_PROC_INTERFACE,
+ NULL, &error);
+ if (proxy == NULL) {
+ _LOGE("failed to get proxy object: %s", error->message);
+ g_error_free(error);
+ g_object_unref(conn);
+ return;
+ }
+
+ reply = g_dbus_proxy_call_sync(proxy, RESOURCED_PROC_METHOD,
+ g_variant_new("(si)", "wakeup", pid),
+ G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+ if (reply == NULL)
+ _LOGE("failed to get reply from resourced");
+ if (error) {
+ _LOGE("failed to send request: %s", error->message);
+ g_error_free(error);
+ }
+
+ g_object_unref(proxy);
+ g_object_unref(conn);
+}
+
static void __check_db_lock(const char *dbpath)
{
FILE *fp;
}
_LOGE("%s (%d) has lock on pkgmgr db(%s)!", name, pid, dbpath);
+ __send_wakeup_signal_to_resourced(pid);
}
fclose(fp);
}
#define BUSY_WAITING_USEC (1000000 / 10 / 2) /* 0.05 sec */
-#define BUSY_WAITING_MAX 20 /* wait for max 1 sec */
+#define BUSY_WAITING_MAX 40 /* wait for max 2 sec */
static int __db_busy_handler(void *data, int count)
{
- if (count < BUSY_WAITING_MAX) {
+ if (count < (BUSY_WAITING_MAX / 2)) {
+ usleep(BUSY_WAITING_USEC);
+ return 1;
+ } else if (count == (BUSY_WAITING_MAX / 2)) {
+ __check_db_lock((const char *)data);
+ usleep(BUSY_WAITING_USEC);
+ return 1;
+ } else if (count < BUSY_WAITING_MAX) {
usleep(BUSY_WAITING_USEC);
return 1;
} else {
/* sqlite3_prepare_v2 will return SQLITE_BUSY */
- __check_db_lock((const char *)data);
return 0;
}
}