guint signal_subscribe_id;
} gdbus_connection_data;
+static int ref_count = 0;
static __thread gdbus_connection_data gdbus_conn = {NULL, 0};
typedef struct {
gpointer user_data);
} wifi_direct_dbus_signal_map_s;
-static __thread wifi_direct_dbus_signal_map_s wifi_direct_dbus_signal_map[] = {
+static wifi_direct_dbus_signal_map_s wifi_direct_dbus_signal_map[] = {
{
0,
WFD_MANAGER_MANAGE_INTERFACE,
return FALSE; //LCOV_EXCL_LINE
}
- /* subscribe signal handler */
- for (i = 0; wifi_direct_dbus_signal_map[i].member != NULL; i++) {
- wifi_direct_dbus_signal_map[i].sub_id =
- g_dbus_connection_signal_subscribe(gdbus_conn.connection,
+ if(ref_count == 0) {
+ /* subscribe signal handler */
+ for (i = 0; wifi_direct_dbus_signal_map[i].member != NULL; i++) {
+ wifi_direct_dbus_signal_map[i].sub_id =
+ g_dbus_connection_signal_subscribe(gdbus_conn.connection,
WFD_MANAGER_SERVICE, /* bus name */
wifi_direct_dbus_signal_map[i].interface, /* interface */
wifi_direct_dbus_signal_map[i].member, /* member */
wifi_direct_dbus_signal_map[i].function,
NULL,
NULL);
- WDC_LOGD("Subscribed dbus signals [%d]", wifi_direct_dbus_signal_map[i].sub_id);
+ WDC_LOGD("Subscribed dbus signals [%d]", wifi_direct_dbus_signal_map[i].sub_id);
+ }
}
+ ref_count++;
return TRUE;
}
void wifi_direct_dbus_deinit(void)
{
+ __WDC_LOG_FUNC_START__;
int i = 0;
if (gdbus_conn.connection == NULL)
return;
- /* unsubscribe signal handler */
- for (i = 0; wifi_direct_dbus_signal_map[i].member != NULL; i++) {
- g_dbus_connection_signal_unsubscribe(gdbus_conn.connection,
- wifi_direct_dbus_signal_map[i].sub_id);
- wifi_direct_dbus_signal_map[i].sub_id = 0;
+ ref_count--;
+ if(ref_count == 0) {
+ /* unsubscribe signal handler */
+ for (i = 0; wifi_direct_dbus_signal_map[i].member != NULL; i++) {
+ g_dbus_connection_signal_unsubscribe(gdbus_conn.connection,
+ wifi_direct_dbus_signal_map[i].sub_id);
+ wifi_direct_dbus_signal_map[i].sub_id = 0;
+ }
}
-
/* unref gdbus connection */
g_object_unref(gdbus_conn.connection);
gdbus_conn.connection = NULL;
+ __WDC_LOG_FUNC_END__;
}
//LCOV_EXCL_START