aboutsummaryrefslogtreecommitdiff
path: root/src/fs/gnunet-service-fs_cp.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-09-30 22:01:13 +0000
committerChristian Grothoff <christian@grothoff.org>2013-09-30 22:01:13 +0000
commit7abf844d0d4de319f2b093d50b0334af9a9d3bda (patch)
tree212272d6aaf9e5530ce44418149b9158f1eb0f7c /src/fs/gnunet-service-fs_cp.c
parent8556fe9ebd0c4f8e63577a43155ffede20607f41 (diff)
downloadgnunet-7abf844d0d4de319f2b093d50b0334af9a9d3bda.tar.gz
gnunet-7abf844d0d4de319f2b093d50b0334af9a9d3bda.zip
-fixing build issues in fs/set related to #3047
Diffstat (limited to 'src/fs/gnunet-service-fs_cp.c')
-rw-r--r--src/fs/gnunet-service-fs_cp.c52
1 files changed, 30 insertions, 22 deletions
diff --git a/src/fs/gnunet-service-fs_cp.c b/src/fs/gnunet-service-fs_cp.c
index f5b5213bc..a9e950363 100644
--- a/src/fs/gnunet-service-fs_cp.c
+++ b/src/fs/gnunet-service-fs_cp.c
@@ -24,6 +24,7 @@
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26#include "platform.h" 26#include "platform.h"
27#include "gnunet_util_lib.h"
27#include "gnunet_load_lib.h" 28#include "gnunet_load_lib.h"
28#include "gnunet-service-fs.h" 29#include "gnunet-service-fs.h"
29#include "gnunet-service-fs_cp.h" 30#include "gnunet-service-fs_cp.h"
@@ -307,7 +308,7 @@ struct GSF_ConnectedPeer
307/** 308/**
308 * Map from peer identities to 'struct GSF_ConnectPeer' entries. 309 * Map from peer identities to 'struct GSF_ConnectPeer' entries.
309 */ 310 */
310static struct GNUNET_CONTAINER_MultiHashMap *cp_map; 311static struct GNUNET_CONTAINER_MultiPeerMap *cp_map;
311 312
312/** 313/**
313 * Where do we store respect information? 314 * Where do we store respect information?
@@ -325,11 +326,13 @@ static char *respectDirectory;
325static char * 326static char *
326get_respect_filename (const struct GNUNET_PeerIdentity *id) 327get_respect_filename (const struct GNUNET_PeerIdentity *id)
327{ 328{
328 struct GNUNET_CRYPTO_HashAsciiEncoded fil;
329 char *fn; 329 char *fn;
330 330
331 GNUNET_CRYPTO_hash_to_enc (&id->hashPubKey, &fil); 331 GNUNET_asprintf (&fn,
332 GNUNET_asprintf (&fn, "%s%s%s", respectDirectory, DIR_SEPARATOR_STR, &fil); 332 "%s%s%s",
333 respectDirectory,
334 DIR_SEPARATOR_STR,
335 GNUNET_i2s_full (id));
333 return fn; 336 return fn;
334} 337}
335 338
@@ -594,12 +597,12 @@ GSF_peer_connect_handler_ (const struct GNUNET_PeerIdentity *peer)
594 GNUNET_free (fn); 597 GNUNET_free (fn);
595 cp->request_map = GNUNET_CONTAINER_multihashmap_create (128, GNUNET_NO); 598 cp->request_map = GNUNET_CONTAINER_multihashmap_create (128, GNUNET_NO);
596 GNUNET_break (GNUNET_OK == 599 GNUNET_break (GNUNET_OK ==
597 GNUNET_CONTAINER_multihashmap_put (cp_map, 600 GNUNET_CONTAINER_multipeermap_put (cp_map,
598 &GSF_connected_peer_get_identity2_ (cp)->hashPubKey, 601 GSF_connected_peer_get_identity2_ (cp),
599 cp, 602 cp,
600 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); 603 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
601 GNUNET_STATISTICS_set (GSF_stats, gettext_noop ("# peers connected"), 604 GNUNET_STATISTICS_set (GSF_stats, gettext_noop ("# peers connected"),
602 GNUNET_CONTAINER_multihashmap_size (cp_map), 605 GNUNET_CONTAINER_multipeermap_size (cp_map),
603 GNUNET_NO); 606 GNUNET_NO);
604 GSF_push_start_ (cp); 607 GSF_push_start_ (cp);
605 return cp; 608 return cp;
@@ -643,7 +646,7 @@ GSF_peer_get_ (const struct GNUNET_PeerIdentity *peer)
643{ 646{
644 if (NULL == cp_map) 647 if (NULL == cp_map)
645 return NULL; 648 return NULL;
646 return GNUNET_CONTAINER_multihashmap_get (cp_map, &peer->hashPubKey); 649 return GNUNET_CONTAINER_multipeermap_get (cp_map, peer);
647} 650}
648 651
649 652
@@ -1490,10 +1493,11 @@ GSF_peer_disconnect_handler_ (void *cls, const struct GNUNET_PeerIdentity *peer)
1490 return; /* must have been disconnect from core with 1493 return; /* must have been disconnect from core with
1491 * 'peer' == my_id, ignore */ 1494 * 'peer' == my_id, ignore */
1492 GNUNET_assert (GNUNET_YES == 1495 GNUNET_assert (GNUNET_YES ==
1493 GNUNET_CONTAINER_multihashmap_remove (cp_map, 1496 GNUNET_CONTAINER_multipeermap_remove (cp_map,
1494 &peer->hashPubKey, cp)); 1497 peer,
1498 cp));
1495 GNUNET_STATISTICS_set (GSF_stats, gettext_noop ("# peers connected"), 1499 GNUNET_STATISTICS_set (GSF_stats, gettext_noop ("# peers connected"),
1496 GNUNET_CONTAINER_multihashmap_size (cp_map), 1500 GNUNET_CONTAINER_multipeermap_size (cp_map),
1497 GNUNET_NO); 1501 GNUNET_NO);
1498 if (NULL != cp->migration_pth) 1502 if (NULL != cp->migration_pth)
1499 { 1503 {
@@ -1579,7 +1583,7 @@ struct IterationContext
1579 * @return #GNUNET_YES to continue iteration 1583 * @return #GNUNET_YES to continue iteration
1580 */ 1584 */
1581static int 1585static int
1582call_iterator (void *cls, const struct GNUNET_HashCode * key, void *value) 1586call_iterator (void *cls, const struct GNUNET_PeerIdentity * key, void *value)
1583{ 1587{
1584 struct IterationContext *ic = cls; 1588 struct IterationContext *ic = cls;
1585 struct GSF_ConnectedPeer *cp = value; 1589 struct GSF_ConnectedPeer *cp = value;
@@ -1602,7 +1606,7 @@ GSF_iterate_connected_peers_ (GSF_ConnectedPeerIterator it, void *it_cls)
1602 1606
1603 ic.it = it; 1607 ic.it = it;
1604 ic.it_cls = it_cls; 1608 ic.it_cls = it_cls;
1605 GNUNET_CONTAINER_multihashmap_iterate (cp_map, &call_iterator, &ic); 1609 GNUNET_CONTAINER_multipeermap_iterate (cp_map, &call_iterator, &ic);
1606} 1610}
1607 1611
1608 1612
@@ -1709,7 +1713,7 @@ GSF_block_peer_migration_ (struct GSF_ConnectedPeer *cp,
1709 * @return GNUNET_OK to continue iteration 1713 * @return GNUNET_OK to continue iteration
1710 */ 1714 */
1711static int 1715static int
1712flush_respect (void *cls, const struct GNUNET_HashCode * key, void *value) 1716flush_respect (void *cls, const struct GNUNET_PeerIdentity * key, void *value)
1713{ 1717{
1714 struct GSF_ConnectedPeer *cp = value; 1718 struct GSF_ConnectedPeer *cp = value;
1715 char *fn; 1719 char *fn;
@@ -1772,7 +1776,7 @@ cron_flush_respect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1772 1776
1773 if (NULL == cp_map) 1777 if (NULL == cp_map)
1774 return; 1778 return;
1775 GNUNET_CONTAINER_multihashmap_iterate (cp_map, &flush_respect, NULL); 1779 GNUNET_CONTAINER_multipeermap_iterate (cp_map, &flush_respect, NULL);
1776 if (NULL == tc) 1780 if (NULL == tc)
1777 return; 1781 return;
1778 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 1782 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
@@ -1789,7 +1793,7 @@ cron_flush_respect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1789void 1793void
1790GSF_connected_peer_init_ () 1794GSF_connected_peer_init_ ()
1791{ 1795{
1792 cp_map = GNUNET_CONTAINER_multihashmap_create (128, GNUNET_YES); 1796 cp_map = GNUNET_CONTAINER_multipeermap_create (128, GNUNET_YES);
1793 GNUNET_assert (GNUNET_OK == 1797 GNUNET_assert (GNUNET_OK ==
1794 GNUNET_CONFIGURATION_get_value_filename (GSF_cfg, "fs", 1798 GNUNET_CONFIGURATION_get_value_filename (GSF_cfg, "fs",
1795 "RESPECT", 1799 "RESPECT",
@@ -1809,9 +1813,11 @@ GSF_connected_peer_init_ ()
1809 * @return #GNUNET_YES (we should continue to iterate) 1813 * @return #GNUNET_YES (we should continue to iterate)
1810 */ 1814 */
1811static int 1815static int
1812clean_peer (void *cls, const struct GNUNET_HashCode * key, void *value) 1816clean_peer (void *cls,
1817 const struct GNUNET_PeerIdentity *key,
1818 void *value)
1813{ 1819{
1814 GSF_peer_disconnect_handler_ (NULL, (const struct GNUNET_PeerIdentity *) key); 1820 GSF_peer_disconnect_handler_ (NULL, key);
1815 return GNUNET_YES; 1821 return GNUNET_YES;
1816} 1822}
1817 1823
@@ -1823,8 +1829,8 @@ void
1823GSF_connected_peer_done_ () 1829GSF_connected_peer_done_ ()
1824{ 1830{
1825 cron_flush_respect (NULL, NULL); 1831 cron_flush_respect (NULL, NULL);
1826 GNUNET_CONTAINER_multihashmap_iterate (cp_map, &clean_peer, NULL); 1832 GNUNET_CONTAINER_multipeermap_iterate (cp_map, &clean_peer, NULL);
1827 GNUNET_CONTAINER_multihashmap_destroy (cp_map); 1833 GNUNET_CONTAINER_multipeermap_destroy (cp_map);
1828 cp_map = NULL; 1834 cp_map = NULL;
1829 GNUNET_free (respectDirectory); 1835 GNUNET_free (respectDirectory);
1830 respectDirectory = NULL; 1836 respectDirectory = NULL;
@@ -1840,7 +1846,9 @@ GSF_connected_peer_done_ ()
1840 * @return #GNUNET_YES (we should continue to iterate) 1846 * @return #GNUNET_YES (we should continue to iterate)
1841 */ 1847 */
1842static int 1848static int
1843clean_local_client (void *cls, const struct GNUNET_HashCode * key, void *value) 1849clean_local_client (void *cls,
1850 const struct GNUNET_PeerIdentity *key,
1851 void *value)
1844{ 1852{
1845 const struct GSF_LocalClient *lc = cls; 1853 const struct GSF_LocalClient *lc = cls;
1846 struct GSF_ConnectedPeer *cp = value; 1854 struct GSF_ConnectedPeer *cp = value;
@@ -1864,7 +1872,7 @@ GSF_handle_local_client_disconnect_ (const struct GSF_LocalClient *lc)
1864{ 1872{
1865 if (NULL == cp_map) 1873 if (NULL == cp_map)
1866 return; /* already cleaned up */ 1874 return; /* already cleaned up */
1867 GNUNET_CONTAINER_multihashmap_iterate (cp_map, &clean_local_client, 1875 GNUNET_CONTAINER_multipeermap_iterate (cp_map, &clean_local_client,
1868 (void *) lc); 1876 (void *) lc);
1869} 1877}
1870 1878