aboutsummaryrefslogtreecommitdiff
path: root/src/peerinfo
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-01-03 22:40:33 +0000
committerChristian Grothoff <christian@grothoff.org>2013-01-03 22:40:33 +0000
commit7d10aae1489414e5cba3ea6dedd77223eda6216a (patch)
treeb4d8a50041859975c06df633bcd5428e2084039f /src/peerinfo
parent48390cae71be23aaa7f4be516c31688628b62c8d (diff)
downloadgnunet-7d10aae1489414e5cba3ea6dedd77223eda6216a.tar.gz
gnunet-7d10aae1489414e5cba3ea6dedd77223eda6216a.zip
adding NO_IO option to peerinfo to disable disc accesses for experiments
Diffstat (limited to 'src/peerinfo')
-rw-r--r--src/peerinfo/gnunet-service-peerinfo.c66
-rw-r--r--src/peerinfo/peerinfo.conf.in4
2 files changed, 43 insertions, 27 deletions
diff --git a/src/peerinfo/gnunet-service-peerinfo.c b/src/peerinfo/gnunet-service-peerinfo.c
index 18f10621a..bd7a93fe5 100644
--- a/src/peerinfo/gnunet-service-peerinfo.c
+++ b/src/peerinfo/gnunet-service-peerinfo.c
@@ -171,6 +171,8 @@ get_host_filename (const struct GNUNET_PeerIdentity *id)
171 struct GNUNET_CRYPTO_HashAsciiEncoded fil; 171 struct GNUNET_CRYPTO_HashAsciiEncoded fil;
172 char *fn; 172 char *fn;
173 173
174 if (NULL == networkIdDirectory)
175 return NULL;
174 GNUNET_CRYPTO_hash_to_enc (&id->hashPubKey, &fil); 176 GNUNET_CRYPTO_hash_to_enc (&id->hashPubKey, &fil);
175 GNUNET_asprintf (&fn, "%s%s%s", networkIdDirectory, DIR_SEPARATOR_STR, &fil); 177 GNUNET_asprintf (&fn, "%s%s%s", networkIdDirectory, DIR_SEPARATOR_STR, &fil);
176 return fn; 178 return fn;
@@ -271,8 +273,11 @@ add_host_to_known_hosts (const struct GNUNET_PeerIdentity *identity)
271 GNUNET_CONTAINER_multihashmap_put (hostmap, &entry->identity.hashPubKey, entry, 273 GNUNET_CONTAINER_multihashmap_put (hostmap, &entry->identity.hashPubKey, entry,
272 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); 274 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
273 fn = get_host_filename (identity); 275 fn = get_host_filename (identity);
274 entry->hello = read_host_file (fn, GNUNET_YES); 276 if (NULL != fn)
275 GNUNET_free (fn); 277 {
278 entry->hello = read_host_file (fn, GNUNET_YES);
279 GNUNET_free (fn);
280 }
276 notify_all (entry); 281 notify_all (entry);
277} 282}
278 283
@@ -457,7 +462,8 @@ bind_address (const struct GNUNET_PeerIdentity *peer,
457 host->hello = mrg; 462 host->hello = mrg;
458 } 463 }
459 fn = get_host_filename (peer); 464 fn = get_host_filename (peer);
460 if (GNUNET_OK == GNUNET_DISK_directory_create_for_file (fn)) 465 if ( (NULL != fn) &&
466 (GNUNET_OK == GNUNET_DISK_directory_create_for_file (fn)) )
461 { 467 {
462 cnt = 0; 468 cnt = 0;
463 (void) GNUNET_HELLO_iterate_addresses (hello, GNUNET_NO, &count_addresses, 469 (void) GNUNET_HELLO_iterate_addresses (hello, GNUNET_NO, &count_addresses,
@@ -479,7 +485,7 @@ bind_address (const struct GNUNET_PeerIdentity *peer,
479 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "write", fn); 485 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "write", fn);
480 } 486 }
481 } 487 }
482 GNUNET_free (fn); 488 GNUNET_free_non_null (fn);
483 notify_all (host); 489 notify_all (host);
484} 490}
485 491
@@ -775,35 +781,41 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
775 char *peerdir; 781 char *peerdir;
776 char *ip; 782 char *ip;
777 struct DirScanContext dsc; 783 struct DirScanContext dsc;
784 int noio;
778 785
779 hostmap = GNUNET_CONTAINER_multihashmap_create (1024, GNUNET_YES); 786 hostmap = GNUNET_CONTAINER_multihashmap_create (1024, GNUNET_YES);
780 stats = GNUNET_STATISTICS_create ("peerinfo", cfg); 787 stats = GNUNET_STATISTICS_create ("peerinfo", cfg);
781 notify_list = GNUNET_SERVER_notification_context_create (server, 0); 788 notify_list = GNUNET_SERVER_notification_context_create (server, 0);
782 GNUNET_assert (GNUNET_OK == 789 noio = GNUNET_CONFIGURATION_get_value_yesno (cfg, "peerionfo", "NO_IO");
783 GNUNET_CONFIGURATION_get_value_filename (cfg, "peerinfo", 790 if (GNUNET_YES != noio)
784 "HOSTS", 791 {
785 &networkIdDirectory)); 792 GNUNET_assert (GNUNET_OK ==
786 GNUNET_DISK_directory_create (networkIdDirectory); 793 GNUNET_CONFIGURATION_get_value_filename (cfg, "peerinfo",
787 GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, 794 "HOSTS",
788 &cron_scan_directory_data_hosts, NULL); 795 &networkIdDirectory));
789 GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, 796 GNUNET_DISK_directory_create (networkIdDirectory);
790 &cron_clean_data_hosts, NULL); 797 GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE,
798 &cron_scan_directory_data_hosts, NULL);
799 GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE,
800 &cron_clean_data_hosts, NULL);
801 ip = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_DATADIR);
802 GNUNET_asprintf (&peerdir,
803 "%shellos",
804 ip);
805 GNUNET_free (ip);
806 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
807 _("Importing HELLOs from `%s'\n"),
808 peerdir);
809 dsc.matched = 0;
810 dsc.remove_files = GNUNET_NO;
811 GNUNET_DISK_directory_scan (peerdir,
812 &hosts_directory_scan_callback, &dsc);
813 GNUNET_free (peerdir);
814 }
815 GNUNET_SERVER_add_handlers (server, handlers);
791 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, 816 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task,
792 NULL); 817 NULL);
793 GNUNET_SERVER_add_handlers (server, handlers); 818
794 ip = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_DATADIR);
795 GNUNET_asprintf (&peerdir,
796 "%shellos",
797 ip);
798 GNUNET_free (ip);
799 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
800 _("Importing HELLOs from `%s'\n"),
801 peerdir);
802 dsc.matched = 0;
803 dsc.remove_files = GNUNET_NO;
804 GNUNET_DISK_directory_scan (peerdir,
805 &hosts_directory_scan_callback, &dsc);
806 GNUNET_free (peerdir);
807} 819}
808 820
809 821
diff --git a/src/peerinfo/peerinfo.conf.in b/src/peerinfo/peerinfo.conf.in
index 34015b558..1420da844 100644
--- a/src/peerinfo/peerinfo.conf.in
+++ b/src/peerinfo/peerinfo.conf.in
@@ -20,5 +20,9 @@ UNIX_MATCH_GID = YES
20# PREFIX = 20# PREFIX =
21HOSTS = $SERVICEHOME/data/hosts/ 21HOSTS = $SERVICEHOME/data/hosts/
22 22
23# Option to disable all disk IO; only useful for testbed runs
24# (large-scale experiments); disables persistence of HELLOs!
25NO_IO = NO
26
23[uri] 27[uri]
24hello = gnunet-peerinfo 28hello = gnunet-peerinfo