gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r24318 - gnunet/src/fs
Date: Sun, 14 Oct 2012 20:39:08 +0200

Author: grothoff
Date: 2012-10-14 20:39:08 +0200 (Sun, 14 Oct 2012)
New Revision: 24318

Modified:
   gnunet/src/fs/gnunet-service-fs_cp.c
   gnunet/src/fs/gnunet-service-fs_cp.h
   gnunet/src/fs/gnunet-service-fs_pe.c
Log:
-optimizing all FS multi hashmaps for key memory sharing

Modified: gnunet/src/fs/gnunet-service-fs_cp.c
===================================================================
--- gnunet/src/fs/gnunet-service-fs_cp.c        2012-10-14 18:29:00 UTC (rev 
24317)
+++ gnunet/src/fs/gnunet-service-fs_cp.c        2012-10-14 18:39:08 UTC (rev 
24318)
@@ -315,6 +315,7 @@
  */
 static struct GNUNET_ATS_PerformanceHandle *ats;
 
+
 /**
  * Get the filename under which we would store respect
  * for the given peer.
@@ -617,7 +618,8 @@
   GNUNET_free (fn);
   cp->request_map = GNUNET_CONTAINER_multihashmap_create (128, GNUNET_NO);
   GNUNET_break (GNUNET_OK ==
-                GNUNET_CONTAINER_multihashmap_put (cp_map, &peer->hashPubKey,
+                GNUNET_CONTAINER_multihashmap_put (cp_map, 
+                                                  
&GSF_connected_peer_get_identity2_ (cp)->hashPubKey,
                                                    cp,
                                                    
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
   GNUNET_STATISTICS_set (GSF_stats, gettext_noop ("# peers connected"),
@@ -1646,7 +1648,7 @@
 /**
  * Obtain the identity of a connected peer.
  *
- * @param cp peer to reserve bandwidth from
+ * @param cp peer to get identity of
  * @param id identity to set (written to)
  */
 void
@@ -1659,6 +1661,20 @@
 
 
 /**
+ * Obtain the identity of a connected peer.
+ *
+ * @param cp peer to get identity of
+ * @return reference to peer identity, valid until peer disconnects (!)
+ */
+const struct GNUNET_PeerIdentity *
+GSF_connected_peer_get_identity2_ (const struct GSF_ConnectedPeer *cp)
+{
+  GNUNET_assert (0 != cp->ppd.pid);
+  return GNUNET_PEER_resolve2 (cp->ppd.pid);
+}
+
+
+/**
  * Assemble a migration stop message for transmission.
  *
  * @param cls the 'struct GSF_ConnectedPeer' to use
@@ -1811,7 +1827,7 @@
 void
 GSF_connected_peer_init_ ()
 {
-  cp_map = GNUNET_CONTAINER_multihashmap_create (128, GNUNET_NO);
+  cp_map = GNUNET_CONTAINER_multihashmap_create (128, GNUNET_YES);
   ats = GNUNET_ATS_performance_init (GSF_cfg, NULL, NULL);
   GNUNET_assert (GNUNET_OK ==
                  GNUNET_CONFIGURATION_get_value_filename (GSF_cfg, "fs",

Modified: gnunet/src/fs/gnunet-service-fs_cp.h
===================================================================
--- gnunet/src/fs/gnunet-service-fs_cp.h        2012-10-14 18:29:00 UTC (rev 
24317)
+++ gnunet/src/fs/gnunet-service-fs_cp.h        2012-10-14 18:39:08 UTC (rev 
24318)
@@ -384,7 +384,7 @@
 /**
  * Obtain the identity of a connected peer.
  *
- * @param cp peer to reserve bandwidth from
+ * @param cp peer to get identity of
  * @param id identity to set (written to)
  */
 void
