Revert "e_dbus_conn: do eldbus_connection_unref in the main thread, add a logic to... 39/198839/1
authorSung-Jin Park <sj76.park@samsung.com>
Thu, 24 Jan 2019 09:50:59 +0000 (18:50 +0900)
committerSung-Jin Park <sj76.park@samsung.com>
Wed, 30 Jan 2019 08:17:26 +0000 (08:17 +0000)
This reverts commit b5d331adc26b91154b3b4ca1727e8e750b7bf11d.

Change-Id: I99e3028b2ac71a4617e4442fa09812d8f00b0f47
(cherry picked from commit 14b875dfbfefe854312140b22e523b09e1235547)

src/bin/e_dbus_conn.c
src/bin/e_dbus_conn.h

index ad0aef06c99f67d79ed1acf33a77a64150ea35d3..984616083ee760ff9fe05d29abdf419970219bbf 100644 (file)
@@ -22,10 +22,7 @@ e_dbus_conn_connection_ref(Eldbus_Connection_Type type)
    /* Currently, ELDBUS_CONNECTION_TYPE_SYSTEM is being supported */
 
    if (e_dbus_conn->conn && e_dbus_conn->conn_type == type)
-     {
-        e_dbus_conn->conn_refcount++;
-        return eldbus_connection_ref(e_dbus_conn->conn);
-     }
+     return eldbus_connection_ref(e_dbus_conn->conn);
 
    return NULL;
 }
@@ -34,16 +31,7 @@ E_API void
 e_dbus_conn_connection_unref(Eldbus_Connection *conn)
 {
    if (conn)
-     {
-        if (e_dbus_conn->conn_refcount <= 0)
-          {
-             ERR("Invalid unreference of e_dbus_conn ! (conn_refcount=%d)", e_dbus_conn->conn_refcount);
-             return;
-          }
-
-        eldbus_connection_unref(conn);
-        --e_dbus_conn->conn_refcount;
-     }
+     eldbus_connection_unref(conn);
 }
 
 static void
@@ -80,56 +68,50 @@ _e_dbus_conn_init_done_send(E_DBus_Conn *ed)
 static void
 _e_dbus_conn_init_thread_heavy(void *data, Ecore_Thread *th, void *msg_data)
 {
-   E_DBus_Conn *ed_thread = (E_DBus_Conn *)data;
-   int retry_cnt;
+   Eina_Bool *res = NULL;
+   E_DBus_Conn ed_thread = *(E_DBus_Conn *)data;
+   int retry_cnt = ed_thread.retry_cnt;
+
+   res = calloc(1, sizeof(Eina_Bool));
 
-   if (!ed_thread)
+   if (!res)
      {
-        ERR("[E_DBus_Conn] Invalid E_DBus_Conn ptr is given ! Thread is going to canceled !");
-        ecore_thread_cancel(th);
+        ERR("Failed to allocate memory for E_DBus_Conn thread !\n");
         return;
      }
 
-   retry_cnt = ed_thread->retry_cnt;
-
-   ed_thread->conn = NULL;
+   *res = EINA_FALSE;
+   ed_thread.conn = NULL;
 
    while (retry_cnt--)
      {
-        ed_thread->conn = eldbus_connection_get(ed_thread->conn_type);
+        ed_thread.conn = eldbus_connection_get(ed_thread.conn_type);
 
-        if (ed_thread->conn)
+        if (ed_thread.conn)
           {
+             eldbus_connection_unref(ed_thread.conn);
+             *res = EINA_TRUE;
              break;
           }
 
-        if (ed_thread->retry_intervals)
-          usleep(ed_thread->retry_intervals);
+        if (ed_thread.retry_intervals)
+          usleep(ed_thread.retry_intervals);
      }
 
-   ecore_thread_feedback(th, ed_thread);
-
+   ecore_thread_feedback(th, res);
    return;
 }
 
 static void
 _e_dbus_conn_init_thread_notify(void *data, Ecore_Thread *th, void *msg_data)
 {
-   E_DBus_Conn *ed_thread = (E_DBus_Conn *)msg_data;
-
-   if (!ed_thread)
-     {
-        ERR("[%s] Invalid E_DBus_Conn ptr !", __FUNCTION__);
-        return;
-     }
+   Eina_Bool *res = (Eina_Bool *)msg_data;
 
-   if (ed_thread->conn)
+   if (res && *res)
      {
-        eldbus_connection_unref(ed_thread->conn);
-
         e_dbus_conn->conn = eldbus_connection_get(e_dbus_conn->conn_type);
         if (e_dbus_conn->conn) e_dbus_conn->init_status = E_DBUS_CONN_INIT_SUCCESS;
-        INF("E_DBus_Conn connection has been got successfully !");
+        free(res);
      }
 }
 
@@ -137,8 +119,6 @@ static void
 _e_dbus_conn_init_thread_end(void *data, Ecore_Thread *th, void *msg_data)
 {
    _e_dbus_conn_init_done_send(e_dbus_conn);
-
-   INF("E_DBus_Conn thread has been ended successfully !");
 }
 
 static void
@@ -260,7 +240,6 @@ e_dbus_conn_init(void)
    ed->retry_cnt = E_DBUS_CONN_DEFAULT_RETRY_COUNT;
    ed->init_status = E_DBUS_CONN_INIT_YET_STARTED;
    ed->retry_intervals = 0;
-   ed->conn_refcount = 0;
 
    E_EVENT_DBUS_CONN_INIT_DONE = ecore_event_type_new();
 
@@ -297,8 +276,7 @@ e_dbus_conn_init(void)
 
    e_dbus_conn = ed;
 
-   INF("Succeed to init E_DBus_Conn ! (use_thread=%d, retry_intervals=%d, retry_cnt=%d)",
-                                                  ed->use_thread, ed->retry_intervals, ed->retry_cnt);
+   INF("Succeed to init E_DBus_Conn !");
 
    return _e_dbus_conn_init_count;
 }
index a5bf7a56e9e976f7b58729f1c84c359b0f39bb62..83b1ba531b66ff3010bb564ea8b342eed06b0747 100644 (file)
@@ -32,7 +32,6 @@ struct _E_DBus_Conn
    Eldbus_Connection *conn;
    Eldbus_Connection_Type conn_type;
    unsigned int retry_intervals; /* suspend re-connection for microsecond intervals */
-   unsigned int conn_refcount;
 };
 
 typedef struct _E_DBus_Conn_Init_Done_Event E_DBus_Conn_Init_Done_Event;