aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNathan S. Evans <evans@in.tum.de>2011-07-26 18:26:14 +0000
committerNathan S. Evans <evans@in.tum.de>2011-07-26 18:26:14 +0000
commit9b6ccb91e1a8d4da5341c2fbe4d766c1602d4153 (patch)
tree202491dd1d070cf3beb15b91fe9ff3650b35b914 /src
parent81eae49a1b5dfeadb9aac5974ec87cd01aed9ffd (diff)
downloadgnunet-9b6ccb91e1a8d4da5341c2fbe4d766c1602d4153.tar.gz
gnunet-9b6ccb91e1a8d4da5341c2fbe4d766c1602d4153.zip
undo
Diffstat (limited to 'src')
-rw-r--r--src/peerinfo/gnunet-service-peerinfo.c22
1 files changed, 4 insertions, 18 deletions
diff --git a/src/peerinfo/gnunet-service-peerinfo.c b/src/peerinfo/gnunet-service-peerinfo.c
index 0d86e483c..d5d153b65 100644
--- a/src/peerinfo/gnunet-service-peerinfo.c
+++ b/src/peerinfo/gnunet-service-peerinfo.c
@@ -51,8 +51,6 @@
51 */ 51 */
52#define DATA_HOST_CLEAN_FREQ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 60) 52#define DATA_HOST_CLEAN_FREQ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 60)
53 53
54#define WRITE_TO_DISK GNUNET_NO
55
56/** 54/**
57 * In-memory cache of known hosts. 55 * In-memory cache of known hosts.
58 */ 56 */
@@ -115,7 +113,6 @@ make_info_message (const struct HostEntry *he)
115} 113}
116 114
117 115
118#if WRITE_TO_DISK
119/** 116/**
120 * Address iterator that causes expired entries to be discarded. 117 * Address iterator that causes expired entries to be discarded.
121 * 118 *
@@ -160,7 +157,6 @@ get_host_filename (const struct GNUNET_PeerIdentity *id)
160 "%s%s%s", networkIdDirectory, DIR_SEPARATOR_STR, &fil); 157 "%s%s%s", networkIdDirectory, DIR_SEPARATOR_STR, &fil);
161 return fn; 158 return fn;
162} 159}
163#endif
164 160
165 161
166/** 162/**
@@ -191,14 +187,12 @@ static void
191add_host_to_known_hosts (const struct GNUNET_PeerIdentity *identity) 187add_host_to_known_hosts (const struct GNUNET_PeerIdentity *identity)
192{ 188{
193 struct HostEntry *entry; 189 struct HostEntry *entry;
194#if WRITE_TO_DISK
195 char buffer[GNUNET_SERVER_MAX_MESSAGE_SIZE - 1]; 190 char buffer[GNUNET_SERVER_MAX_MESSAGE_SIZE - 1];
196 const struct GNUNET_HELLO_Message *hello; 191 const struct GNUNET_HELLO_Message *hello;
197 struct GNUNET_HELLO_Message *hello_clean; 192 struct GNUNET_HELLO_Message *hello_clean;
198 int size; 193 int size;
199 struct GNUNET_TIME_Absolute now; 194 struct GNUNET_TIME_Absolute now;
200 char *fn; 195 char *fn;
201#endif
202 196
203 entry = GNUNET_CONTAINER_multihashmap_get (hostmap, 197 entry = GNUNET_CONTAINER_multihashmap_get (hostmap,
204 &identity->hashPubKey); 198 &identity->hashPubKey);
@@ -210,7 +204,7 @@ add_host_to_known_hosts (const struct GNUNET_PeerIdentity *identity)
210 GNUNET_NO); 204 GNUNET_NO);
211 entry = GNUNET_malloc (sizeof (struct HostEntry)); 205 entry = GNUNET_malloc (sizeof (struct HostEntry));
212 entry->identity = *identity; 206 entry->identity = *identity;
213#if WRITE_TO_DISK 207
214 fn = get_host_filename (identity); 208 fn = get_host_filename (identity);
215 if (GNUNET_DISK_file_test (fn) == GNUNET_YES) 209 if (GNUNET_DISK_file_test (fn) == GNUNET_YES)
216 { 210 {
@@ -236,7 +230,6 @@ add_host_to_known_hosts (const struct GNUNET_PeerIdentity *identity)
236 } 230 }
237 } 231 }
238 GNUNET_free (fn); 232 GNUNET_free (fn);
239#endif
240 GNUNET_CONTAINER_multihashmap_put (hostmap, 233 GNUNET_CONTAINER_multihashmap_put (hostmap,
241 &identity->hashPubKey, 234 &identity->hashPubKey,
242 entry, 235 entry,
@@ -244,7 +237,7 @@ add_host_to_known_hosts (const struct GNUNET_PeerIdentity *identity)
244 notify_all (entry); 237 notify_all (entry);
245} 238}
246 239
247#if WRITE_TO_DISK 240
248/** 241/**
249 * Remove a file that should not be there. LOG 242 * Remove a file that should not be there. LOG
250 * success or failure. 243 * success or failure.
@@ -326,7 +319,7 @@ cron_scan_directory_data_hosts (void *cls,
326 GNUNET_SCHEDULER_add_delayed (DATA_HOST_FREQ, 319 GNUNET_SCHEDULER_add_delayed (DATA_HOST_FREQ,
327 &cron_scan_directory_data_hosts, NULL); 320 &cron_scan_directory_data_hosts, NULL);
328} 321}
329#endif 322
330 323
331/** 324/**
332 * Bind a host address (hello) to a hostId. 325 * Bind a host address (hello) to a hostId.
@@ -338,9 +331,7 @@ static void
338bind_address (const struct GNUNET_PeerIdentity *peer, 331bind_address (const struct GNUNET_PeerIdentity *peer,
339 const struct GNUNET_HELLO_Message *hello) 332 const struct GNUNET_HELLO_Message *hello)
340{ 333{
341#if WRITE_TO_DISK
342 char *fn; 334 char *fn;
343#endif
344 struct HostEntry *host; 335 struct HostEntry *host;
345 struct GNUNET_HELLO_Message *mrg; 336 struct GNUNET_HELLO_Message *mrg;
346 struct GNUNET_TIME_Absolute delta; 337 struct GNUNET_TIME_Absolute delta;
@@ -368,7 +359,6 @@ bind_address (const struct GNUNET_PeerIdentity *peer,
368 GNUNET_free (host->hello); 359 GNUNET_free (host->hello);
369 host->hello = mrg; 360 host->hello = mrg;
370 } 361 }
371#if WRITE_TO_DISK
372 fn = get_host_filename (peer); 362 fn = get_host_filename (peer);
373 if (GNUNET_OK == GNUNET_DISK_directory_create_for_file (fn)) 363 if (GNUNET_OK == GNUNET_DISK_directory_create_for_file (fn))
374 { 364 {
@@ -384,7 +374,6 @@ bind_address (const struct GNUNET_PeerIdentity *peer,
384 374
385 } 375 }
386 GNUNET_free (fn); 376 GNUNET_free (fn);
387#endif
388 notify_all (host); 377 notify_all (host);
389} 378}
390 379
@@ -428,7 +417,7 @@ add_to_tc (void *cls,
428 return GNUNET_YES; 417 return GNUNET_YES;
429} 418}
430 419
431#if WRITE_TO_DISK 420
432/** 421/**
433 * @brief delete expired HELLO entries in data/hosts/ 422 * @brief delete expired HELLO entries in data/hosts/
434 */ 423 */
@@ -489,7 +478,6 @@ cron_clean_data_hosts (void *cls,
489 GNUNET_SCHEDULER_add_delayed (DATA_HOST_CLEAN_FREQ, 478 GNUNET_SCHEDULER_add_delayed (DATA_HOST_CLEAN_FREQ,
490 &cron_clean_data_hosts, NULL); 479 &cron_clean_data_hosts, NULL);
491} 480}
492#endif
493 481
494 482
495/** 483/**
@@ -695,7 +683,6 @@ run (void *cls,
695 hostmap = GNUNET_CONTAINER_multihashmap_create (1024); 683 hostmap = GNUNET_CONTAINER_multihashmap_create (1024);
696 stats = GNUNET_STATISTICS_create ("peerinfo", cfg); 684 stats = GNUNET_STATISTICS_create ("peerinfo", cfg);
697 notify_list = GNUNET_SERVER_notification_context_create (server, 0); 685 notify_list = GNUNET_SERVER_notification_context_create (server, 0);
698#if WRITE_TO_DISK
699 GNUNET_assert (GNUNET_OK == 686 GNUNET_assert (GNUNET_OK ==
700 GNUNET_CONFIGURATION_get_value_filename (cfg, 687 GNUNET_CONFIGURATION_get_value_filename (cfg,
701 "peerinfo", 688 "peerinfo",
@@ -706,7 +693,6 @@ run (void *cls,
706 &cron_scan_directory_data_hosts, NULL); 693 &cron_scan_directory_data_hosts, NULL);
707 GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, 694 GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE,
708 &cron_clean_data_hosts, NULL); 695 &cron_clean_data_hosts, NULL);
709#endif
710 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, 696 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
711 &shutdown_task, NULL); 697 &shutdown_task, NULL);
712 GNUNET_SERVER_add_handlers (server, handlers); 698 GNUNET_SERVER_add_handlers (server, handlers);