fix
authorChristian Grothoff <christian@grothoff.org>
Fri, 25 Mar 2011 11:02:34 +0000 (11:02 +0000)
committerChristian Grothoff <christian@grothoff.org>
Fri, 25 Mar 2011 11:02:34 +0000 (11:02 +0000)
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 9ff96ba367206606163d841404ebae8d701c34a0..783bd40244ddb284a11428e47e91825c3c20d62e 100644 (file)
@@ -560,6 +560,7 @@ copy_reply (void *cls,
  *            have liked an answer to the request
  * @param pr handle to the original pending request
  * @param expiration when does 'data' expire?
+ * @param type type of the block
  * @param data response data, NULL on request expiration
  * @param data_len number of bytes in data
  */
@@ -567,6 +568,7 @@ static void
 handle_p2p_reply (void *cls,
                  struct GSF_PendingRequest *pr,
                  struct GNUNET_TIME_Absolute expiration,
+                 enum GNUNET_BLOCK_Type type,
                  const void *data,
                  size_t data_len)
 {
@@ -588,6 +590,13 @@ handle_p2p_reply (void *cls,
                                                          pr));
       return;
     }  
+  GNUNET_break (type != GNUNET_BLOCK_TYPE_ANY);
+  if ( (prd->type != type) &&
+       (prd->type != GNUNET_BLOCK_TYPE_ANY) )
+    {
+      GNUNET_break (0);
+      return;
+    }
 #if DEBUG_FS
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Transmitting result for query `%s'\n",
@@ -606,7 +615,7 @@ handle_p2p_reply (void *cls,
   pm = GNUNET_malloc (sizeof (msize));
   pm->header.type = htons (GNUNET_MESSAGE_TYPE_FS_PUT);
   pm->header.size = htons (msize);
-  pm->type = htonl (prd->type);
+  pm->type = htonl (type);
   pm->expiration = GNUNET_TIME_absolute_hton (expiration);
   memcpy (&pm[1], data, data_len);
   (void) GSF_peer_transmit_ (cp, GNUNET_NO,
index 5ceb7c2a5fbc85022897146bd331945b0fe9a348..3908b8a558b4ec6218f0969e298863988cf1849a 100644 (file)
@@ -189,7 +189,8 @@ GSF_local_client_lookup_ (struct GNUNET_SERVER_Client *client)
  *
  * @param cls user-specified closure
  * @param pr handle to the original pending request
- * @param expiration when does 'data' expire?
+ * @param expiration when does 'data' expire? 
+ * @param type type of the block
  * @param data response data, NULL on request expiration
  * @param data_len number of bytes in data
  */
@@ -197,6 +198,7 @@ static void
 client_response_handler (void *cls,
                         struct GSF_PendingRequest *pr,
                         struct GNUNET_TIME_Absolute expiration,
+                        enum GNUNET_BLOCK_Type type,
                         const void *data,
                         size_t data_len)
 {
@@ -212,18 +214,25 @@ client_response_handler (void *cls,
       GNUNET_break (0);
       return;
     }
+  prd = GSF_pending_request_get_data_ (pr);
+  GNUNET_break (type != GNUNET_BLOCK_TYPE_ANY);
+  if ( (prd->type != type) &&
+       (prd->type != GNUNET_BLOCK_TYPE_ANY) )
+    {
+      GNUNET_break (0);
+      return;
+    }
   GNUNET_STATISTICS_update (GSF_stats,
                            gettext_noop ("# replies received for local clients"),
                            1,
                            GNUNET_NO);
-  prd = GSF_pending_request_get_data_ (pr);
   GNUNET_assert (pr == cr->pr);
   lc = cr->lc;
   msize = sizeof (struct PutMessage) + data_len;
   pm = GNUNET_malloc (msize);
   pm->header.type = htons (GNUNET_MESSAGE_TYPE_FS_PUT);
   pm->header.size = htons (msize);
-  pm->type = htonl (prd->type);
+  pm->type = htonl (type);
   pm->expiration = GNUNET_TIME_absolute_hton (expiration);
   memcpy (&pm[1], data, data_len);      
   GSF_local_client_transmit_ (lc, &pm->header);
index 13de31c7c6074477d88dbc322f0fd1e4667f9e36..8a14c4c007f796d0d83178f6ea3641364320e196 100644 (file)
@@ -333,6 +333,7 @@ GSF_pending_request_create_ (enum GSF_PendingRequestOptions options,
          dpr->rh (dpr->rh_cls,
                   dpr,
                   GNUNET_TIME_UNIT_FOREVER_ABS,
+                  GNUNET_BLOCK_TYPE_ANY,
                   NULL, 0);
          GSF_pending_request_cancel_ (dpr);
        }
@@ -692,6 +693,7 @@ process_reply (void *cls,
       pr->rh (pr->rh_cls,            
              pr,
              prq->expiration,
+             prq->type,
              prq->data, prq->size);
       return GNUNET_YES;
     case GNUNET_BLOCK_EVALUATION_OK_DUPLICATE:
@@ -749,6 +751,7 @@ process_reply (void *cls,
   pr->rh (pr->rh_cls,
          pr, 
          prq->expiration,
+         prq->type,
          prq->data, prq->size);
   return GNUNET_YES;
 }
index ea464e57811cb298a0c1c4cef36cf9fd5599aad5..b546fc1abbbb19bda883d8161ae9de6859e9ad37 100644 (file)
@@ -160,12 +160,14 @@ struct GSF_PendingRequestData
  * @param cls user-specified closure
  * @param pr handle to the original pending request
  * @param expiration when does 'data' expire?
+ * @param type type of the block
  * @param data response data, NULL on request expiration
  * @param data_len number of bytes in data
  */
 typedef void (*GSF_PendingRequestReplyHandler)(void *cls,
                                               struct GSF_PendingRequest *pr,
                                               struct GNUNET_TIME_Absolute expiration,
+                                              enum GNUNET_BLOCK_Type type,
                                               const void *data,
                                               size_t data_len);