Fix for #4553
[oweals/gnunet.git] / src / fs / gnunet-service-fs_pr.c
index b507992b49ab29d8ab1ec3427c6397a8fbd7c418..a7a62a7437b5ac42361d2ed70c00d9f7ca5eca17 100644 (file)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     Copyright (C) 2009-2013 Christian Grothoff (and other contributing authors)
+     Copyright (C) 2009-2013 GNUnet e.V.
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -289,7 +289,8 @@ GSF_pending_request_create_ (enum GSF_PendingRequestOptions options,
                              enum GNUNET_BLOCK_Type type,
                              const struct GNUNET_HashCode *query,
                              const struct GNUNET_PeerIdentity *target,
-                             const char *bf_data, size_t bf_size,
+                             const char *bf_data,
+                             size_t bf_size,
                              uint32_t mingle,
                              uint32_t anonymity_level,
                              uint32_t priority,
@@ -325,7 +326,9 @@ GSF_pending_request_create_ (enum GSF_PendingRequestOptions options,
   if (NULL != target)
   {
     pr->public_data.target = (struct GNUNET_PeerIdentity *) eptr;
-    memcpy (eptr, target, sizeof (struct GNUNET_PeerIdentity));
+    memcpy (eptr,
+            target,
+            sizeof (struct GNUNET_PeerIdentity));
   }
   pr->public_data.anonymity_level = anonymity_level;
   pr->public_data.priority = priority;
@@ -397,7 +400,9 @@ GSF_pending_request_create_ (enum GSF_PendingRequestOptions options,
                 UINT32_MAX,
                  GNUNET_TIME_UNIT_FOREVER_ABS,
                  GNUNET_TIME_UNIT_FOREVER_ABS,
-                 GNUNET_BLOCK_TYPE_ANY, NULL, 0);
+                 GNUNET_BLOCK_TYPE_ANY,
+                 NULL,
+                 0);
       GSF_pending_request_cancel_ (dpr,
                                    GNUNET_YES);
     }
@@ -623,7 +628,9 @@ clean_request (void *cls,
   if (NULL != (cont = pr->llc_cont))
   {
     pr->llc_cont = NULL;
-    cont (pr->llc_cont_cls, pr, pr->local_result);
+    cont (pr->llc_cont_cls,
+          pr,
+          pr->local_result);
   }
   GSF_plan_notify_request_done_ (pr);
   GNUNET_free_non_null (pr->replies_seen);
@@ -661,7 +668,8 @@ clean_request (void *cls,
                                                        &pr->public_data.query,
                                                        pr));
   GNUNET_STATISTICS_update (GSF_stats,
-                            gettext_noop ("# Pending requests active"), -1,
+                            gettext_noop ("# Pending requests active"),
+                            -1,
                             GNUNET_NO);
   GNUNET_free (pr);
   return GNUNET_YES;
@@ -682,7 +690,7 @@ GSF_pending_request_cancel_ (struct GSF_PendingRequest *pr,
 
   if (NULL == pr_map)
     return;                     /* already cleaned up! */
-  if (GNUNET_YES != full_cleanup)
+  if (GNUNET_NO == full_cleanup)
   {
     /* make request inactive (we're no longer interested in more results),
      * but do NOT remove from our data-structures, we still need it there
@@ -1229,10 +1237,10 @@ cadet_reply_proc (void *cls,
     /* retry -- without delay, as this is non-anonymous
        and cadet/cadet connect will take some time anyway */
     pr->cadet_request = GSF_cadet_query (pr->public_data.target,
-                                       &pr->public_data.query,
-                                       pr->public_data.type,
-                                       &cadet_reply_proc,
-                                       pr);
+                                         &pr->public_data.query,
+                                         pr->public_data.type,
+                                         &cadet_reply_proc,
+                                         pr);
     return;
   }
   if (GNUNET_YES !=
@@ -1281,10 +1289,10 @@ GSF_cadet_lookup_ (struct GSF_PendingRequest *pr)
   if (NULL != pr->cadet_request)
     return;
   pr->cadet_request = GSF_cadet_query (pr->public_data.target,
-                                    &pr->public_data.query,
-                                    pr->public_data.type,
-                                    &cadet_reply_proc,
-                                    pr);
+                                       &pr->public_data.query,
+                                       pr->public_data.type,
+                                       &cadet_reply_proc,
+                                       pr);
 }
 
 
@@ -1292,11 +1300,9 @@ GSF_cadet_lookup_ (struct GSF_PendingRequest *pr)
  * Task that issues a warning if the datastore lookup takes too long.
  *
  * @param cls the `struct GSF_PendingRequest`
- * @param tc task context
  */
 static void
-warn_delay_task (void *cls,
-                 const struct GNUNET_SCHEDULER_TaskContext *tc)
+warn_delay_task (void *cls)
 {
   struct GSF_PendingRequest *pr = cls;
 
@@ -1315,11 +1321,9 @@ warn_delay_task (void *cls,
  * Task that issues a warning if the datastore lookup takes too long.
  *
  * @param cls the `struct GSF_PendingRequest`
- * @param tc task context
  */
 static void
-odc_warn_delay_task (void *cls,
-                     const struct GNUNET_SCHEDULER_TaskContext *tc)
+odc_warn_delay_task (void *cls)
 {
   struct GSF_PendingRequest *pr = cls;
 
@@ -1834,6 +1838,19 @@ GSF_handle_p2p_content_ (struct GSF_ConnectedPeer *cp,
 }
 
 
+/**
+ * Check if the given request is still active.
+ *
+ * @param pr pending request
+ * @return #GNUNET_YES if the request is still active
+ */
+int
+GSF_pending_request_test_active_ (struct GSF_PendingRequest *pr)
+{
+  return (NULL != pr->rh) ? GNUNET_YES : GNUNET_NO;
+}
+
+
 /**
  * Setup the subsystem.
  */
@@ -1863,7 +1880,9 @@ GSF_pending_request_init_ ()
 void
 GSF_pending_request_done_ ()
 {
-  GNUNET_CONTAINER_multihashmap_iterate (pr_map, &clean_request, NULL);
+  GNUNET_CONTAINER_multihashmap_iterate (pr_map,
+                                         &clean_request,
+                                         NULL);
   GNUNET_CONTAINER_multihashmap_destroy (pr_map);
   pr_map = NULL;
   GNUNET_CONTAINER_heap_destroy (requests_by_expiration_heap);