apply retry logic to get an user type using gum api. 41/97241/1 accepted/tizen/3.0/common/20161114.143016 accepted/tizen/3.0/ivi/20161114.002606 accepted/tizen/3.0/mobile/20161114.002448 accepted/tizen/3.0/tv/20161114.002513 accepted/tizen/3.0/wearable/20161114.002538 accepted/tizen/common/20161125.095130 accepted/tizen/ivi/20161125.004138 accepted/tizen/mobile/20161125.003553 accepted/tizen/tv/20161125.003904 accepted/tizen/wearable/20161125.004023 submit/tizen/20161124.000829 submit/tizen_3.0/20161111.080112 submit/tizen_3.0_common/20161114.081136
authorjongmyeongko <jongmyeong.ko@samsung.com>
Fri, 11 Nov 2016 12:51:46 +0000 (21:51 +0900)
committerjongmyeongko <jongmyeong.ko@samsung.com>
Fri, 11 Nov 2016 12:51:46 +0000 (21:51 +0900)
Change-Id: I3c72109483737e0ba8281cadde48b24e9f7d2928
Signed-off-by: jongmyeongko <jongmyeong.ko@samsung.com>
src/request.c

index ad964c1..7a5ba92 100644 (file)
@@ -11,6 +11,8 @@
 #include "pkgmgr-server.h"
 #include "package-manager.h"
 
+#define RETRY_MAX 5
+#define RETRY_WAIT_USEC (1000000 / 2) /* 0.5 sec */
 #define PKGMGR_DBUS_SERVICE "org.tizen.pkgmgr"
 #define PKGMGR_DBUS_OBJECT_PATH "/org/tizen/pkgmgr"
 
@@ -200,10 +202,21 @@ static int __is_admin_user(uid_t uid)
 {
        GumUser *guser;
        GumUserType ut = GUM_USERTYPE_NONE;
+       int retry_cnt = 0;
+
+       do {
+               guser = gum_user_get_sync(uid, FALSE);
+               if (guser == NULL) {
+                       ERR("cannot get user information from gumd, retry");
+                       retry_cnt++;
+                       usleep(RETRY_WAIT_USEC);
+                       continue;
+               }
+               break;
+       } while (retry_cnt <= RETRY_MAX);
 
-       guser = gum_user_get_sync(uid, FALSE);
        if (guser == NULL) {
-               ERR("cannot get user information from gumd");
+               ERR("cannot get user information from gumd, failed");
                return -1;
        }