- opaque mq structs
[oweals/gnunet.git] / src / fs / gnunet-service-fs_lc.c
index f3b18256b1b1e320ee333c6c559097d084c2c607..f901318153b1cf065dcbeeb6f00348dc06bf8050 100644 (file)
@@ -197,7 +197,7 @@ client_request_destroy (void *cls,
   cr->kill_task = GNUNET_SCHEDULER_NO_TASK;
   lc = cr->lc;
   GNUNET_CONTAINER_DLL_remove (lc->cr_head, lc->cr_tail, cr);
-  GSF_pending_request_cancel_ (cr->pr, GNUNET_NO);
+  GSF_pending_request_cancel_ (cr->pr, GNUNET_YES);
   GNUNET_STATISTICS_update (GSF_stats,
                             gettext_noop ("# client searches active"), -1,
                             GNUNET_NO);
@@ -267,15 +267,22 @@ client_response_handler (void *cls, enum GNUNET_BLOCK_EvaluationResult eval,
     pm->type = htonl (type);
     pm->expiration = GNUNET_TIME_absolute_hton (expiration);
     pm->last_transmission = GNUNET_TIME_absolute_hton (last_transmission);
+    pm->num_transmissions = htonl (prd->num_transmissions);
+    pm->respect_offered = htonl (prd->respect_offered);
     memcpy (&pm[1], data, data_len);
     GSF_local_client_transmit_ (lc, &pm->header);
   }
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Queued reply to query `%s' for local client\n",
               GNUNET_h2s (&prd->query), (unsigned int) prd->type);
-  if (eval != GNUNET_BLOCK_EVALUATION_OK_LAST)
+  if (GNUNET_BLOCK_EVALUATION_OK_LAST != eval)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+               "Evaluation %d - keeping query alive\n",
+               (int) eval);
     return;
-  if (GNUNET_SCHEDULER_NO_TASK != cr->kill_task)
+  }
+  if (GNUNET_SCHEDULER_NO_TASK == cr->kill_task)
     cr->kill_task = GNUNET_SCHEDULER_add_now (&client_request_destroy, cr);
 }
 
@@ -328,9 +335,9 @@ GSF_local_client_start_search_handler_ (struct GNUNET_SERVER_Client *client,
               GNUNET_h2s (&sm->query), (unsigned int) type);
   lc = GSF_local_client_lookup_ (client);
   cr = NULL;
-  /* detect duplicate KBLOCK requests */
-  if ((type == GNUNET_BLOCK_TYPE_FS_KBLOCK) ||
-      (type == GNUNET_BLOCK_TYPE_FS_NBLOCK) || (type == GNUNET_BLOCK_TYPE_ANY))
+  /* detect duplicate UBLOCK requests */
+  if ((type == GNUNET_BLOCK_TYPE_FS_UBLOCK) ||
+      (type == GNUNET_BLOCK_TYPE_ANY))
   {
     cr = lc->cr_head;
     while (cr != NULL)
@@ -346,7 +353,7 @@ GSF_local_client_start_search_handler_ (struct GNUNET_SERVER_Client *client,
       cr = cr->next;
     }
   }
-  if (cr != NULL)
+  if (NULL != cr)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Have existing request, merging content-seen lists.\n");
@@ -367,8 +374,8 @@ GSF_local_client_start_search_handler_ (struct GNUNET_SERVER_Client *client,
     options = GSF_PRO_LOCAL_REQUEST;
     if (0 != (SEARCH_MESSAGE_OPTION_LOOPBACK_ONLY & ntohl (sm->options)))
       options |= GSF_PRO_LOCAL_ONLY;
-    cr->pr = GSF_pending_request_create_ (options, type, &sm->query, (type == GNUNET_BLOCK_TYPE_FS_SBLOCK) ? &sm->target        /* namespace */
-                                          : NULL,
+    cr->pr = GSF_pending_request_create_ (options, type,
+                                         &sm->query, 
                                           (0 !=
                                            memcmp (&sm->target, &all_zeros,
                                                    sizeof (struct GNUNET_HashCode)))
@@ -478,18 +485,13 @@ GSF_client_disconnect_handler_ (void *cls, struct GNUNET_SERVER_Client *client)
   pos = client_head;
   while ((pos != NULL) && (pos->client != client))
     pos = pos->next;
-  if (pos == NULL)
+  if (NULL == pos)
     return;
   while (NULL != (cr = pos->cr_head))
   {
-    GNUNET_CONTAINER_DLL_remove (pos->cr_head, pos->cr_tail, cr);
-    GSF_pending_request_cancel_ (cr->pr, GNUNET_NO);
-    GNUNET_STATISTICS_update (GSF_stats,
-                              gettext_noop ("# client searches active"), -1,
-                              GNUNET_NO);
     if (GNUNET_SCHEDULER_NO_TASK != cr->kill_task)
       GNUNET_SCHEDULER_cancel (cr->kill_task);
-    GNUNET_free (cr);
+    client_request_destroy (cr, NULL);
   }
   while (NULL != (res = pos->res_head))
   {