[PATCH] Don't send interleaved byebye/alive on startup



According to UPnP CTT, there should not be any byebye message after
the device sent an alive message. So we need to group the initial
byebye messages (also requested by the tool, UDA-1.1.3) to come
before the initial alive messages.

Partially fixes UDA-1.1.1 - UDA-1.1.3
---
 libgssdp/gssdp-resource-group.c |   35 +++++++++++++++++++++++++----------
 1 files changed, 25 insertions(+), 10 deletions(-)

diff --git a/libgssdp/gssdp-resource-group.c b/libgssdp/gssdp-resource-group.c
index 7be1a7e..e28766e 100644
--- a/libgssdp/gssdp-resource-group.c
+++ b/libgssdp/gssdp-resource-group.c
@@ -86,7 +86,7 @@ typedef struct {
 
         guint                version;
 
-        gboolean             initial_alive_sent;
+        gboolean             initial_byebye_sent;
 } Resource;
 
 typedef struct {
@@ -132,6 +132,8 @@ static GRegex *
 create_target_regex             (const char         *target,
                                  guint              *version,
                                  GError            **error);
+static void
+send_initial_resource_byebye    (Resource          *resource);
 
 static void
 gssdp_resource_group_init (GSSDPResourceGroup *resource_group)
@@ -483,6 +485,20 @@ gssdp_resource_group_get_message_delay (GSSDPResourceGroup *resource_group)
         return resource_group->priv->message_delay;
 }
 
+static void
+send_initial_resource_byebye (Resource *resource)
+{
+        if (!resource->initial_byebye_sent) {
+                /* Unannounce before first announce. This is
+                   done to minimize the possibility of
+                   control points thinking that this is just
+                   a reannouncement. */
+                resource_byebye (resource);
+
+                resource->initial_byebye_sent = TRUE;
+        }
+}
+
 /**
  * gssdp_resource_group_set_available
  * @resource_group: A #GSSDPResourceGroup
@@ -532,6 +548,11 @@ gssdp_resource_group_set_available (GSSDPResourceGroup *resource_group,
 
                 g_source_unref (resource_group->priv->timeout_src);
 
+                /* Make sure initial byebyes are sent grouped before initial
+                 * alives */
+                for (l = resource_group->priv->resources; l; l = l->next)
+                        send_initial_resource_byebye (l->data);
+
                 /* Announce all resources */
                 for (l = resource_group->priv->resources; l; l = l->next)
                         resource_alive (l->data);
@@ -609,7 +630,7 @@ gssdp_resource_group_add_resource (GSSDPResourceGroup *resource_group,
                 return 0;
         }
 
-        resource->initial_alive_sent = FALSE;
+        resource->initial_byebye_sent = FALSE;
 
         for (l = locations; l; l = l->next) {
                 resource->locations = g_list_append (resource->locations,
@@ -992,14 +1013,8 @@ resource_alive (Resource *resource)
         guint max_age;
         char *al, *message;
 
-        if (!resource->initial_alive_sent) {
-                /* Unannounce before first announce. This is done to
-                   minimize the possibility of control points thinking
-                   that this is just a reannouncement. */
-                resource_byebye (resource);
-
-                resource->initial_alive_sent = TRUE;
-        }
+        /* Send initial byebye if not sent already */
+        send_initial_resource_byebye (resource);
 
         /* Send message */
         client = resource->resource_group->priv->client;
-- 
1.7.5.2



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]