Fix memory leak due to sending dbus when no reply 15/198215/1
authorWonnam Jang <wn.jang@samsung.com>
Mon, 14 Jan 2019 12:26:25 +0000 (21:26 +0900)
committerSooyeon Kim <sooyeon.kim@samsung.com>
Tue, 22 Jan 2019 09:41:56 +0000 (09:41 +0000)
Change-Id: I327b07a1e3a658221ccc0bb33ca3512c5657e561
Signed-off-by: Wonnam Jang <wn.jang@samsung.com>
(cherry picked from commit 81c5fa0c165ddd329b5d1f90c7a81d7304ccc3b5)

client/vc_dbus.c
client/vc_mgr_dbus.c
client/vc_widget_dbus.c
server/vcd_dbus_server.c

index ebdce04f019f7bc31814bd0dec3bb987f9685ffd..5ea2841c49513571383f814165b3c1efed536571 100644 (file)
@@ -854,6 +854,7 @@ int vc_dbus_set_foreground(int pid, bool value)
 
        if (1 != dbus_connection_send(g_conn_sender, msg, NULL)) {
                SLOG(LOG_ERROR, TAG_VCC, "[Dbus ERROR] Fail to Send"); //LCOV_EXCL_LINE
+               dbus_message_unref(msg);
                return VC_ERROR_OPERATION_FAILED;
        }
 
@@ -882,6 +883,7 @@ int vc_dbus_set_foreground(int pid, bool value)
 
        if (1 != dbus_connection_send(g_conn_sender, msg, NULL)) {
                SLOG(LOG_ERROR, TAG_VCC, "[Dbus ERROR] Fail to Send"); //LCOV_EXCL_LINE
+               dbus_message_unref(msg);
                return VC_ERROR_OPERATION_FAILED;
        }
 
