Remove the "delete _requestObj" line in dbus disconnect listener. 44/129644/6
authorSegwon <segwon.han@samsung.com>
Wed, 17 May 2017 08:39:46 +0000 (17:39 +0900)
committerkmook <kmook.choi@samsung.com>
Mon, 22 May 2017 03:46:36 +0000 (12:46 +0900)
Signed-off-by: Segwon <segwon.han@samsung.com>
Change-Id: Ida41b8c041ff9cd5f3b43b1b7764011899ddffd8

daemon/Request.cpp
daemon/Request.h
daemon/service_provider/AppCommServiceApplication.cpp
daemon/service_provider/AppCommServiceProvider.cpp
daemon/service_provider/RemoteAppControlServiceProvider.cpp

index c327a0be28937cfb35c048b8fc32cfd67a19f2c5..61054ba3690fb429ac99c2e0815d6b509362ab50 100755 (executable)
 #include "Request.h"
 #include "DbusServer.h"
 
+conv::Request::Request()
+       : __type(0)
+       , __reqId(0)
+       , __isConnect(true)
+{
+}
+
 conv::Request::Request(int type, const char *client, int reqId, const char *subj, const char *desc,
                const char *sender, Credentials *creds, GDBusMethodInvocation *inv,
                int binaryLength, const unsigned char* binary)
