From a59c6e4a0176ca9ad05c1980dcebfbb07b8a188f Mon Sep 17 00:00:00 2001 From: Niraj Kumar Goit Date: Wed, 15 Jun 2016 15:39:36 +0530 Subject: [PATCH] [SPIN] Fix the connman bugs. - 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 --- gweb/gresolv.c | 8 ++++++++ src/connection.c | 7 +++++++ src/connman.h | 4 ++++ src/device.c | 3 +++ src/dhcp.c | 8 ++++++++ src/main.c | 20 ++++++++++++++++++++ src/resolver.c | 5 +++++ src/service.c | 11 +++++++++++ src/storage.c | 14 ++++++++++++++ src/wispr.c | 2 ++ src/wpad.c | 2 ++ 11 files changed, 84 insertions(+) diff --git a/gweb/gresolv.c b/gweb/gresolv.c index 5cf7a9a..93f156e 100755 --- a/gweb/gresolv.c +++ b/gweb/gresolv.c @@ -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); diff --git a/src/connection.c b/src/connection.c index b87625f..0b6dc4a 100755 --- a/src/connection.c +++ b/src/connection.c @@ -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); diff --git a/src/connman.h b/src/connman.h index 6f588bf..26aa7e5 100755 --- a/src/connman.h +++ b/src/connman.h @@ -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); diff --git a/src/device.c b/src/device.c index 4d2d540..aff0fa9 100755 --- a/src/device.c +++ b/src/device.c @@ -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); /* diff --git a/src/dhcp.c b/src/dhcp.c index bc7deb2..5514c33 100755 --- a/src/dhcp.c +++ b/src/dhcp.c @@ -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); diff --git a/src/main.c b/src/main.c index 5bd7e16..2d91c2f 100755 --- a/src/main.c +++ b/src/main.c @@ -30,6 +30,8 @@ #include #include #include +#include +#include #include #include #include @@ -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); diff --git a/src/resolver.c b/src/resolver.c index 6a64938..fae02a8 100755 --- a/src/resolver.c +++ b/src/resolver.c @@ -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; diff --git a/src/service.c b/src/service.c index ed59930..2baf871 100755 --- a/src/service.c +++ b/src/service.c @@ -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; diff --git a/src/storage.c b/src/storage.c index 7d03130..2da54d6 100755 --- a/src/storage.c +++ b/src/storage.c @@ -23,6 +23,7 @@ #include #endif +#include #include #include #include @@ -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; diff --git a/src/wispr.c b/src/wispr.c index 330aa1d..c3b0c9c 100755 --- a/src/wispr.c +++ b/src/wispr.c @@ -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) { diff --git a/src/wpad.c b/src/wpad.c index d40959b..109e9d7 100755 --- a/src/wpad.c +++ b/src/wpad.c @@ -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++) -- 2.7.4