From 774fb63daa28f0effa2742ab894f55c2bc3aee39 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 16 Jun 2011 12:05:46 +0000 Subject: [PATCH] fix --- src/fs/gnunet-service-fs_pr.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/fs/gnunet-service-fs_pr.c b/src/fs/gnunet-service-fs_pr.c index 10be10e12..5e21e35ca 100644 --- a/src/fs/gnunet-service-fs_pr.c +++ b/src/fs/gnunet-service-fs_pr.c @@ -31,6 +31,10 @@ #include "gnunet-service-fs_pe.h" #include "gnunet-service-fs_pr.h" +/** + * Hard limit on the number of results we may get from the datastore per query. + */ +#define MAX_RESULTS (100 * 1024) /** * An active request. @@ -141,7 +145,7 @@ struct GSF_PendingRequest /** * Do we have a first UID yet? */ - int have_first_uid; + unsigned int have_first_uid; }; @@ -1145,7 +1149,7 @@ process_local_reply (void *cls, if (GNUNET_NO == pr->have_first_uid) { pr->first_uid = uid; - pr->have_first_uid = GNUNET_YES; + pr->have_first_uid = 1; } else { @@ -1157,6 +1161,15 @@ process_local_reply (void *cls, GNUNET_NO); key = NULL; /* all replies seen! */ } + pr->have_first_uid++; + if (pr->have_first_uid > MAX_RESULTS) + { + GNUNET_STATISTICS_update (GSF_stats, + gettext_noop ("# Datastore lookups aborted (more than MAX_RESULTS)"), + 1, + GNUNET_NO); + key = NULL; /* all replies seen! */ + } } if (NULL == key) { -- 2.25.1