gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r36575 - gnunet/src/fs


From: gnunet
Subject: [GNUnet-SVN] r36575 - gnunet/src/fs
Date: Mon, 26 Oct 2015 00:22:33 +0100

Author: grothoff
Date: 2015-10-26 00:22:33 +0100 (Mon, 26 Oct 2015)
New Revision: 36575

Modified:
   gnunet/src/fs/gnunet-service-fs.c
   gnunet/src/fs/gnunet-service-fs_cp.c
   gnunet/src/fs/gnunet-service-fs_pe.c
   gnunet/src/fs/gnunet-service-fs_pr.c
Log:
-reduce calls in get_latest()

Modified: gnunet/src/fs/gnunet-service-fs.c
===================================================================
--- gnunet/src/fs/gnunet-service-fs.c   2015-10-25 23:09:35 UTC (rev 36574)
+++ gnunet/src/fs/gnunet-service-fs.c   2015-10-25 23:22:33 UTC (rev 36575)
@@ -355,7 +355,8 @@
 {
   if (GNUNET_BLOCK_EVALUATION_OK_LAST == result)
     return;                     /* we're done... */
-  GSF_iterate_connected_peers_ (&consider_request_for_forwarding, pr);
+  GSF_iterate_connected_peers_ (&consider_request_for_forwarding,
+                                pr);
 }
 
 
@@ -376,12 +377,14 @@
 {
   struct GSF_PendingRequest *pr;
 
-  pr = GSF_handle_p2p_query_ (other, message);
+  pr = GSF_handle_p2p_query_ (other,
+                              message);
   if (NULL == pr)
-    return GNUNET_SYSERR;
+    return GNUNET_OK; /* exists, identical to existing request, or malformed */
   GSF_pending_request_get_data_ (pr)->has_started = GNUNET_YES;
   GSF_local_lookup_ (pr,
-                     &consider_forwarding, NULL);
+                     &consider_forwarding,
+                     NULL);
   return GNUNET_OK;
 }
 

Modified: gnunet/src/fs/gnunet-service-fs_cp.c
===================================================================
--- gnunet/src/fs/gnunet-service-fs_cp.c        2015-10-25 23:09:35 UTC (rev 
36574)
+++ gnunet/src/fs/gnunet-service-fs_cp.c        2015-10-25 23:22:33 UTC (rev 
36575)
@@ -1160,11 +1160,12 @@
  *
  * @param ttl_in requested ttl
  * @param prio given priority
- * @return ttl_in if ttl_in is below the limit,
- *         otherwise the ttl-limit for the given priority
+ * @return @a ttl_in if @a ttl_in is below the limit,
+ *         otherwise the ttl-limit for the given @a prio
  */
 static int32_t
-bound_ttl (int32_t ttl_in, uint32_t prio)
+bound_ttl (int32_t ttl_in,
+           uint32_t prio)
 {
   unsigned long long allowed;
 
@@ -1257,7 +1258,6 @@
 }
 
 
-
 /**
  * Handle P2P "QUERY" message.  Creates the pending request entry
  * and sets up all of the data structures to that we will

Modified: gnunet/src/fs/gnunet-service-fs_pe.c
===================================================================
--- gnunet/src/fs/gnunet-service-fs_pe.c        2015-10-25 23:09:35 UTC (rev 
36574)
+++ gnunet/src/fs/gnunet-service-fs_pe.c        2015-10-25 23:22:33 UTC (rev 
36575)
@@ -355,18 +355,23 @@
 {
   struct GSF_PendingRequest *ret;
   struct GSF_PendingRequestPlanBijection *bi;
+  const struct GSF_PendingRequestData *rprd;
+  const struct GSF_PendingRequestData *prd;
 
   bi = rp->pe_head;
   if (NULL == bi)
     return NULL; /* should never happen */
   ret = bi->pr;
-  bi = bi->next_PE;
-  while (NULL != bi)
+  rprd = GSF_pending_request_get_data_ (ret);
+  for (bi = bi->next_PE; NULL != bi; bi = bi->next_PE)
   {
-    if (GSF_pending_request_get_data_ (bi->pr)->ttl.abs_value_us >
-        GSF_pending_request_get_data_ (ret)->ttl.abs_value_us)
+    prd = GSF_pending_request_get_data_ (bi->pr);
+    if (prd->ttl.abs_value_us >
+        rprd->ttl.abs_value_us)
+    {
       ret = bi->pr;
-    bi = bi->next_PE;
+      rprd = prd;
+    }
   }
   return ret;
 }

