After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 694450 - Control point doesn't retry to get the description document
Control point doesn't retry to get the description document
Status: RESOLVED FIXED
Product: GUPnP
Classification: Other
Component: gupnp
unspecified
Other Linux
: Normal normal
: ---
Assigned To: GUPnP Maintainers
GUPnP Maintainers
Depends on:
Blocks:
 
 
Reported: 2013-02-22 14:19 UTC by Jozef Šiška
Modified: 2016-06-18 15:17 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Retry getting description url in control point (6.87 KB, patch)
2013-02-22 14:22 UTC, Jozef Šiška
none Details | Review
237182: Retry getting description url in control point (7.28 KB, patch)
2013-02-22 14:32 UTC, Jozef Šiška
needs-work Details | Review
control-point: retry get description url on failure (8.50 KB, patch)
2014-05-29 14:09 UTC, Jens Georg
none Details | Review
control-point: retry get description url on failure (9.47 KB, patch)
2016-06-18 13:08 UTC, Jens Georg
committed Details | Review

Description Jozef Šiška 2013-02-22 14:19:52 UTC
We have come upon a weird situation when we get ssdp notifications from a device that just became available, but for a short time http(tcp) conections to that device fail, ie GUPnPControlPoint reports:
(null)-WARNING: Failed to GET http://192.168.1.157:40166/00000000-0000-0000-0000-001966374ef6.xml: Cannot connect to destination (192.168.1.157)

This means that GUPnPControlPoint receives the resource_available notification, but is unable to retrieve the description url at that time. After such failure, the control point gives up, doesn't try to retrieve the description anymore and is able to properly annouce the device/service only after GSSDP reports it unavailable and then available again (ie after the device restarts).

Steps to Reproduce
1. Have a device that is unable to receive / respond to tcp connections for a short time after it is turned on / starts to announce itself (it is possible to reproduce simply this by dropping all tcp traffic to/from the device when it starts)

Actual Results
GUPnPControlPoint fails to recognize the device/service until it is restarted, even if (tcp) connectivity to the device is restored and ssdp alive packets keep comming in.

Expected Results
GUPnPControlPoint should recognize the device/service as soon as it becomes possible to download the description or when the next ssdp alive notification comes

The attached patch fixes this by retrying to fetch the description until it either succeeds or resource_unavailable for that device/service is received. Not sure if this is the best thing to do. Maybe only retrying when the next ssdp alive comes would be best, but I don't know how to get such information from GSSDPResourceBrowser.
Comment 1 Jozef Šiška 2013-02-22 14:22:30 UTC
Created attachment 237182 [details] [review]
Retry getting description url in control point
Comment 2 Jozef Šiška 2013-02-22 14:32:58 UTC
Created attachment 237187 [details] [review]
237182: Retry getting description url in control point

Fixed patch, I missed a line in the previous one.
Comment 3 Jens Georg 2014-01-16 09:53:12 UTC
Review of attachment 237187 [details] [review]:

Looks good in general. If I read the code correctly, this keeps on retrying to download the document forever? Wouldn't it be better to give up after some tries/time?

::: libgupnp/gupnp-control-point.c
@@ +914,3 @@
+        if (get_data) {
+                get_description_url_data_free (get_data);
+        }

No curlies
Comment 4 Jussi Kukkonen 2014-01-16 15:20:30 UTC
Review of attachment 237187 [details] [review]:

Huh, never noticed this bug before... 

The retry method that has worked for me in other areas is starting with a timeout value and doubling that on failure (stopping at some point still sounds reasonable) -- this way it's OK to start with a small value so the "normal" case of short non-connectivity works as well as possible.

::: libgupnp/gupnp-control-point.c
@@ +126,3 @@
+                if ((strcmp(udn, data->udn) == 0) &&
+                    (service_type == data->service_type) &&
+        GList *l = control_point->priv->pending_gets;

Doesn't this go wrong when service_type is non-NULL?
Comment 5 Jussi Kukkonen 2014-01-16 15:22:16 UTC
(In reply to comment #4)
> Doesn't this go wrong when service_type is non-NULL?

Er, that was supposed to refer to this:
+                if ((strcmp(udn, data->udn) == 0) &&
+                    (service_type == data->service_type) &&
+                    (!service_type || (strcmp(service_type, data->service_type) == 0)))
Comment 6 Jens Georg 2014-01-16 15:31:33 UTC
Review of attachment 237187 [details] [review]:

::: libgupnp/gupnp-control-point.c
@@ +126,3 @@
+                if ((strcmp(udn, data->udn) == 0) &&
+                    (service_type == data->service_type) &&
+                    (!service_type || (strcmp(service_type, data->service_type) == 0)))

Yeah, the boolean is a bit odd here, I think...

Somethink like

(service_type == data->service_type || (service_type && (strcmp(service_type, data->service_type) == 0)))

?
Comment 7 Jens Georg 2014-01-16 15:38:53 UTC
or even

(service_type == data->service_type || g_strcmp0 (service_type,
data->service_type) == 0)
Comment 8 Jens Georg 2014-05-29 14:09:31 UTC
Created attachment 277458 [details] [review]
control-point: retry get description url on failure

Retry 4 times, doubling the intial timeout of 5s

https://bugzilla.gnome.org/show_bug.cgi?id=694450

Signed-off-by: Jens Georg <mail@jensge.org>
Comment 9 Jens Georg 2014-05-29 14:18:44 UTC
Comment on attachment 277458 [details] [review]
control-point: retry get description url on failure

Mh, no, that doesn't work
Comment 10 Jens Georg 2015-07-11 22:24:17 UTC
I love how I documented WHY my last patch does not work -.-
Comment 11 Jens Georg 2016-06-18 13:08:48 UTC
Created attachment 329994 [details] [review]
control-point: retry get description url on failure

Retry 4 times, doubling the intial timeout of 5s

https://bugzilla.gnome.org/show_bug.cgi?id=694450

Signed-off-by: Jens Georg <mail@jensge.org>
Comment 12 Jens Georg 2016-06-18 13:11:19 UTC
Found out what was wrong with the previous patch. The increased timeout and decreased try count wasn't propagated to the next round
Comment 13 Jens Georg 2016-06-18 15:17:35 UTC
Attachment 329994 [details] pushed as cc4550f - control-point: retry get description url on failure