Currently, check_async_call_rate is applied to power and display.
If power related api is blocked, display related api is blocked as well.
So, devide them.
Change-Id: I7132448f2aaf29fe26fcd1c4f3e7f7d421732fd6
Signed-off-by: lokilee73 <changjoo.lee@samsung.com>
return profile;
}
-int check_async_call_rate(void)
+int check_async_call_rate(long *num_calls)
{
static int status;
- static long num_calls;
static struct timeval prev;
struct timeval cur;
int ret;
if (ret < 0)
return 0;
- if (num_calls > 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;
+ rate = *num_calls / diff.tv_sec;
if (rate > CHECK_RATE_THRESHOLD) {
status = -1;
if (diff.tv_sec > CHECK_RATE_PERIOD_LEN) {
/* Reset the check period */
- num_calls = 0;
+ *num_calls = 0;
return 0;
}
}
prev = cur;
}
- num_calls++;
+ *num_calls += 1;
return 0;
}
#define CHECK_RATE_THRESHOLD 100
#define CHECK_RATE_PERIOD_LEN 5
-int check_async_call_rate(void);
+int check_async_call_rate(long *num_calls);
#define TIZEN_FEATURE_TRACKER (_get_tizen_profile() == TIZEN_PROFILE_TV)
char *str;
int ret;
static int privilege = -1;
+ static long num_calls = 0;
ret = is_display_state_supported();
if (!ret)
return DEVICE_ERROR_NOT_SUPPORTED;
- if (check_async_call_rate() < 0) {
+ if (check_async_call_rate(&num_calls) < 0) {
//LCOV_EXCL_START System Error
_E("Rejected by too frequent calls; %d (calls per sec.) limit is violated."
, CHECK_RATE_THRESHOLD);
int device_power_request_lock(power_lock_e type, int timeout_ms)
{
int ret;
+ static long num_calls = 0;
_I("power_lock_e = %d", type);
- if (check_async_call_rate() < 0) {
+ if (check_async_call_rate(&num_calls) < 0) {
//LCOV_EXCL_START System Error
_E("Rejected by too frequent calls; %d (calls per sec.) limit is violated."
, CHECK_RATE_THRESHOLD);