Change the processing slot for cleardata/clearcache 39/124239/2
authorjongmyeongko <jongmyeong.ko@samsung.com>
Wed, 5 Apr 2017 14:16:17 +0000 (23:16 +0900)
committerjongmyeong ko <jongmyeong.ko@samsung.com>
Thu, 13 Apr 2017 07:36:57 +0000 (00:36 -0700)
In the most client's event-callback, the pkgid is used to classify the incomming event.
So, we should control not to process somethings simultaneously
for same pkgid in different slots.

Note: In case of getting size, there is dedicated callback. so, no problem.
In case of clear cache all, the pkgid is '__ALL__', so it can be distinguished.

Change-Id: If7840f9ae49ae5857483cae3ed3902f0cdab0319
Signed-off-by: jongmyeongko <jongmyeong.ko@samsung.com>
(cherry picked from commit a171770669d15b8f1d0ab44aa5c438ba83e5880c)

src/request.c

index 0c3d41f..ee0bfae 100644 (file)
@@ -1077,6 +1077,7 @@ static int __handle_request_cleardata(uid_t caller_uid,
 {
        uid_t target_uid = (uid_t)-1;
        char *pkgid = NULL;
+       char *pkgtype;
 
        g_variant_get(parameters, "(u&s)", &target_uid, &pkgid);
        if (target_uid == (uid_t)-1 || pkgid == NULL) {
@@ -1085,8 +1086,15 @@ static int __handle_request_cleardata(uid_t caller_uid,
                return -1;
        }
 
+       pkgtype = _get_pkgtype_from_pkgid(pkgid, target_uid);
+       if (pkgtype == NULL) {
+               g_dbus_method_invocation_return_value(invocation,
+                               g_variant_new("(is)", PKGMGR_R_ENOPKG, ""));
+               return -1;
+       }
+
        if (_push_queue(target_uid, caller_uid, NULL, REQUEST_TYPE_CLEARDATA,
-                               "pkgtool", pkgid, NULL)) {
+                               pkgtype, pkgid, NULL)) {
                g_dbus_method_invocation_return_value(invocation,
                                g_variant_new("(i)", PKGMGR_R_ESYSTEM));
                return -1;
@@ -1103,6 +1111,7 @@ static int __handle_request_clearcache(uid_t caller_uid,
 {
        uid_t target_uid = (uid_t)-1;
        char *pkgid = NULL;
+       char *pkgtype;
 
        g_variant_get(parameters, "(u&s)", &target_uid, &pkgid);
        if (target_uid == (uid_t)-1 || pkgid == NULL) {
@@ -1111,8 +1120,18 @@ static int __handle_request_clearcache(uid_t caller_uid,
                return -1;
        }
 
+       if (strcmp(PKG_CLEAR_ALL_CACHE, pkgid) == 0)
+               pkgtype = strdup("pkgtool");
+       else
+               pkgtype = _get_pkgtype_from_pkgid(pkgid, target_uid);
+       if (pkgtype == NULL) {
+               g_dbus_method_invocation_return_value(invocation,
+                               g_variant_new("(is)", PKGMGR_R_ENOPKG, ""));
+               return -1;
+       }
+
        if (_push_queue(target_uid, caller_uid, NULL, REQUEST_TYPE_CLEARCACHE,
-                               "pkgtool",  pkgid, NULL)) {
+                               pkgtype,  pkgid, NULL)) {
                g_dbus_method_invocation_return_value(invocation,
                                g_variant_new("(i)", PKGMGR_R_ESYSTEM));
                return -1;