From: MuHong Byun Date: Thu, 21 May 2020 03:56:15 +0000 (+0900) Subject: Limit number of providers for better performance X-Git-Tag: accepted/tizen/unified/20200805.122521~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0924b8afa724129d7b82176be328379ddab3b914;p=platform%2Fcore%2Fsystem%2Fsensord.git Limit number of providers for better performance Change-Id: Icaef386841acfd1537a38a210115e049453c0670 Signed-off-by: MuHong Byun --- diff --git a/src/client/sensor_internal.cpp b/src/client/sensor_internal.cpp index 14844b5..7fa8f4d 100644 --- a/src/client/sensor_internal.cpp +++ b/src/client/sensor_internal.cpp @@ -38,6 +38,7 @@ #define CONVERT_OPTION_TO_PAUSE_POLICY(option) ((option) ^ 0b11) #define MAX_LISTENER 100 +#define MAX_PROVIDER 20 using namespace sensor; @@ -55,6 +56,7 @@ typedef GSourceFunc callback_dispatcher_t; static sensor::sensor_manager manager; static std::unordered_map listeners; static cmutex lock; +static uint providerCnt = 0; static gboolean sensor_events_callback_dispatcher(gpointer data) { @@ -896,6 +898,7 @@ API int sensord_remove_sensor_removed_cb(sensord_removed_cb callback) /* Sensor provider */ API int sensord_create_provider(const char *uri, sensord_provider_h *provider) { + retvm_if(providerCnt >= MAX_PROVIDER, -EPERM, "Exceeded the maximum provider"); retvm_if(!provider, -EINVAL, "Invalid paramter"); std::string str_uri(uri); @@ -912,6 +915,7 @@ API int sensord_create_provider(const char *uri, sensord_provider_h *provider) retvm_if(!p, -ENOMEM, "Failed to allocate memory"); *provider = static_cast(p); + providerCnt++; return OP_SUCCESS; } @@ -920,6 +924,7 @@ API int sensord_destroy_provider(sensord_provider_h provider) retvm_if(!provider, -EINVAL, "Invalid paramter"); delete static_cast(provider); + providerCnt--; return OP_SUCCESS; }