[gupnp-tools] av-cp: Don't create an enless loop
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gupnp-tools] av-cp: Don't create an enless loop
- Date: Mon, 8 Oct 2012 14:08:52 +0000 (UTC)
commit 0c38e7503a94ac09bf56ccd851617cb6a145616a
Author: Jens Georg <mail jensge org>
Date: Tue Jan 17 14:43:51 2012 +0100
av-cp: Don't create an enless loop
If the server reports a total_count > 0 but smaller than the returned
children so far, av-cp would enter an endless loop since the unsigned
integer substraction ended up in a rather large remaining number of
items to be fetched.
https://bugzilla.gnome.org/show_bug.cgi?id=668090
src/av-cp/playlist-treeview.c | 34 ++++++++++++++++++++++------------
1 files changed, 22 insertions(+), 12 deletions(-)
---
diff --git a/src/av-cp/playlist-treeview.c b/src/av-cp/playlist-treeview.c
index 51353d8..24f99d1 100644
--- a/src/av-cp/playlist-treeview.c
+++ b/src/av-cp/playlist-treeview.c
@@ -790,7 +790,8 @@ browse_cb (GUPnPServiceProxy *content_dir,
NULL);
if (didl_xml) {
GUPnPDIDLLiteParser *parser;
- guint32 remaining;
+ gint32 remaining;
+ gint32 batch_size;
GError *error;
error = NULL;
@@ -801,14 +802,17 @@ browse_cb (GUPnPServiceProxy *content_dir,
G_CALLBACK (on_didl_object_available),
data);
- if (!gupnp_didl_lite_parser_parse_didl (parser,
- didl_xml,
- &error)) {
- g_warning ("Error while browsing %s: %s",
- data->id,
- error->message);
- g_error_free (error);
- }
+ /* Only try to parse DIDL if server claims that there was a
+ * result */
+ if (number_returned > 0)
+ if (!gupnp_didl_lite_parser_parse_didl (parser,
+ didl_xml,
+ &error)) {
+ g_warning ("Error while browsing %s: %s",
+ data->id,
+ error->message);
+ g_error_free (error);
+ }
g_object_unref (parser);
g_free (didl_xml);
@@ -817,13 +821,19 @@ browse_cb (GUPnPServiceProxy *content_dir,
/* See if we have more objects to get */
remaining = total_matches - data->starting_index;
+
/* Keep browsing till we get each and every object */
- if (remaining != 0)
+ if ((remaining > 0 || total_matches == 0) && number_returned != 0) {
+ if (remaining > 0)
+ batch_size = MIN (remaining, MAX_BROWSE);
+ else
+ batch_size = MAX_BROWSE;
+
browse (content_dir,
data->id,
data->starting_index,
- MIN (remaining, MAX_BROWSE));
- else
+ batch_size);
+ } else
update_container_child_count (content_dir, data->id);
} else if (error) {
GUPnPServiceInfo *info;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]