Modified: gnunet/src/fs/gnunet-service-fs_pr.c
===================================================================
--- gnunet/src/fs/gnunet-service-fs_pr.c        2015-10-25 23:09:35 UTC (rev 
36574)
+++ gnunet/src/fs/gnunet-service-fs_pr.c        2015-10-25 23:22:33 UTC (rev 
36575)
@@ -290,13 +290,16 @@
                              const struct GNUNET_HashCode *query,
                              const struct GNUNET_PeerIdentity *target,
                              const char *bf_data, size_t bf_size,
-                             uint32_t mingle, uint32_t anonymity_level,
-                             uint32_t priority, int32_t ttl,
+                             uint32_t mingle,
+                             uint32_t anonymity_level,
+                             uint32_t priority,
+                             int32_t ttl,
                              GNUNET_PEER_Id sender_pid,
                              GNUNET_PEER_Id origin_pid,
                              const struct GNUNET_HashCode *replies_seen,
                              unsigned int replies_seen_count,
-                             GSF_PendingRequestReplyHandler rh, void *rh_cls)
+                             GSF_PendingRequestReplyHandler rh,
+                             void *rh_cls)
 {
   struct GSF_PendingRequest *pr;
   struct GSF_PendingRequest *dpr;
@@ -351,7 +354,8 @@
     pr->replies_seen_size = replies_seen_count;
     pr->replies_seen =
         GNUNET_malloc (sizeof (struct GNUNET_HashCode) * 
pr->replies_seen_size);
-    memcpy (pr->replies_seen, replies_seen,
+    memcpy (pr->replies_seen,
+            replies_seen,
             replies_seen_count * sizeof (struct GNUNET_HashCode));
     pr->replies_seen_count = replies_seen_count;
   }
@@ -358,7 +362,8 @@
   if (NULL != bf_data)
   {
     pr->bf =
-        GNUNET_CONTAINER_bloomfilter_init (bf_data, bf_size,
+        GNUNET_CONTAINER_bloomfilter_init (bf_data,
+                                           bf_size,
                                            GNUNET_CONSTANTS_BLOOMFILTER_K);
     pr->mingle = mingle;
   }
@@ -368,12 +373,14 @@
     refresh_bloomfilter (pr);
   }
   GNUNET_CONTAINER_multihashmap_put (pr_map,
-                                    &pr->public_data.query, pr,
+                                    &pr->public_data.query,
+                                     pr,
                                      
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
   if (0 == (options & GSF_PRO_REQUEST_NEVER_EXPIRES))
   {
     pr->hnode =
-        GNUNET_CONTAINER_heap_insert (requests_by_expiration_heap, pr,
+        GNUNET_CONTAINER_heap_insert (requests_by_expiration_heap,
+                                      pr,
                                       pr->public_data.ttl.abs_value_us);
     /* make sure we don't track too many requests */
     while (GNUNET_CONTAINER_heap_get_size (requests_by_expiration_heap) >
@@ -380,14 +387,19 @@
            max_pending_requests)
     {
       dpr = GNUNET_CONTAINER_heap_peek (requests_by_expiration_heap);
-      GNUNET_assert (dpr != NULL);
+      GNUNET_assert (NULL != dpr);
       if (pr == dpr)
         break;                  /* let the request live briefly... */
       if (NULL != dpr->rh)
-       dpr->rh (dpr->rh_cls, GNUNET_BLOCK_EVALUATION_REQUEST_VALID, dpr,
-                UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_ABS, 
GNUNET_TIME_UNIT_FOREVER_ABS,
+       dpr->rh (dpr->rh_cls,
+                 GNUNET_BLOCK_EVALUATION_REQUEST_VALID,
+                 dpr,
+                UINT32_MAX,
+                 GNUNET_TIME_UNIT_FOREVER_ABS,
+                 GNUNET_TIME_UNIT_FOREVER_ABS,
                  GNUNET_BLOCK_TYPE_ANY, NULL, 0);
-      GSF_pending_request_cancel_ (dpr, GNUNET_YES);
+      GSF_pending_request_cancel_ (dpr,
+                                   GNUNET_YES);
     }
   }
   GNUNET_STATISTICS_update (GSF_stats,




reply via email to

[Prev in Thread] Current Thread [Next in Thread]