[SPIN] Fix the connman bugs. 34/74634/2
authorNiraj Kumar Goit <niraj.g@samsung.com>
Wed, 15 Jun 2016 10:09:36 +0000 (15:39 +0530)
committerNiraj Kumar Goit <niraj.g@samsung.com>
Fri, 17 Jun 2016 15:57:27 +0000 (21:27 +0530)
- Fixed NTP service's DNS resolving failure in Hive project.
- Do not turn "wlan0" interface down in cleanup_devices().
- Set resource limits "RLIMIT_NOFILE" for a process.
- After appending a file, fflush and fsync all modified in-core data of the file.

Change-Id: I2767b3302d6204d066fe2075027828ff209d0ee0
Signed-off-by: Niraj Kumar Goit <niraj.g@samsung.com>
gweb/gresolv.c
src/connection.c
src/connman.h
src/device.c
src/dhcp.c
src/main.c
src/resolver.c
src/service.c
src/storage.c
src/wispr.c
src/wpad.c

index 5cf7a9a..93f156e 100755 (executable)
@@ -948,10 +948,12 @@ bool g_resolv_add_nameserver(GResolv *resolv, const char *address,
        nameserver->flags = flags;
        nameserver->resolv = resolv;
 
+       debug(resolv, "");
        if (connect_udp_channel(nameserver) < 0) {
                free_nameserver(nameserver);
                return false;
        }
+       debug(resolv, "");
 
        resolv->nameserver_list = g_list_append(resolv->nameserver_list,
                                                                nameserver);
@@ -1053,6 +1055,8 @@ guint g_resolv_lookup_hostname(GResolv *resolv, const char *hostname,
        lookup->result_data = user_data;
        lookup->id = resolv->next_lookup_id++;
 
+       debug(resolv, "");
+
        if (resolv->result_family != AF_INET6) {
                if (add_query(lookup, hostname, ns_t_a)) {
                        g_free(lookup);
@@ -1060,6 +1064,8 @@ guint g_resolv_lookup_hostname(GResolv *resolv, const char *hostname,
                }
        }
 
+       debug(resolv, "");
+
        if (resolv->result_family != AF_INET) {
                if (add_query(lookup, hostname, ns_t_aaaa)) {
                        if (resolv->result_family != AF_INET6) {
@@ -1073,6 +1079,8 @@ guint g_resolv_lookup_hostname(GResolv *resolv, const char *hostname,
                }
        }
 
+       debug(resolv, "");
+
        g_queue_push_tail(resolv->lookup_queue, lookup);
 
        debug(resolv, "lookup %p id %d", lookup, lookup->id);
index b87625f..0b6dc4a 100755 (executable)
@@ -674,8 +674,15 @@ static void connection_newgateway(int index, const char *gateway)
        }
 
        if (!found) {
+#if defined TIZEN_EXT
+               if (data->ipv4_gateway != NULL){
+                       set_default_gateway(data, CONNMAN_IPCONFIG_TYPE_IPV4);
+                       connman_check_proxy_setup_and_wispr_start(data->service);
+               }
+#else
                if (data->ipv4_gateway)
                        set_default_gateway(data, CONNMAN_IPCONFIG_TYPE_IPV4);
+#endif
 
                if (data->ipv6_gateway)
                        set_default_gateway(data, CONNMAN_IPCONFIG_TYPE_IPV6);
index 6f588bf..26aa7e5 100755 (executable)
@@ -730,6 +730,10 @@ enum connman_service_state __connman_service_ipconfig_get_state(
                                        struct connman_service *service,
                                        enum connman_ipconfig_type type);
 
+#if defined TIZEN_EXT
+void connman_check_proxy_setup_and_wispr_start(struct connman_service *service);
+#endif
+
 int __connman_service_indicate_error(struct connman_service *service,
                                        enum connman_service_error error);
 int __connman_service_clear_error(struct connman_service *service);
index 4d2d540..aff0fa9 100755 (executable)
@@ -1432,6 +1432,9 @@ static void cleanup_devices(void)
 
                DBG("cleaning up %s index %d", interfaces[i], index);
 
+#if defined TIZEN_EXT
+               if (strcmp(interfaces[i], "wlan0") != 0)
+#endif
                connman_inet_ifdown(index);
 
                /*
index bc7deb2..5514c33 100755 (executable)
@@ -192,12 +192,16 @@ static int ipv4ll_start_client(struct connman_dhcp *dhcp)
        if (error != G_DHCP_CLIENT_ERROR_NONE)
                return -EINVAL;
 
+#if !defined TIZEN_EXT
        if (getenv("CONNMAN_DHCP_DEBUG")) {
+#endif
                dhcp->ipv4ll_debug_prefix = g_strdup_printf("IPv4LL index %d",
                                                        index);
                g_dhcp_client_set_debug(ipv4ll_client, dhcp_debug,
                                        dhcp->ipv4ll_debug_prefix);
+#if !defined TIZEN_EXT
        }
+#endif
 
        g_dhcp_client_set_id(ipv4ll_client);
 
@@ -526,12 +530,16 @@ static int dhcp_initialize(struct connman_dhcp *dhcp)
        if (error != G_DHCP_CLIENT_ERROR_NONE)
                return -EINVAL;
 
+#if !defined TIZEN_EXT
        if (getenv("CONNMAN_DHCP_DEBUG")) {
+#endif
                dhcp->dhcp_debug_prefix = g_strdup_printf("DHCP index %d",
                                                        index);
                g_dhcp_client_set_debug(dhcp_client, dhcp_debug,
                                        dhcp->dhcp_debug_prefix);
+#if !defined TIZEN_EXT
        }
+#endif
 
        g_dhcp_client_set_id(dhcp_client);
 
index 5bd7e16..2d91c2f 100755 (executable)
@@ -30,6 +30,8 @@
 #include <string.h>
 #include <signal.h>
 #include <sys/signalfd.h>
+#include <sys/types.h>
+#include <sys/resource.h>
 #include <getopt.h>
 #include <sys/stat.h>
 #include <net/if.h>
@@ -259,6 +261,21 @@ static void check_Tizen_configuration(GKeyFile *config)
 
        g_clear_error(&error);
 }
+
+static void set_nofile_inc(void)
+{
+       int err;
+       struct rlimit rlim;
+
+       rlim.rlim_cur = 8192;
+       rlim.rlim_max = 8192;
+
+       err = setrlimit(RLIMIT_NOFILE, &rlim);
+       if (err)
+               DBG("fail to increase FILENO err(%d)", err);
+
+       return;
+}
 #endif
 
 static void parse_config(GKeyFile *config)
@@ -404,6 +421,9 @@ static int config_init(const char *file)
 {
        GKeyFile *config;
 
+#if defined TIZEN_EXT
+       set_nofile_inc();
+#endif
        config = load_config(file);
        check_config(config);
        parse_config(config);
index 6a64938..fae02a8 100755 (executable)
@@ -356,6 +356,11 @@ static int append_resolver(int index, const char *domain,
        if (!server && !domain)
                return -EINVAL;
 
+#ifdef TIZEN_EXT
+       if (g_strcmp0(server, "0.0.0.0") == 0)
+               return -EINVAL;
+#endif
+
        entry = g_try_new0(struct entry_data, 1);
        if (!entry)
                return -ENOMEM;
index ed59930..2baf871 100755 (executable)
@@ -6746,6 +6746,15 @@ done:
        __connman_wispr_start(service, CONNMAN_IPCONFIG_TYPE_IPV4);
 }
 
+#if defined TIZEN_EXT
+void connman_check_proxy_setup_and_wispr_start(struct connman_service *service){
+
+       DBG("check the proxy and start wispr");
+       check_proxy_setup(service);
+       return;
+}
+#endif
+
 /*
  * How many networks are connected at the same time. If more than 1,
  * then set the rp_filter setting properly (loose mode routing) so that network
@@ -6914,7 +6923,9 @@ int __connman_service_ipconfig_indicate_state(struct connman_service *service,
                }
 #endif
                if (type == CONNMAN_IPCONFIG_TYPE_IPV4) {
+#if !defined TIZEN_EXT
                        check_proxy_setup(service);
+#endif
                        service_rp_filter(service, true);
                } else {
                        service->online_check_count = 1;
index 7d03130..2da54d6 100755 (executable)
@@ -23,6 +23,7 @@
 #include <config.h>
 #endif
 
+#include <stdio.h>
 #include <errno.h>
 #include <unistd.h>
 #include <sys/stat.h>
@@ -73,6 +74,19 @@ static int storage_save(GKeyFile *keyfile, char *pathname)
                ret = -EIO;
        }
 
+#if defined TIZEN_EXT
+       {
+               FILE *fp = NULL;
+               fp = fopen(pathname, "a+");
+               if(fp){
+                       fflush(fp);
+                       fsync(fp->_fileno);
+                       fclose(fp);
+                       DBG("sync the file to disk");
+               }
+       }
+#endif
+
        g_free(data);
 
        return ret;
index 330aa1d..c3b0c9c 100755 (executable)
@@ -879,7 +879,9 @@ static int wispr_portal_detect(struct connman_wispr_portal_context *wp_context)
                goto done;
        }
 
+#if !defined TIZEN_EXT
        if (getenv("CONNMAN_WEB_DEBUG"))
+#endif
                g_web_set_debug(wp_context->web, web_debug, "WEB");
 
        if (wp_context->type == CONNMAN_IPCONFIG_TYPE_IPV4) {
index d40959b..109e9d7 100755 (executable)
@@ -160,7 +160,9 @@ int __connman_wpad_start(struct connman_service *service)
                return -ENOMEM;
        }
 
+#if !defined TIZEN_EXT
        if (getenv("CONNMAN_RESOLV_DEBUG"))
+#endif
                g_resolv_set_debug(wpad->resolv, resolv_debug, "RESOLV");
 
        for (i = 0; nameservers[i]; i++)