Remove check_rate because it is the same function with check_async_call_rate 15/182115/1 accepted/tizen/unified/20180621.141347 submit/tizen/20180620.105920
authorlokilee73 <changjoo.lee@samsung.com>
Wed, 20 Jun 2018 10:49:53 +0000 (19:49 +0900)
committerlokilee73 <changjoo.lee@samsung.com>
Wed, 20 Jun 2018 10:49:59 +0000 (19:49 +0900)
Change-Id: I7d95dbdd6a0d2adea83526e1ab723ea851a689be
Signed-off-by: lokilee73 <changjoo.lee@samsung.com>
src/power.c

index 344afb1..2a541d4 100755 (executable)
@@ -444,60 +444,13 @@ static int unlock_state(display_state_e state, unsigned int flag)
                        METHOD_UNLOCK_STATE, "ss", arr, unlock_cb, -1, NULL);
 }
 
-#define CHECK_RATE_THRESHOLD   100
-#define CHECK_RATE_PERIOD_LEN  5
-static int check_rate()
-{
-       static int status;
-       static long num_calls;
-       static struct timeval prev;
-       struct timeval cur;
-       int ret;
-
-       if (status < 0)
-               return status;
-
-       ret = gettimeofday(&cur, NULL);
-       if (ret < 0) {
-               _E("Failed to do gettimeofday() ret=%d", ret);
-               return 0;
-       }
-
-       if (num_calls > 0) {
-               long rate;
-               struct timeval diff;
-               timersub(&cur, &prev, &diff);
-
-               if (diff.tv_sec > 0) {
-                       rate = num_calls / diff.tv_sec;
-
-                       if (rate > CHECK_RATE_THRESHOLD) {
-                               status = -1;
-                               return status;
-                       }
-
-                       if (diff.tv_sec > CHECK_RATE_PERIOD_LEN) {
-                               /* Reset the check period */
-                               num_calls = 0;
-                               return 0;
-                       }
-               }
-       } else {
-               /* Start a new check period */
-               prev = cur;
-       }
-
-       num_calls++;
-       return 0;
-}
-
 int device_power_request_lock(power_lock_e type, int timeout_ms)
 {
        int ret;
 
        _I("power_lock_e = %d", type);
 
-       if (check_rate() < 0) {
+       if (check_async_call_rate() < 0) {
                _E("Rejected by too frequent calls; %d (calls per sec.) limit is violated."
                                , CHECK_RATE_THRESHOLD);
                return DEVICE_ERROR_OPERATION_FAILED;
@@ -527,7 +480,7 @@ int device_power_release_lock(power_lock_e type)
 
        _I("power_lock_e = %d", type);
 
-       if (check_rate() < 0) {
+       if (check_async_call_rate() < 0) {
                _E("Rejected by too frequent calls; %d (calls per sec.) limit is violated."
                                , CHECK_RATE_THRESHOLD);
                return DEVICE_ERROR_OPERATION_FAILED;