session: Add session argument to create_service_entry_cb
authorDaniel Wagner <daniel.wagner@bmw-carit.de>
Fri, 31 May 2013 07:13:26 +0000 (09:13 +0200)
committerPatrik Flykt <patrik.flykt@linux.intel.com>
Fri, 31 May 2013 11:35:44 +0000 (14:35 +0300)
Remember which session this struct service_entry belongs to when
removing the entries again.

src/connman.h
src/service.c
src/session.c

index 1e6bfec..f4de887 100644 (file)
@@ -714,6 +714,7 @@ struct service_entry;
 typedef connman_bool_t (* service_match_cb) (struct connman_session *session,
                                        struct connman_service *service);
 typedef struct service_entry* (* create_service_entry_cb) (
+                                       struct connman_session *session,
                                        struct connman_service *service,
                                        const char *name,
                                        enum connman_service_state state);
index af8bfce..3d03b2c 100644 (file)
@@ -2145,8 +2145,8 @@ GSequence *__connman_service_get_list(struct connman_session *session,
                service = g_sequence_get(iter);
 
                if (service_match(session, service) == TRUE) {
-                       entry = create_service_entry(service, service->name,
-                                                       service->state);
+                       entry = create_service_entry(session, service,
+                                               service->name, service->state);
                        if (entry == NULL)
                                return list;
 
index e5d8d85..0ac73c7 100644 (file)
@@ -60,6 +60,7 @@ enum connman_session_state {
 };
 
 struct service_entry {
+       struct connman_session *session;
        /* track why this service was selected */
        enum connman_session_reason reason;
        enum connman_service_state state;
@@ -1206,7 +1207,8 @@ static void select_and_connect(struct connman_session *session,
        }
 }
 
-static struct service_entry *create_service_entry(struct connman_service *service,
+static struct service_entry *create_service_entry(struct connman_session * session,
+                                       struct connman_service *service,
                                        const char *name,
                                        enum connman_service_state state)
 {
@@ -1234,6 +1236,8 @@ static struct service_entry *create_service_entry(struct connman_service *servic
        type = connman_service_get_type(entry->service);
        entry->bearer = service2bearer(type);
 
+       entry->session = session;
+
        return entry;
 }
 
@@ -1939,7 +1943,7 @@ static void service_add(struct connman_service *service,
                if (service_match(session, service) == FALSE)
                        continue;
 
-               entry = create_service_entry(service, name,
+               entry = create_service_entry(session, service, name,
                                                CONNMAN_SERVICE_STATE_IDLE);
                if (entry == NULL)
                        continue;