fix
authorChristian Grothoff <christian@grothoff.org>
Thu, 16 Jun 2011 12:05:46 +0000 (12:05 +0000)
committerChristian Grothoff <christian@grothoff.org>
Thu, 16 Jun 2011 12:05:46 +0000 (12:05 +0000)
src/fs/gnunet-service-fs_pr.c

index 10be10e123b3836b1fea22c85b78783aef988693..5e21e35cabf079b9f5628812799d997d964762b3 100644 (file)
 #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)
     {