/* Currently, ELDBUS_CONNECTION_TYPE_SYSTEM is being supported */
if (e_dbus_conn->conn && e_dbus_conn->conn_type == type)
- return eldbus_connection_ref(e_dbus_conn->conn);
+ {
+ e_dbus_conn->conn_refcount++;
+ return eldbus_connection_ref(e_dbus_conn->conn);
+ }
return NULL;
}
e_dbus_conn_connection_unref(Eldbus_Connection *conn)
{
if (conn)
- eldbus_connection_unref(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;
+ }
}
static void
static void
_e_dbus_conn_init_thread_heavy(void *data, Ecore_Thread *th, void *msg_data)
{
- 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));
+ E_DBus_Conn *ed_thread = (E_DBus_Conn *)data;
+ int retry_cnt;
- if (!res)
+ if (!ed_thread)
{
- ERR("Failed to allocate memory for E_DBus_Conn thread !\n");
+ ERR("[E_DBus_Conn] Invalid E_DBus_Conn ptr is given ! Thread is going to canceled !");
+ ecore_thread_cancel(th);
return;
}
- *res = EINA_FALSE;
- ed_thread.conn = NULL;
+ retry_cnt = ed_thread->retry_cnt;
+
+ 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, res);
+ ecore_thread_feedback(th, ed_thread);
+
return;
}
static void
_e_dbus_conn_init_thread_notify(void *data, Ecore_Thread *th, void *msg_data)
{
- Eina_Bool *res = (Eina_Bool *)msg_data;
+ E_DBus_Conn *ed_thread = (E_DBus_Conn *)msg_data;
+
+ if (!ed_thread)
+ {
+ ERR("[%s] Invalid E_DBus_Conn ptr !", __FUNCTION__);
+ return;
+ }
- if (res && *res)
+ if (ed_thread->conn)
{
+ 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;
- free(res);
+ INF("E_DBus_Conn connection has been got successfully !");
}
}
_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
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();
e_dbus_conn = ed;
- INF("Succeed to init E_DBus_Conn !");
+ 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);
return _e_dbus_conn_init_count;
}