aboutsummaryrefslogtreecommitdiff
path: root/src/fs/gnunet-service-fs_cp.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-10-25 23:47:39 +0000
committerChristian Grothoff <christian@grothoff.org>2015-10-25 23:47:39 +0000
commit7c55f94e78c72d3b78a5c6007e3658ae30e1f64b (patch)
tree77cb53d80cbb79053a68c71a270586e6e0dcb1ef /src/fs/gnunet-service-fs_cp.c
parent124f3e77a5e022f5f7ab49df49023d0080bcbbb4 (diff)
downloadgnunet-7c55f94e78c72d3b78a5c6007e3658ae30e1f64b.tar.gz
gnunet-7c55f94e78c72d3b78a5c6007e3658ae30e1f64b.zip
-use hash in prd query to reduce memory consumption of CP request_map
Diffstat (limited to 'src/fs/gnunet-service-fs_cp.c')
-rw-r--r--src/fs/gnunet-service-fs_cp.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/fs/gnunet-service-fs_cp.c b/src/fs/gnunet-service-fs_cp.c
index 7066b0698..1d52f28f9 100644
--- a/src/fs/gnunet-service-fs_cp.c
+++ b/src/fs/gnunet-service-fs_cp.c
@@ -250,7 +250,7 @@ struct GSF_ConnectedPeer
250 struct GNUNET_SCHEDULER_Task *rc_delay_task; 250 struct GNUNET_SCHEDULER_Task *rc_delay_task;
251 251
252 /** 252 /**
253 * Active requests from this neighbour, map of query to 'struct PeerRequest'. 253 * Active requests from this neighbour, map of query to `struct PeerRequest`.
254 */ 254 */
255 struct GNUNET_CONTAINER_MultiHashMap *request_map; 255 struct GNUNET_CONTAINER_MultiHashMap *request_map;
256 256
@@ -646,7 +646,8 @@ GSF_peer_connect_handler_ (const struct GNUNET_PeerIdentity *peer,
646 cp->rc = 646 cp->rc =
647 GNUNET_ATS_reserve_bandwidth (GSF_ats, peer, DBLOCK_SIZE, 647 GNUNET_ATS_reserve_bandwidth (GSF_ats, peer, DBLOCK_SIZE,
648 &ats_reserve_callback, cp); 648 &ats_reserve_callback, cp);
649 cp->request_map = GNUNET_CONTAINER_multihashmap_create (128, GNUNET_NO); 649 cp->request_map = GNUNET_CONTAINER_multihashmap_create (128,
650 GNUNET_YES);
650 GNUNET_break (GNUNET_OK == 651 GNUNET_break (GNUNET_OK ==
651 GNUNET_CONTAINER_multipeermap_put (cp_map, 652 GNUNET_CONTAINER_multipeermap_put (cp_map,
652 GSF_connected_peer_get_identity2_ (cp), 653 GSF_connected_peer_get_identity2_ (cp),
@@ -811,8 +812,10 @@ free_pending_request (struct PeerRequest *peerreq,
811 GNUNET_SCHEDULER_cancel (peerreq->kill_task); 812 GNUNET_SCHEDULER_cancel (peerreq->kill_task);
812 peerreq->kill_task = NULL; 813 peerreq->kill_task = NULL;
813 } 814 }
814 GNUNET_STATISTICS_update (GSF_stats, gettext_noop ("# P2P searches active"), 815 GNUNET_STATISTICS_update (GSF_stats,
815 -1, GNUNET_NO); 816 gettext_noop ("# P2P searches active"),
817 -1,
818 GNUNET_NO);
816 GNUNET_break (GNUNET_YES == 819 GNUNET_break (GNUNET_YES ==
817 GNUNET_CONTAINER_multihashmap_remove (cp->request_map, 820 GNUNET_CONTAINER_multihashmap_remove (cp->request_map,
818 query, 821 query,
@@ -1288,6 +1291,7 @@ GSF_handle_p2p_query_ (const struct GNUNET_PeerIdentity *other,
1288 uint32_t ttl_decrement; 1291 uint32_t ttl_decrement;
1289 struct TestExistClosure tec; 1292 struct TestExistClosure tec;
1290 GNUNET_PEER_Id spid; 1293 GNUNET_PEER_Id spid;
1294 const struct GSF_PendingRequestData *prd;
1291 1295
1292 msize = ntohs (message->size); 1296 msize = ntohs (message->size);
1293 if (msize < sizeof (struct GetMessage)) 1297 if (msize < sizeof (struct GetMessage))
@@ -1452,20 +1456,25 @@ GSF_handle_p2p_query_ (const struct GNUNET_PeerIdentity *other,
1452 spid, 1456 spid,
1453 GNUNET_PEER_intern (other), 1457 GNUNET_PEER_intern (other),
1454 NULL, 0, /* replies_seen */ 1458 NULL, 0, /* replies_seen */
1455 &handle_p2p_reply, peerreq); 1459 &handle_p2p_reply,
1460 peerreq);
1456 GNUNET_assert (NULL != pr); 1461 GNUNET_assert (NULL != pr);
1462 prd = GSF_pending_request_get_data_ (pr);
1457 peerreq->pr = pr; 1463 peerreq->pr = pr;
1458 GNUNET_break (GNUNET_OK == 1464 GNUNET_break (GNUNET_OK ==
1459 GNUNET_CONTAINER_multihashmap_put (cp->request_map, 1465 GNUNET_CONTAINER_multihashmap_put (cp->request_map,
1460 &gm->query, 1466 &prd->query,
1461 peerreq, 1467 peerreq,
1462 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); 1468 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE));
1463 GNUNET_STATISTICS_update (GSF_stats, 1469 GNUNET_STATISTICS_update (GSF_stats,
1464 gettext_noop 1470 gettext_noop
1465 ("# P2P query messages received and processed"), 1, 1471 ("# P2P query messages received and processed"),
1472 1,
1473 GNUNET_NO);
1474 GNUNET_STATISTICS_update (GSF_stats,
1475 gettext_noop ("# P2P searches active"),
1476 1,
1466 GNUNET_NO); 1477 GNUNET_NO);
1467 GNUNET_STATISTICS_update (GSF_stats, gettext_noop ("# P2P searches active"),
1468 1, GNUNET_NO);
1469 return pr; 1478 return pr;
1470} 1479}
1471 1480