static __thread GSList *dnssd_handle_list = NULL;
static __thread GSList *resolve_handle_list = NULL;
static __thread bool g_is_init = false;
+static __thread GDBusConnection *netconfig_bus = NULL;
static const char *dnssd_error_to_string(dnssd_error_e error)
{
}
//LCOV_EXCL_START
-static int __dnssd_unref_mdns_dbus(void)
-{
- GDBusConnection *netconfig_bus = NULL;
- GError *g_error = NULL;
-
- DNSSD_LOGD("Request to decrease ref count for mdnsd");
-#if !GLIB_CHECK_VERSION(2, 36, 0)
- g_type_init();
-#endif
- netconfig_bus = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &g_error);
- if (netconfig_bus == NULL) {
- if (g_error != NULL) {
- DNSSD_LOGE("Couldn't connect to system bus "
- "error [%d: %s]", g_error->code, g_error->message);
- g_error_free(g_error);
- }
- return DNSSD_ERROR_OPERATION_FAILED;
- }
-
- g_dbus_connection_call_sync(netconfig_bus,
- NETCONFIG_SERVICE,
- NETCONFIG_NETWORK_PATH,
- NETCONFIG_NETWORK_INTERFACE,
- NETCONFIG_NETWORK_UNREFMDNS,
- NULL,
- NULL,
- G_DBUS_CALL_FLAGS_NONE,
- DBUS_REPLY_TIMEOUT,
- NULL,
- &g_error);
-
- if (g_error != NULL) {
- DNSSD_LOGE("g_dbus_connection_call failed. "
- "error [%d: %s]", g_error->code, g_error->message);
- g_error_free(g_error);
- return DNSSD_ERROR_OPERATION_FAILED;
- }
-
- g_object_unref(netconfig_bus);
-
- return DNSSD_ERROR_NONE;
-
-}
-//LCOV_EXCL_STOP
-
-//LCOV_EXCL_START
static int __dnssd_launch_mdns_dbus(void)
{
- GDBusConnection *netconfig_bus = NULL;
GError *g_error = NULL;
+ GVariant *params;
+ const gchar *name;
#if !GLIB_CHECK_VERSION(2, 36, 0)
g_type_init();
return DNSSD_ERROR_OPERATION_FAILED;
}
+ name = g_dbus_connection_get_unique_name(netconfig_bus);
+ DNSSD_LOGD("Unique DBUS Name %s", name);
+ params = g_variant_new("(s)", name);
g_dbus_connection_call_sync(netconfig_bus,
NETCONFIG_SERVICE,
NETCONFIG_NETWORK_PATH,
NETCONFIG_NETWORK_INTERFACE,
NETCONFIG_NETWORK_LAUNCHMDNS,
- NULL,
+ params,
NULL,
G_DBUS_CALL_FLAGS_NONE,
DBUS_REPLY_TIMEOUT,
return DNSSD_ERROR_OPERATION_FAILED;
}
- g_object_unref(netconfig_bus);
-
DNSSD_LOGD("Successfully launched mdnsresponder");
return DNSSD_ERROR_NONE;
}
g_is_init = false;
- if (__dnssd_unref_mdns_dbus() != DNSSD_ERROR_NONE)
- DNSSD_LOGE("Fail to decrease ref count for mdnsd");
+ g_object_unref(netconfig_bus);
+ netconfig_bus = NULL;
__DNSSD_LOG_FUNC_EXIT__;
return DNSSD_ERROR_NONE;