remove unnecessary cynara_finish() call 41/96541/1 accepted/tizen/common/20161114.170923 accepted/tizen/ivi/20161114.005116 accepted/tizen/mobile/20161114.004936 accepted/tizen/tv/20161114.005009 accepted/tizen/wearable/20161114.005045 submit/tizen/20161111.051722
authorKonrad Lipinski <konrad.l@samsung.com>
Wed, 9 Nov 2016 08:59:35 +0000 (09:59 +0100)
committerKonrad Lipinski <konrad.l@samsung.com>
Wed, 9 Nov 2016 08:59:57 +0000 (09:59 +0100)
Change-Id: Ifcf14f42b8fc2b65c8a5598525b7b0a905f42aee

src/internal/cynara.cpp
src/internal/cynara.hpp
src/internal/cynara_mockup.cpp

index 6fe6b76..8be1c11 100644 (file)
@@ -7,20 +7,6 @@
 
 using namespace ldp_cynara;
 
-pthread_mutex_t Cynara::__mutex = PTHREAD_MUTEX_INITIALIZER;
-
-Cynara::Cynara() : __inited(false) {
-}
-
-Cynara::~Cynara() {
-       int r = cynara_finish(__cynara);
-       if (r != CYNARA_API_SUCCESS) {
-               //TODO: reaction
-               //destructor is usually called when proccess is closed
-               //there is no good way to serve this case.
-       }
-}
-
 bool Cynara::init() {
        if (!__inited) {
                int r = cynara_initialize(&__cynara, NULL);
@@ -33,10 +19,8 @@ bool Cynara::init() {
        return true;
 }
 
-Cynara& Cynara::getInstance() {
-       static Cynara __self;
-       return __self;
-}
+static pthread_mutex_t __mutex = PTHREAD_MUTEX_INITIALIZER;
+static Cynara c;
 
 CynaraResult Cynara::check(const char* label, const char* privilege, const char* uid) {
        const char* _label = "";
@@ -50,7 +34,6 @@ CynaraResult Cynara::check(const char* label, const char* privilege, const char*
        if (uid)
                _uid = uid;
        pthread_mutex_lock(&__mutex);
-       Cynara& c = Cynara::getInstance();
        if (!c.init()) {
                ret = CynaraResult::ERROR_INIT;
        } else {
index 84fbbd2..510b850 100644 (file)
@@ -32,15 +32,11 @@ namespace ldp_cynara {
        };
     class Cynara {
        private:
-               static pthread_mutex_t __mutex;
                cynara* __cynara;
                const char* __session;
-               bool __inited;
-               Cynara();
-               ~Cynara();
+               bool __inited = false;
 
                bool init();
-               static Cynara& getInstance();
        public:
 
                static CynaraResult check(const char* label, const char* privilege, const char* uid);
index 8b701cd..d472cdb 100644 (file)
@@ -6,22 +6,6 @@
 
 using namespace ldp_cynara;
 
-Cynara::Cynara() {
-}
-
-Cynara::~Cynara() {
-}
-
-bool Cynara::init() {
-       return true;
-}
-
-Cynara& Cynara::getInstance() {
-       static Cynara __self;
-       return __self;
-}
-
-
 CynaraResult Cynara::check(const char* label, const char* privilege, const char* uid) {
        (void)label;
        (void)privilege;