From 5aa4ada9b63569c38ade19bde8b2c245938b7bfa Mon Sep 17 00:00:00 2001 From: jongmyeongko Date: Wed, 5 Apr 2017 23:16:17 +0900 Subject: [PATCH] Change the processing slot for cleardata/clearcache 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 (cherry picked from commit a171770669d15b8f1d0ab44aa5c438ba83e5880c) --- src/request.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/request.c b/src/request.c index 0c3d41f..ee0bfae 100644 --- a/src/request.c +++ b/src/request.c @@ -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; -- 2.7.4