[PATCH 02/11] session: do not notify about service info if there is none

Tomasz Bursztyka tomasz.bursztyka at linux.intel.com
Fri Feb 3 02:38:57 PST 2012


It is an optimization on the content notified from a session. We will
assume that Name/Bearer/Interface/Ipv* do not need to be part of
notification they are empty (when session is in disconnected mode).
---
 src/session.c |   28 +++++++---------------------
 1 files changed, 7 insertions(+), 21 deletions(-)

diff --git a/src/session.c b/src/session.c
index 5791205..c6c5b08 100644
--- a/src/session.c
+++ b/src/session.c
@@ -371,8 +371,6 @@ static void append_notify(DBusMessageIter *dict,
 	struct session_info *info = session->info;
 	struct session_info *info_last = session->info_last;
 	const char *policy;
-	struct connman_service *service;
-	const char *name, *ifname, *bearer;
 
 	if (session->append_all == TRUE ||
 			info->state != info_last->state) {
@@ -384,39 +382,27 @@ static void append_notify(DBusMessageIter *dict,
 		info_last->state = info->state;
 	}
 
-	if (session->append_all == TRUE ||
-			info->entry != info_last->entry) {
-		if (info->entry == NULL) {
-			name = "";
-			ifname = "";
-			service = NULL;
-			bearer = "";
-		} else {
-			name = info->entry->name;
-			ifname = info->entry->ifname;
-			service = info->entry->service;
-			bearer = info->entry->bearer;
-		}
-
+	if ((session->append_all == TRUE || info->entry != info_last->entry) &&
+			info->entry != NULL) {
 		connman_dbus_dict_append_basic(dict, "Name",
 						DBUS_TYPE_STRING,
-						&name);
+						&info->entry->name);
 
 		connman_dbus_dict_append_dict(dict, "IPv4",
 						append_ipconfig_ipv4,
-						service);
+						info->entry->service);
 
 		connman_dbus_dict_append_dict(dict, "IPv6",
 						append_ipconfig_ipv6,
-						service);
+						info->entry->service);
 
 		connman_dbus_dict_append_basic(dict, "Interface",
 						DBUS_TYPE_STRING,
-						&ifname);
+						&info->entry->ifname);
 
 		connman_dbus_dict_append_basic(dict, "Bearer",
 						DBUS_TYPE_STRING,
-						&bearer);
+						&info->entry->bearer);
 
 		info_last->entry = info->entry;
 	}
-- 
1.7.8.4




More information about the connman mailing list