Revised to reduce the launch delay of mdnsresponder 60/82160/1 accepted/tizen/common/20160805.125955 accepted/tizen/ivi/20160809.010808 accepted/tizen/mobile/20160809.010714 accepted/tizen/tv/20160809.010726 accepted/tizen/wearable/20160809.010747 submit/tizen/20160805.043523
authorchleun.moon <chleun.moon@samsung.com>
Mon, 1 Aug 2016 08:12:13 +0000 (17:12 +0900)
committerchleun.moon <chleun.moon@samsung.com>
Mon, 1 Aug 2016 08:12:45 +0000 (17:12 +0900)
It causes large delay to check whether the mdnsd is alive or not by
querying the version of mdnsresponder when the mdnsd daemon is not
loaded.

Change-Id: I8c37f4e0bfa05c27698cd0c2399382c9b7054548

src/dns-sd/dns-sd.c

index 1941d5d..3425bd5 100644 (file)
@@ -70,53 +70,6 @@ static bool __dnssd_is_init(void)
 }
 
 //LCOV_EXCL_START
-static int __dnssd_ref_mdns_dbus(void)
-{
-       GDBusConnection *netconfig_bus = NULL;
-       GError *g_error = NULL;
-
-       DNSSD_LOGD("Request to increase 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_REFMDNS,
-                       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_unref_mdns_dbus(void)
 {
        GDBusConnection *netconfig_bus = NULL;
@@ -210,35 +163,12 @@ static int __dnssd_launch_mdns_dbus(void)
 //LCOV_EXCL_START
 static int __dnssd_launch_mdns()
 {
+       __DNSSD_LOG_FUNC_ENTER__;
        int res = DNSSD_ERROR_NONE;
-       int dnssd_err = 0;
-       int retry_count = DNSSD_MDNSD_LAUNCH_RETRY_THRESHOLD;
-       uint32_t version = 0;
-       uint32_t size = sizeof(version);
-
-       while (retry_count >= 0) {
-               dnssd_err = DNSServiceGetProperty(kDNSServiceProperty_DaemonVersion, &version, &size);
-               if (!dnssd_err) {
-                       DNSSD_LOGD("Daemon is running ver. %d.%d", version / 10000, version / 100 % 100);
-
-                       res = __dnssd_ref_mdns_dbus();
-                       if (res != DNSSD_ERROR_NONE)
-                               DNSSD_LOGE("Fail to increase ref count for mdnsd");
-                       else
-                               break;
-               } else {
-                       DNSSD_LOGE("Daemon is not running");
-               }
-
-               DNSSD_LOGD("Launching mdnsresponder. retry count: %d", retry_count);
-               res = __dnssd_launch_mdns_dbus();
-               if (res != DNSSD_ERROR_NONE)
-                       DNSSD_LOGE("Fail to send dbus msg");
-               retry_count--;
-
-               /* wait a little before retrying the next trial */
-               usleep(DNSSD_MDNSD_LAUNCH_TRIAL_INTERVAL);
-       }
+       res = __dnssd_launch_mdns_dbus();
+       if (res != DNSSD_ERROR_NONE)
+               DNSSD_LOGE("Fail to send dbus msg");
+       __DNSSD_LOG_FUNC_EXIT__;
        return res;
 }
 //LCOV_EXCL_STOP