@@ -393,6 +393,17 @@
 
 
 /**
+ * Obtain the identity of a connected peer.
+ *
+ * @param cp peer to get identity of
+ * @return reference to peer identity, valid until peer disconnects (!)
+ */
+const struct GNUNET_PeerIdentity *
+GSF_connected_peer_get_identity2_ (const struct GSF_ConnectedPeer *cp);
+
+
+
+/**
  * Iterate over all connected peers.
  *
  * @param it function to call for each peer

Modified: gnunet/src/fs/gnunet-service-fs_pe.c
===================================================================
--- gnunet/src/fs/gnunet-service-fs_pe.c        2012-10-14 18:29:00 UTC (rev 
24317)
+++ gnunet/src/fs/gnunet-service-fs_pe.c        2012-10-14 18:39:08 UTC (rev 
24318)
@@ -558,7 +558,7 @@
 void
 GSF_plan_add_ (struct GSF_ConnectedPeer *cp, struct GSF_PendingRequest *pr)
 {
-  struct GNUNET_PeerIdentity id;
+  const struct GNUNET_PeerIdentity *id;
   struct PeerPlan *pp;
   struct GSF_PendingRequestData *prd;
   struct GSF_RequestPlan *rp;
@@ -567,18 +567,19 @@
   struct MergeContext mpc;
 
   GNUNET_assert (NULL != cp);
-  GSF_connected_peer_get_identity_ (cp, &id);
-  pp = GNUNET_CONTAINER_multihashmap_get (plans, &id.hashPubKey);
+  id = GSF_connected_peer_get_identity2_ (cp);
+  pp = GNUNET_CONTAINER_multihashmap_get (plans, &id->hashPubKey);
   if (NULL == pp)
   {
     pp = GNUNET_malloc (sizeof (struct PeerPlan));
-    pp->plan_map = GNUNET_CONTAINER_multihashmap_create (128, GNUNET_NO);
+    pp->plan_map = GNUNET_CONTAINER_multihashmap_create (128, GNUNET_YES);
     pp->priority_heap =
         GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MAX);
     pp->delay_heap =
         GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN);
     pp->cp = cp;
-    GNUNET_CONTAINER_multihashmap_put (plans, &id.hashPubKey, pp,
+    GNUNET_CONTAINER_multihashmap_put (plans, 
+                                      &id->hashPubKey, pp,
                                        
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
   }
   mpc.merged = GNUNET_NO;
@@ -599,7 +600,7 @@
   prd = GSF_pending_request_get_data_ (pr);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Planning transmission of query `%s' to peer `%s'\n",
-              GNUNET_h2s (&prd->query), GNUNET_i2s (&id));
+              GNUNET_h2s (&prd->query), GNUNET_i2s (id));
   rp = GNUNET_malloc (sizeof (struct GSF_RequestPlan)); // 8 MB
   rpr = GNUNET_malloc (sizeof (struct GSF_RequestPlanReference));
   prl = GNUNET_malloc (sizeof (struct PendingRequestList));
@@ -627,18 +628,18 @@
 void
 GSF_plan_notify_peer_disconnect_ (const struct GSF_ConnectedPeer *cp)
 {
-  struct GNUNET_PeerIdentity id;
+  const struct GNUNET_PeerIdentity *id;
   struct PeerPlan *pp;
   struct GSF_RequestPlan *rp;
   struct GSF_PendingRequestData *prd;
   struct PendingRequestList *prl;
 
-  GSF_connected_peer_get_identity_ (cp, &id);
-  pp = GNUNET_CONTAINER_multihashmap_get (plans, &id.hashPubKey);
+  id = GSF_connected_peer_get_identity2_ (cp);
+  pp = GNUNET_CONTAINER_multihashmap_get (plans, &id->hashPubKey);
   if (NULL == pp)
     return;                     /* nothing was ever planned for this peer */
   GNUNET_assert (GNUNET_YES ==
-                 GNUNET_CONTAINER_multihashmap_remove (plans, &id.hashPubKey,
+                 GNUNET_CONTAINER_multihashmap_remove (plans, &id->hashPubKey,
                                                        pp));
   if (NULL != pp->pth)
   {
@@ -760,7 +761,7 @@
 void
 GSF_plan_init ()
 {
-  plans = GNUNET_CONTAINER_multihashmap_create (256, GNUNET_NO);
+  plans = GNUNET_CONTAINER_multihashmap_create (256, GNUNET_YES);
 }
 
 




reply via email to

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