@@ -1001,6 +1003,7 @@ int vc_dbus_request_dialog(int pid, const char* disp_text, const char* utt_text,
 
        if (1 != dbus_connection_send(g_conn_sender, msg, NULL)) {
                SLOG(LOG_ERROR, TAG_VCC, "[Dbus ERROR] Fail to Send"); //LCOV_EXCL_LINE
+               dbus_message_unref(msg);
                return VC_ERROR_OPERATION_FAILED;
        } else {
                SLOG(LOG_DEBUG, TAG_VCC, "[Dbus DEBUG] Success to Send");
index 68b78f28e3b5c33c391cb5214621233b5531e583..195d2c77af3cb5fd9849f33c64a9ad9e9057b146 100644 (file)
@@ -268,7 +268,7 @@ static Eina_Bool vc_mgr_listener_event_callback(void* data, Ecore_Fd_Handler *fd
 
                        SLOG(LOG_DEBUG, TAG_VCM, "@@@");
 
-               } /* VCD_MANAGER_METHOD_ALL_RESULT */
+               } /* VCD_MANAGER_METHOD_DIALOG */
 
                else if (dbus_message_is_signal(msg, if_name, VCD_MANAGER_METHOD_ERROR)) {
                        SLOG(LOG_INFO, TAG_VCM, "@@@ Get Error");
@@ -304,7 +304,6 @@ static Eina_Bool vc_mgr_listener_event_callback(void* data, Ecore_Fd_Handler *fd
                else if (dbus_message_is_method_call(msg, if_name, VCD_MANAGER_METHOD_SET_PRIVATE_DATA)) {
                        SLOG(LOG_DEBUG, TAG_VCM, "@@@ Get request set private data");
                        int pid = 0;
-                       int ret = -1;
                        char* key = NULL;
                        char* private_data = NULL;
 
@@ -321,28 +320,11 @@ static Eina_Bool vc_mgr_listener_event_callback(void* data, Ecore_Fd_Handler *fd
 
                        if (pid > 0) {
                                SLOG(LOG_DEBUG, TAG_VCM, "@@ vc mgr get request set private data : pid(%d) ", pid);
-                               ret = __vc_mgr_cb_private_data_set(key, private_data);
+                               __vc_mgr_cb_private_data_set(key, private_data);
                        } else {
                                SLOG(LOG_ERROR, TAG_VCM, "@@ vc mgr get request set private data : invalid pid ");
                        }
 
-                       DBusMessage *reply = NULL;
-                       reply = dbus_message_new_method_return(msg);
-
-                       if (NULL != reply) {
-                               dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
-
-                               if (!dbus_connection_send(g_m_conn_listener, reply, NULL))
-                                       SLOG(LOG_ERROR, TAG_VCM, "@@ vc get request set private data : fail to send reply");
-                               else
-                                       SLOG(LOG_DEBUG, TAG_VCM, "@@ vc get request set private data : result(%d)", ret);
-
-                               dbus_connection_flush(g_m_conn_listener);
-                               dbus_message_unref(reply);
-                       } else {
-                               SLOG(LOG_ERROR, TAG_VCM, "@@ vc mgr get request set private data : fail to create reply message");
-                       }
-
                        SLOG(LOG_DEBUG, TAG_VCM, "@@@");
                } /* VCD_MANAGER_METHOD_SET_PRIVATE_DATA */
 
@@ -1814,11 +1796,13 @@ int vc_mgr_dbus_request_do_action(int pid, vc_send_event_type_e type, char* send
 
        if (1 != dbus_connection_send(g_m_conn_sender, msg, NULL)) {
                SLOG(LOG_ERROR, TAG_VCM, "[Dbus ERROR] Fail to Send");
+               dbus_message_unref(msg);
                return -1;
        } else {
                SLOG(LOG_DEBUG, TAG_VCM, "[Dbus] SUCCESS Send");
                dbus_connection_flush(g_m_conn_sender);
        }
+       dbus_message_unref(msg);
 
        return 0;
 }
@@ -2383,11 +2367,13 @@ int vc_mgr_dbus_send_specific_engine_request(int pid, const char* engine_app_id,
 
        if (1 != dbus_connection_send(g_m_conn_sender, msg, NULL)) {
                SLOG(LOG_ERROR, TAG_VCM, "[Dbus ERROR] Fail to Send");
+               dbus_message_unref(msg);
                return -1;
        } else {
                SLOG(LOG_DEBUG, TAG_VCM, "[Dbus] SUCCESS Send");
                dbus_connection_flush(g_m_conn_sender);
        }
+       dbus_message_unref(msg);
 
        return 0;
 }
@@ -2417,11 +2403,13 @@ int vc_mgr_dbus_send_utterance_status(int pid, int utt_id, int utt_status)
 
        if (1 != dbus_connection_send(g_m_conn_sender, msg, NULL)) {
                SLOG(LOG_ERROR, TAG_VCM, "[Dbus ERROR] Fail to Send");
+               dbus_message_unref(msg);
                return -1;
        } else {
                SLOG(LOG_DEBUG, TAG_VCM, "[Dbus] SUCCESS Send");
                dbus_connection_flush(g_m_conn_sender);
        }
+       dbus_message_unref(msg);
 
        return 0;
 }
index 4cd4b9d51d5a3bcbbef7a21db5544cf044c8ec30..52bee5e2046ffcd9e0ec5f5cf1151539964206a3 100644 (file)
@@ -149,22 +149,6 @@ static Eina_Bool widget_listener_event_callback(void* data, Ecore_Fd_Handler *fd
 
                        __vc_widget_cb_result();
 
-                       /*
-                       reply = dbus_message_new_method_return(msg);
-
-                       if (NULL != reply) {
-                               if (!dbus_connection_send(g_w_conn_listener, reply, NULL))
-                                       SLOG(LOG_ERROR, TAG_VCW, "@@ vc widget get result : fail to send reply");
-                               else
-                                       SLOG(LOG_DEBUG, TAG_VCW, "@@ vc widget get result");
-
-                               dbus_connection_flush(g_w_conn_listener);
-                               dbus_message_unref(reply);
-                       } else {
-                               SLOG(LOG_ERROR, TAG_VCW, "@@ vc widget get result : fail to create reply message");
-
-                       */
-
                        SLOG(LOG_DEBUG, TAG_VCW, "@@@");
 
                } /* VCD_WIDGET_METHOD_RESULT */
@@ -781,6 +765,7 @@ int vc_widget_dbus_set_foreground(int pid, bool value)
 
        if (1 != dbus_connection_send(g_w_conn_sender, msg, NULL)) {
                SLOG(LOG_ERROR, TAG_VCW, "[Dbus ERROR] Fail to Send");
+               dbus_message_unref(msg);
                return VC_ERROR_OPERATION_FAILED;
        }
 
@@ -809,6 +794,7 @@ int vc_widget_dbus_set_foreground(int pid, bool value)
 
        if (1 != dbus_connection_send(g_w_conn_sender, msg, NULL)) {
                SLOG(LOG_ERROR, TAG_VCW, "[Dbus ERROR] Fail to Send");
+               dbus_message_unref(msg);
                return VC_ERROR_OPERATION_FAILED;
        }
 
index 2739c5be5c58e6ad4ed1f1ade26287607d55c65d..b1affc8e2e9b41902bed039ce41eb0b4ca24c318 100644 (file)
@@ -535,28 +535,9 @@ int vcd_dbus_server_mgr_set_private_data(DBusConnection* conn, DBusMessage* msg)
        } else {
                SLOG(LOG_DEBUG, TAG_VCD, "[IN] vcd mgr set domain : pid(%d), key(%s), data(%s)", pid, key, data);
                ret = vcd_server_mgr_set_private_data(pid, key, data);
-       }
-
-       DBusMessage* reply;
-       reply = dbus_message_new_method_return(msg);
-
-       if (NULL != reply) {
-               dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
-
-               if (0 == ret) {
-                       SLOG(LOG_DEBUG, TAG_VCD, "[OUT SUCCESS] Result(%d)", ret);
-               } else {
-                       SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret);
+               if (0 != ret) {
+                       SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to set private data");
                }
-
-               if (!dbus_connection_send(conn, reply, NULL)) {
-                       SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Out Of Memory!");
-               }
-
-               dbus_connection_flush(conn);
-               dbus_message_unref(reply);
-       } else {
-               SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Fail to create reply message!!");
        }
 
        SLOG(LOG_DEBUG, TAG_VCD, "@@@");
@@ -750,28 +731,9 @@ int vcd_dbus_server_mgr_do_action(DBusConnection* conn, DBusMessage* msg)
        } else {
                SLOG(LOG_DEBUG, TAG_VCD, "[IN] vcd mgr request to do action : pid(%d), type(%d) send_event(%s)", pid, type, send_event);
                ret = vcd_server_mgr_do_action(pid, type, send_event);
-       }
-
-       DBusMessage* reply;
-       reply = dbus_message_new_method_return(msg);
-
-       if (NULL != reply) {
-               dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
-
-               if (0 == ret) {
-                       SLOG(LOG_DEBUG, TAG_VCD, "[OUT SUCCESS] Result(%d)", ret);
-               } else {
-                       SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret);
+               if (0 != ret) {
+                       SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to do action");
                }
-
-               if (!dbus_connection_send(conn, reply, NULL)) {
-                       SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Out Of Memory!");
-               }
-
-               dbus_connection_flush(conn);
-               dbus_message_unref(reply);
-       } else {
-               SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Fail to create reply message!!");
        }
 
        SLOG(LOG_DEBUG, TAG_VCD, "@@@");
@@ -1054,34 +1016,6 @@ int vcd_dbus_server_mgr_result_selection(DBusConnection* conn, DBusMessage* msg)
                vcd_server_mgr_result_select();
        }
        return 0;
