Details about the Patch
by Natarajan, Ponniah (P.)
Hi,
Please let me know whether this patch as part of below link has been considered for release? Or any other mechanism is handled in current connman release v1.32
http://permalink.gmane.org/gmane.comp.handhelds.moblin.connman/18794
We are observing similar issue with connman v1.31, where sometimes upon power on of the device, settings of connman for wifi shows as "True", but when run the connmanctl to get the technology state shows the Powered state as "False"
Regards,
Ponniah Natarajan.
------------------------------------
Visteon Electronics, India.
Ph Off : +91-44-49477650
Mob : +91-98401-08041
------------------------------------
4 years, 7 months
[PATCH] storage: write to settings file only when there is a change.
by Feng Wang
Minimize writes to the settings file such that there is only a write
when the data to br written has changed relative to the existed file.
---
src/storage.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 72 insertions(+), 5 deletions(-)
diff --git a/src/storage.c b/src/storage.c
index 7d03130..d78a045 100644
--- a/src/storage.c
+++ b/src/storage.c
@@ -58,6 +58,71 @@ static GKeyFile *storage_load(const char *pathname)
return keyfile;
}
+static bool storage_changed(GKeyFile *keyfile, char *pathname, gchar *data, int length)
+{
+ GKeyFile *oldkeyfile = NULL;
+ gchar *olddata = NULL;
+ gsize oldlen = 0;
+ char id[100];
+ char *str, **strlist;
+ bool changed = false;
+
+ /* Get the service identifier pathname = "STORAGEDIR/id/settings" */
+ strcpy(id, pathname + strlen(STORAGEDIR) + 1);
+ str = strstr(id, SETTINGS);
+ if (str)
+ *(str-1) = 0;
+
+ /* Get existed configuration data on the disk */
+ oldkeyfile = storage_load(pathname);
+ if (oldkeyfile) {
+ /* Don't compare Domains if it is not in the current configuration */
+ str = g_key_file_get_string(keyfile, id, "Domains", NULL);
+ if (!str)
+ g_key_file_remove_key(oldkeyfile, id, "Domains", NULL);
+ else
+ g_free(str);
+
+ /* Set old Modified time same as current modified time */
+ str = g_key_file_get_string(keyfile, id, "Modified", NULL);
+ if (str) {
+ g_key_file_set_string(oldkeyfile, id, "Modified", str);
+ g_free(str);
+ } else
+ g_key_file_remove_key(oldkeyfile, id, "Modified", NULL);
+
+ /* Don't compare DHCP configurations if not in the current configuration */
+ str = g_key_file_get_string(keyfile, id, "IPv4.DHCP.LastAddress", NULL);
+ if (!str)
+ g_key_file_remove_key(oldkeyfile, id, "IPv4.DHCP.LastAddress", NULL);
+ else
+ g_free(str);
+
+ str = g_key_file_get_string(keyfile, id, "IPv6.DHCP.LastAddress", NULL);
+ if (!str)
+ g_key_file_remove_key(oldkeyfile, id, "IPv6.DHCP.LastAddress", NULL);
+ else
+ g_free(str);
+
+ strlist = g_key_file_get_string_list(keyfile, id, "IPv6.DHCP.LastPrefixes",
+ &oldlen, NULL);
+ if (!strlist)
+ g_key_file_remove_key(oldkeyfile, id, "IPv6.DHCP.LastPrefixes", NULL);
+ else
+ g_strfreev(strlist);
+
+ olddata = g_key_file_to_data(oldkeyfile, &oldlen, NULL);
+ g_key_file_free(oldkeyfile);
+ }
+
+ if (oldlen != length || memcmp(data, olddata, length))
+ changed = true;
+
+ g_free(olddata);
+
+ return changed;
+}
+
static int storage_save(GKeyFile *keyfile, char *pathname)
{
gchar *data = NULL;
@@ -66,11 +131,13 @@ static int storage_save(GKeyFile *keyfile, char *pathname)
int ret = 0;
data = g_key_file_to_data(keyfile, &length, NULL);
-
- if (!g_file_set_contents(pathname, data, length, &error)) {
- DBG("Failed to store information: %s", error->message);
- g_error_free(error);
- ret = -EIO;
+ if (storage_changed(keyfile, pathname, data, length)) {
+ connman_info("storage_save file %s len %d", pathname, length);
+ if (!g_file_set_contents(pathname, data, length, &error)) {
+ DBG("Failed to store information: %s", error->message);
+ g_error_free(error);
+ ret = -EIO;
+ }
}
g_free(data);
--
2.8.0.rc3.226.g39d4020
4 years, 7 months
[PATCH] dhcpv6: use correct dhcp renew time when valid life-time is infinity.
by Feng Wang
Based on RFC 3315, 22.6, the valid life-time is infinite when its
value is 0xffffffff. In the g_dhcpv6_client_get_timeouts, the expire
data type is time_t. If time_t is uint32, the last_request time plus
0xffffffff will wrapover so that expire time is smaller than current
time. Thus the dhcpv6 will restart immediately(dhcpv6_restart called).
---
gdhcp/client.c | 9 +++++++--
src/dhcpv6.c | 6 +++++-
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/gdhcp/client.c b/gdhcp/client.c
index 9012b38..2be3982 100644
--- a/gdhcp/client.c
+++ b/gdhcp/client.c
@@ -835,8 +835,13 @@ int g_dhcpv6_client_get_timeouts(GDHCPClient *dhcp_client,
if (started)
*started = dhcp_client->last_request;
- if (expire)
- *expire = dhcp_client->last_request + dhcp_client->expire;
+ if (expire) {
+ if (dhcp_client->expire == 0xffffffff)
+ /* RFC3315 22.6 infinite valid-lifetime */
+ *expire = 0xffffffff;
+ else
+ *expire = dhcp_client->last_request + dhcp_client->expire;
+ }
return 0;
}
diff --git a/src/dhcpv6.c b/src/dhcpv6.c
index 9e21040..cd5733a 100644
--- a/src/dhcpv6.c
+++ b/src/dhcpv6.c
@@ -1195,7 +1195,7 @@ static int check_restart(struct connman_dhcpv6 *dhcp)
NULL, &expired);
current = time(NULL);
- if (current >= expired) {
+ if (current >= expired && expired != 0xffffffff) {
DBG("expired by %d secs", (int)(current - expired));
g_timeout_add(0, dhcpv6_restart, dhcp);
@@ -1442,6 +1442,10 @@ int __connman_dhcpv6_start_renew(struct connman_network *network,
/* RFC 3315, 22.4
* Client can choose the timeout.
*/
+ if (expired == 0xffffffff) {
+ /* RFC 3315, 22.6 infinite valid-lifetime */
+ return 0;
+ }
T1 = (expired - started) / 2;
T2 = (expired - started) / 10 * 8;
}
--
2.8.0.rc3.226.g39d4020
4 years, 7 months