Make thread-safe of hasPermission() with cynara 11/76011/1
authorKyungwook Tak <k.tak@samsung.com>
Wed, 22 Jun 2016 10:23:59 +0000 (19:23 +0900)
committerKyungwook Tak <k.tak@samsung.com>
Wed, 22 Jun 2016 10:23:59 +0000 (19:23 +0900)
cynara is not thread-safe so locking mechanism is needed on our side.

Change-Id: Ica0105dc74a9bd3d76e73339d82831181c1469db
Signed-off-by: Kyungwook Tak <k.tak@samsung.com>
src/framework/service/access-control-cynara.cpp

index 9650e12..d0de0fe 100644 (file)
@@ -65,8 +65,13 @@ public:
        bool request(const std::string &user, const std::string &client,
                                 const std::string &session, const std::string &privilege)
        {
-               auto ret = cynara_check(this->m_cynara, client.c_str(), session.c_str(),
-                                                               user.c_str(), privilege.c_str());
+               int ret = CYNARA_API_ACCESS_DENIED;
+
+               {
+                       std::lock_guard<std::mutex> l(this->m_mutex);
+                       ret = cynara_check(this->m_cynara, client.c_str(), session.c_str(),
+                                                          user.c_str(), privilege.c_str());
+               }
 
                switch (ret) {
                case CYNARA_API_ACCESS_ALLOWED: return true;