-
-       /*
-       DBusMessage* reply;
-       reply = dbus_message_new_method_return(msg);
-
-       if (NULL != reply) {
-               dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
-
-               if (0 == ret) {
-                       SLOG(LOG_DEBUG, TAG_VCD, "[OUT SUCCESS] Result(%d)", ret);
-               } else {
-                       SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret);
-               }
-
-               if (!dbus_connection_send(conn, reply, NULL)) {
-                       SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Out Of Memory!");
-               }
-
-               dbus_connection_flush(conn);
-               dbus_message_unref(reply);
-       } else {
-               SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Fail to create reply message!!");
-       }
-
-       SLOG(LOG_DEBUG, TAG_VCD, "@@@");
-
-       return 0;
-       */
 }
 
 /* for TTS feedback */
@@ -1659,34 +1593,11 @@ int vcd_dbus_server_dialog(DBusConnection* conn, DBusMessage* msg)
        } else {
                SLOG(LOG_DEBUG, TAG_VCD, "[IN] vcd dialog : pid(%d), disp_text(%s), utt_text(%s), continuous(%d)", pid, disp_text, utt_text, continuous);
                ret = vcd_server_dialog(pid, disp_text, utt_text, continuous);
-       }
-
-       DBusMessage* reply;
-       reply = dbus_message_new_method_return(msg);
-
-       if (NULL != reply) {
-               if (0 == ret) {
-                       /* Append result and language */
-                       dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
-
-                       SLOG(LOG_DEBUG, TAG_VCD, "[OUT SUCCESS] Result(%d)", ret);
-               } else {
-                       dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
-
-                       SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret);
-               }
-
-               if (!dbus_connection_send(conn, reply, NULL)) {
-                       SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Out Of Memory!");
+               if (0 != ret) {
+                       SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to dialog");
                }
-
-               dbus_connection_flush(conn);
-               dbus_message_unref(reply);
-       } else {
-               SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Fail to create reply message!!");
        }
 
-
        SLOG(LOG_DEBUG, TAG_VCD, "@@@");
 
        return 0;