-fixes
[oweals/gnunet.git] / src / fs / gnunet-service-fs_lc.c
index d8f7d5cb3ef51bbe5b5b251d8abcab5db0b88795..36aafdde9dd6fbc4dbdee73dd2fcf42d2a7a3a27 100644 (file)
@@ -218,6 +218,7 @@ client_request_destroy (void *cls,
  * @param pr handle to the original pending request
  * @param reply_anonymity_level anonymity level for the reply, UINT32_MAX for "unknown"
  * @param expiration when does 'data' expire?
+ * @param last_transmission when was the last time we've tried to download this block? (FOREVER if unknown)
  * @param type type of the block
  * @param data response data, NULL on request expiration
  * @param data_len number of bytes in data
@@ -227,12 +228,13 @@ client_response_handler (void *cls, enum GNUNET_BLOCK_EvaluationResult eval,
                          struct GSF_PendingRequest *pr,
                          uint32_t reply_anonymity_level,
                          struct GNUNET_TIME_Absolute expiration,
+                         struct GNUNET_TIME_Absolute last_transmission,
                          enum GNUNET_BLOCK_Type type, const void *data,
                          size_t data_len)
 {
   struct ClientRequest *cr = cls;
   struct GSF_LocalClient *lc;
-  struct PutMessage *pm;
+  struct ClientPutMessage *pm;
   const struct GSF_PendingRequestData *prd;
   size_t msize;
 
@@ -255,26 +257,26 @@ client_response_handler (void *cls, enum GNUNET_BLOCK_EvaluationResult eval,
                             GNUNET_NO);
   GNUNET_assert (pr == cr->pr);
   lc = cr->lc;
-  msize = sizeof (struct PutMessage) + data_len;
+  msize = sizeof (struct ClientPutMessage) + data_len;
   {
     char buf[msize];
 
-    pm = (struct PutMessage *) buf;
+    pm = (struct ClientPutMessage *) buf;
     pm->header.type = htons (GNUNET_MESSAGE_TYPE_FS_PUT);
     pm->header.size = htons (msize);
     pm->type = htonl (type);
     pm->expiration = GNUNET_TIME_absolute_hton (expiration);
+    pm->last_transmission = GNUNET_TIME_absolute_hton (last_transmission);
     memcpy (&pm[1], data, data_len);
     GSF_local_client_transmit_ (lc, &pm->header);
   }
-#if DEBUG_FS_CLIENT
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Queued reply to query `%s' for local client\n",
               GNUNET_h2s (&prd->query), (unsigned int) prd->type);
-#endif
   if (eval != GNUNET_BLOCK_EVALUATION_OK_LAST)
     return;
-  cr->kill_task = GNUNET_SCHEDULER_add_now (&client_request_destroy, cr);
+  if (GNUNET_SCHEDULER_NO_TASK != cr->kill_task)
+    cr->kill_task = GNUNET_SCHEDULER_add_now (&client_request_destroy, cr);
 }
 
 
@@ -321,11 +323,9 @@ GSF_local_client_start_search_handler_ (struct GNUNET_SERVER_Client *client,
   sc = (msize - sizeof (struct SearchMessage)) / sizeof (GNUNET_HashCode);
   sm = (const struct SearchMessage *) message;
   type = ntohl (sm->type);
-#if DEBUG_FS_CLIENT
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Received request for `%s' of type %u from local client\n",
               GNUNET_h2s (&sm->query), (unsigned int) type);
-#endif
   lc = GSF_local_client_lookup_ (client);
   cr = NULL;
   /* detect duplicate KBLOCK requests */
@@ -348,10 +348,8 @@ GSF_local_client_start_search_handler_ (struct GNUNET_SERVER_Client *client,
   }
   if (cr != NULL)
   {
-#if DEBUG_FS_CLIENT
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Have existing request, merging content-seen lists.\n");
-#endif
     GSF_pending_request_update_ (cr->pr, (const GNUNET_HashCode *) &sm[1], sc);
     GNUNET_STATISTICS_update (GSF_stats,
                               gettext_noop