[rygel-grilo] Add a limit to number of children
- From: Juan A. Suarez Romero <jasuarez src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel-grilo] Add a limit to number of children
- Date: Wed, 12 May 2010 10:00:05 +0000 (UTC)
commit e16dae7840826cb6883c8e132a0b3879dbd5a21a
Author: Juan A. Suarez Romero <jasuarez igalia com>
Date: Wed May 12 11:51:32 2010 +0200
Add a limit to number of children
In spec if user requests Items, ItemCount, Containers or ContainerCount, we
would need to get all children, and then split between items and containers.
As a source can potentially have thousands of elements, it seems that it can
take a huge time to get these values, getting even a dbus timeout in client
side.
Thus, as a protective measure. allow user to specify up to how many children we
would ask plugin. Thus, none of those values will be greater than the limit.
src/rygel-grilo.c | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/src/rygel-grilo.c b/src/rygel-grilo.c
index db70514..c907cc1 100644
--- a/src/rygel-grilo.c
+++ b/src/rygel-grilo.c
@@ -1,4 +1,3 @@
-
/*
* Copyright (C) 2010 Igalia S.L.
*
@@ -44,6 +43,7 @@ static GrlPluginRegistry *registry = NULL;
static gboolean dups;
static gchar **args = NULL;
static gchar *conffile = NULL;
+static gint limit = 0;
static GOptionEntry entries[] = {
{ "config-file", 'c', 0,
@@ -54,6 +54,10 @@ static GOptionEntry entries[] = {
G_OPTION_ARG_NONE, &dups,
"Allow more than one provider with same name",
NULL },
+ { "limit", 'l', 0,
+ G_OPTION_ARG_INT, &limit,
+ "Limit max. number of children for Items/Containers ( 0 = unlimited)",
+ NULL },
{ G_OPTION_REMAINING, '\0', 0,
G_OPTION_ARG_FILENAME_ARRAY, &args,
"Grilo module to load",
@@ -257,7 +261,7 @@ get_items_and_containers (MS1Server *server,
}
children =
- get_children_cb (server, container_id, 0, 0, properties, source, NULL);
+ get_children_cb (server, container_id, 0, (guint) limit, properties, source, NULL);
/* Separate containers from items */
for (child = children; child; child = g_list_next (child)) {
@@ -893,6 +897,9 @@ main (gint argc, gchar **argv)
return -1;
}
+ /* Adjust limit */
+ limit = CLAMP (limit, 0, G_MAXINT);
+
/* Load grilo plugins */
registry = grl_plugin_registry_get_instance ();
if (!registry) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]