fix
authorChristian Grothoff <christian@grothoff.org>
Thu, 21 Apr 2011 13:29:22 +0000 (13:29 +0000)
committerChristian Grothoff <christian@grothoff.org>
Thu, 21 Apr 2011 13:29:22 +0000 (13:29 +0000)
src/fs/fs_download.c
src/fs/gnunet-service-fs_cp.c
src/fs/gnunet-service-fs_lc.c
src/fs/gnunet-service-fs_pr.c
src/fs/gnunet-service-fs_pr.h

index 8192b8c1f693b5d391f3cebc060369cce77926b6..785803edfea3a7b29fb5d55b9c314a8d0800fa3b 100644 (file)
@@ -31,7 +31,7 @@
 #include "fs.h"
 #include "fs_tree.h"
 
-#define DEBUG_DOWNLOAD GNUNET_NO
+#define DEBUG_DOWNLOAD GNUNET_YES
 
 /**
  * Determine if the given download (options and meta data) should cause
index 92461e4778b93ddf320d2ae10366ca3755e362a4..5aba8329828ee1f9b21661c95926199fd0cf0e0a 100644 (file)
@@ -616,6 +616,7 @@ copy_reply (void *cls,
  *
  * @param cls 'struct GSF_ConnectedPeer' of the peer that would
  *            have liked an answer to the request
+ * @param eval evaluation of the result
  * @param pr handle to the original pending request
  * @param expiration when does 'data' expire?
  * @param type type of the block
@@ -624,6 +625,7 @@ copy_reply (void *cls,
  */
 static void
 handle_p2p_reply (void *cls,
+                 enum GNUNET_BLOCK_EvaluationResult eval,
                  struct GSF_PendingRequest *pr,
                  struct GNUNET_TIME_Absolute expiration,
                  enum GNUNET_BLOCK_Type type,
@@ -683,6 +685,17 @@ handle_p2p_reply (void *cls,
                             msize,
                             &copy_reply,
                             pm);
+  if (eval != GNUNET_BLOCK_EVALUATION_OK_LAST)
+    return;
+  GNUNET_STATISTICS_update (GSF_stats,
+                           gettext_noop ("# P2P searches active"),
+                           -1,
+                           GNUNET_NO);
+  GNUNET_break (GNUNET_OK ==
+               GNUNET_CONTAINER_multihashmap_remove (cp->request_map,
+                                                     &prd->query,
+                                                     pr));
+  GSF_pending_request_cancel_ (pr);
 }
 
 
index 3908b8a558b4ec6218f0969e298863988cf1849a..58a1a0933a7dc6cbdd8a5054217620873ac2ec0e 100644 (file)
@@ -188,6 +188,7 @@ GSF_local_client_lookup_ (struct GNUNET_SERVER_Client *client)
  * expiration.
  *
  * @param cls user-specified closure
+ * @param eval evaluation of the result
  * @param pr handle to the original pending request
  * @param expiration when does 'data' expire? 
  * @param type type of the block
@@ -196,6 +197,7 @@ GSF_local_client_lookup_ (struct GNUNET_SERVER_Client *client)
  */
 static void
 client_response_handler (void *cls,
+                        enum GNUNET_BLOCK_EvaluationResult eval,
                         struct GSF_PendingRequest *pr,
                         struct GNUNET_TIME_Absolute expiration,
                         enum GNUNET_BLOCK_Type type,
@@ -242,6 +244,18 @@ client_response_handler (void *cls,
              GNUNET_h2s (&prd->query),
              (unsigned int) prd->type);
 #endif
+  if (eval != GNUNET_BLOCK_EVALUATION_OK_LAST)
+    return;
+  GNUNET_CONTAINER_DLL_remove (lc->cr_head,
+                              lc->cr_tail,
+                              cr);
+  GSF_pending_request_cancel_ (cr->pr);
+  GNUNET_STATISTICS_update (GSF_stats,
+                           gettext_noop ("# client searches active"),
+                           - 1,
+                           GNUNET_NO);
+  GNUNET_free (cr);
+
 }
 
 
index f8ca828003e7b927047b3a8abaf66d72bc5f73ae..f327d9b4b301b93d06329b6642d2581819249b31 100644 (file)
@@ -338,6 +338,7 @@ GSF_pending_request_create_ (enum GSF_PendingRequestOptions options,
          if (pr == dpr)
            break; /* let the request live briefly... */
          dpr->rh (dpr->rh_cls,
+                  GNUNET_BLOCK_EVALUATION_REQUEST_VALID,
                   dpr,
                   GNUNET_TIME_UNIT_FOREVER_ABS,
                   GNUNET_BLOCK_TYPE_ANY,
@@ -705,11 +706,11 @@ process_reply (void *cls,
                          GNUNET_TIME_absolute_get_duration (pr->public_data.start_time).rel_value);
       /* pass on to other peers / local clients */
       pr->rh (pr->rh_cls,            
+             prq->eval,
              pr,
              prq->expiration,
              prq->type,
              prq->data, prq->size);
-      GSF_pending_request_cancel_ (pr);
       return GNUNET_YES;
     case GNUNET_BLOCK_EVALUATION_OK_DUPLICATE:
       GNUNET_STATISTICS_update (GSF_stats,
@@ -764,6 +765,7 @@ process_reply (void *cls,
   prq->request_found = GNUNET_YES;
   /* finally, pass on to other peer / local client */
   pr->rh (pr->rh_cls,
+         prq->eval,
          pr, 
          prq->expiration,
          prq->type,
index b546fc1abbbb19bda883d8161ae9de6859e9ad37..fa3c51ffdb787d9d1bd7f92974287d872893b73d 100644 (file)
@@ -158,6 +158,7 @@ struct GSF_PendingRequestData
  * expiration.
  *
  * @param cls user-specified closure
+ * @param eval evaluation of the result
  * @param pr handle to the original pending request
  * @param expiration when does 'data' expire?
  * @param type type of the block
@@ -165,6 +166,7 @@ struct GSF_PendingRequestData
  * @param data_len number of bytes in data
  */
 typedef void (*GSF_PendingRequestReplyHandler)(void *cls,
+                                              enum GNUNET_BLOCK_EvaluationResult eval,
                                               struct GSF_PendingRequest *pr,
                                               struct GNUNET_TIME_Absolute expiration,
                                               enum GNUNET_BLOCK_Type type,