@@ -207,7 +214,25 @@ void conv::Request::setIsConnect(bool state)
 
 conv::Request* conv::Request::clone()
 {
-       conv::Request *instance = new conv::Request(*this);
-       instance->setCreds(NULL);
+       conv::Request *instance = NULL;
+       instance = new conv::Request();
+
+       if(instance == NULL) {
+               _E("instance is NULL");
+               return NULL;
+       }
+       instance->__type = this->__type;
+       instance->__reqId = this->__reqId;
+       instance->__client = this->__client;
+       instance->__subject = this->__subject;
+       instance->__description = this->__description;
+       instance->__sender = this->__sender;
+       instance->__invocation = this->__invocation;
+       instance->__serviceInfo = this->__serviceInfo;
+       instance->__communicationInfo = this->__communicationInfo;
+       instance->__binaryLength = this->__binaryLength;
+       instance->__binary = this->__binary;
+       instance->__isConnect = this->__isConnect;
+
        return instance;
-}
\ No newline at end of file
+}
index cd53252dc8e0666521e93c030e523e6d29da25e8..a9ae6acb239239e922f4c065e6439609975d4fbe 100644 (file)
@@ -28,6 +28,7 @@
 namespace conv {
        class Request {
                public:
+                       Request();
                        Request(int type, const char *client, int reqId, const char *subj, const char *desc);
                        Request(int type,
                                        const char *client, int reqId, const char *subj, const char *desc,
index 16aa6cea5c811085f1eca61ecdfd0d8a33fdf6aa..d95d76a1e7489bfc5e9b51d7bcb5c3de4dda778c 100755 (executable)
@@ -45,7 +45,7 @@ void conv::AppCommServiceApplication::onStart(bool start_result)
                }
        }
 
-       if ((*requestObj) != NULL) {
+       if (requestObj != NULL && (*requestObj) != NULL) {
                _D(RED("publishing_response"));
                Json result;
                Json payload;
@@ -83,7 +83,7 @@ void conv::AppCommServiceApplication::onStop(bool stop_result)
                state = APP_COMM_STATE_FAILED;
        }
 
-       if ((*requestObj) != NULL) {
+       if (requestObj != NULL && (*requestObj) != NULL) {
                _D(RED("publishing_response"));
                Json result;
                Json payload;
@@ -142,7 +142,7 @@ void conv::AppCommServiceApplication::onMessage(Message message)
 {
        _D("onMessage Called");
 
-       if ((*requestObj) != NULL) {
+       if (requestObj != NULL && (*requestObj) != NULL) {
                _D(RED("publishing_response"));
                Json result;
                Json description;
@@ -177,7 +177,7 @@ void conv::AppCommServiceApplication::onError(Error error)
        _D("onError Called");
        state = APP_COMM_STATE_NONE;
 
-       if ((*requestObj) != NULL) {
+       if (requestObj != NULL && (*requestObj) != NULL) {
                _D(RED("publishing_response"));
                Json result;
                Json payload;
@@ -201,7 +201,7 @@ void conv::AppCommServiceApplication::onPublished(bool publish_result, void* use
 {
        _D("onPublished Called");
 
-       if ((*requestObj) != NULL) {
+       if (requestObj != NULL && (*requestObj) != NULL) {
                _D(RED("publishing_response"));
                Json result;
                Json payload;
@@ -225,7 +225,7 @@ void conv::AppCommServiceApplication::onPublished(bool publish_result, void* use
 
 void conv::AppCommServiceApplication::publishResponse(int error, string result_type, Client *client)
 {
-       if ((*requestObj) != NULL) {
+       if (requestObj != NULL && (*requestObj) != NULL) {
                _D(RED("publishing_response"));
                Json result;
                Json payload;
index 6bf2b85c282163696a40f6f19b43e03a6576327b..677d9405b7863868f12a52cecc3d1164e2d3336c 100755 (executable)
@@ -152,10 +152,20 @@ static int stop_request(conv::Request* requestObj);
 static void _dbusDisconnectListenerFreeCallback(gpointer userData)
 {
        conv::Request *_requestObj = reinterpret_cast<conv::Request *>(userData);
-       if (_requestObj != NULL) {
-               delete _requestObj;
-               _requestObj = NULL;
+       if (_requestObj == NULL) {
+               return;
        }
+
+       conv::AppCommServiceInfo *svcInfo = reinterpret_cast<conv::AppCommServiceInfo*>(_requestObj->getServiceInfo());
+
+       if (svcInfo->registeredRequest != NULL) {
+               delete svcInfo->registeredRequest;
+               svcInfo->registeredRequest = NULL;
+               _D("registeredRequest deleted");
+       }
+
+       delete _requestObj;
+       _requestObj = NULL;
 }
 
 static void _dbusDisconnectListener(GDBusConnection* conn, const gchar* sender, const gchar* path, const gchar* iface, const gchar* name, GVariant* param, gpointer userData)
@@ -190,15 +200,6 @@ static void _dbusDisconnectListener(GDBusConnection* conn, const gchar* sender,
                        } else {
                                _E("requestObj invocation is NULL");
                        }
-
-                       conv::AppCommServiceInfo *svcInfo = reinterpret_cast<conv::AppCommServiceInfo*>(_requestObj->getServiceInfo());
-                       if (svcInfo->registeredRequest != NULL) {
-                               delete svcInfo->registeredRequest;
-                               svcInfo->registeredRequest = NULL;
-                       }
-
-                       delete _requestObj;
-                       _requestObj = NULL;
                }
        } else {
                _E("Not found dbus disconnect listener.");
@@ -380,10 +381,7 @@ static int stop_request(conv::Request* requestObj)
                                _D("COMMUNCATION_STOP : uri : %s, channel_id : %s", uri.c_str(), channelId.c_str());
 
                                if (!requestObj->getIsConnect()) {
-                                       conv::Request *_request = NULL;
-                                       _request = *(appInfo->requestObj);
-                                       if(_request)
-                                               _request->setIsConnect(false);
+                                       appInfo->requestObj = NULL;
                                }
 
                                if (svcInfo->isLocal) {
index 906636e8b484b70b57ae7eaf2f4e37a7c7185823..001c5c3a85de448bc096da5baef44c15ef396e99 100755 (executable)
@@ -823,10 +823,19 @@ static int stop_request(conv::Request* requestObj);
 static void _dbusDisconnectListenerFreeCallback(gpointer userData)
 {
        conv::Request *_requestObj = reinterpret_cast<conv::Request *>(userData);
-       if (_requestObj != NULL) {
-               delete _requestObj;
-               _requestObj = NULL;
+       if (_requestObj == NULL) {
+               return;
        }
+
+       conv::RemoteAppControlServiceInfo *svcInfo = reinterpret_cast<conv::RemoteAppControlServiceInfo*>(_requestObj->getServiceInfo());
+
+       if (svcInfo->registeredRequest != NULL) {
+               delete svcInfo->registeredRequest;
+               svcInfo->registeredRequest = NULL;
+       }
+
+       delete _requestObj;
+       _requestObj = NULL;
 }
 
 static void _dbusDisconnectListener(GDBusConnection* conn, const gchar* sender, const gchar* path, const gchar* iface, const gchar* name, GVariant* param, gpointer userData)
@@ -863,15 +872,6 @@ static void _dbusDisconnectListener(GDBusConnection* conn, const gchar* sender,
                        } else {
                                _E("requestObj invocation is NULL");
                        }
-
-                       conv::RemoteAppControlServiceInfo *svcInfo = reinterpret_cast<conv::RemoteAppControlServiceInfo*>(_requestObj->getServiceInfo());
-                       if (svcInfo->registeredRequest != NULL) {
-                               delete svcInfo->registeredRequest;
-                               svcInfo->registeredRequest = NULL;
-                       }
-
-                       delete _requestObj;
-                       _requestObj = NULL;
                }
        } else {
                _D("Not found dbus disconnect listener.");