aboutsummaryrefslogtreecommitdiff
path: root/src/peerinfo
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-08-15 21:54:06 +0000
committerChristian Grothoff <christian@grothoff.org>2011-08-15 21:54:06 +0000
commit5746309cb4be2073d550ad7a6885e918631dbc38 (patch)
tree89455bc4aadf977816b38df13f990372cd81d71a /src/peerinfo
parent6fd3e715cae09fa6e657c96f1c6f9711ee51f42f (diff)
downloadgnunet-5746309cb4be2073d550ad7a6885e918631dbc38.tar.gz
gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.zip
indentation
Diffstat (limited to 'src/peerinfo')
-rw-r--r--src/peerinfo/gnunet-service-peerinfo.c101
-rw-r--r--src/peerinfo/peerinfo_api.c46
-rw-r--r--src/peerinfo/peerinfo_api_notify.c21
-rwxr-xr-xsrc/peerinfo/perf_peerinfo_api.c50
-rw-r--r--src/peerinfo/test_peerinfo_api.c44
5 files changed, 117 insertions, 145 deletions
diff --git a/src/peerinfo/gnunet-service-peerinfo.c b/src/peerinfo/gnunet-service-peerinfo.c
index 160993649..26fec5289 100644
--- a/src/peerinfo/gnunet-service-peerinfo.c
+++ b/src/peerinfo/gnunet-service-peerinfo.c
@@ -124,10 +124,9 @@ make_info_message (const struct HostEntry *he)
124 * @return GNUNET_NO if expiration smaller than the current time 124 * @return GNUNET_NO if expiration smaller than the current time
125 */ 125 */
126static int 126static int
127discard_expired (void *cls, 127discard_expired (void *cls, const char *tname,
128 const char *tname, 128 struct GNUNET_TIME_Absolute expiration, const void *addr,
129 struct GNUNET_TIME_Absolute expiration, 129 uint16_t addrlen)
130 const void *addr, uint16_t addrlen)
131{ 130{
132 const struct GNUNET_TIME_Absolute *now = cls; 131 const struct GNUNET_TIME_Absolute *now = cls;
133 132
@@ -170,8 +169,8 @@ notify_all (struct HostEntry *entry)
170 struct InfoMessage *msg; 169 struct InfoMessage *msg;
171 170
172 msg = make_info_message (entry); 171 msg = make_info_message (entry);
173 GNUNET_SERVER_notification_context_broadcast (notify_list, 172 GNUNET_SERVER_notification_context_broadcast (notify_list, &msg->header,
174 &msg->header, GNUNET_NO); 173 GNUNET_NO);
175 GNUNET_free (msg); 174 GNUNET_free (msg);
176} 175}
177 176
@@ -195,8 +194,8 @@ add_host_to_known_hosts (const struct GNUNET_PeerIdentity *identity)
195 entry = GNUNET_CONTAINER_multihashmap_get (hostmap, &identity->hashPubKey); 194 entry = GNUNET_CONTAINER_multihashmap_get (hostmap, &identity->hashPubKey);
196 if (entry != NULL) 195 if (entry != NULL)
197 return; 196 return;
198 GNUNET_STATISTICS_update (stats, 197 GNUNET_STATISTICS_update (stats, gettext_noop ("# peers known"), 1,
199 gettext_noop ("# peers known"), 1, GNUNET_NO); 198 GNUNET_NO);
200 entry = GNUNET_malloc (sizeof (struct HostEntry)); 199 entry = GNUNET_malloc (sizeof (struct HostEntry));
201 entry->identity = *identity; 200 entry->identity = *identity;
202 201
@@ -216,16 +215,14 @@ add_host_to_known_hosts (const struct GNUNET_PeerIdentity *identity)
216 else 215 else
217 { 216 {
218 now = GNUNET_TIME_absolute_get (); 217 now = GNUNET_TIME_absolute_get ();
219 hello_clean = GNUNET_HELLO_iterate_addresses (hello, 218 hello_clean =
220 GNUNET_YES, 219 GNUNET_HELLO_iterate_addresses (hello, GNUNET_YES, &discard_expired,
221 &discard_expired, &now); 220 &now);
222 entry->hello = hello_clean; 221 entry->hello = hello_clean;
223 } 222 }
224 } 223 }
225 GNUNET_free (fn); 224 GNUNET_free (fn);
226 GNUNET_CONTAINER_multihashmap_put (hostmap, 225 GNUNET_CONTAINER_multihashmap_put (hostmap, &identity->hashPubKey, entry,
227 &identity->hashPubKey,
228 entry,
229 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); 226 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY);
230 notify_all (entry); 227 notify_all (entry);
231} 228}
@@ -244,8 +241,8 @@ remove_garbage (const char *fullname)
244 ("File `%s' in directory `%s' does not match naming convention. " 241 ("File `%s' in directory `%s' does not match naming convention. "
245 "Removed.\n"), fullname, networkIdDirectory); 242 "Removed.\n"), fullname, networkIdDirectory);
246 else 243 else
247 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR | 244 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,
248 GNUNET_ERROR_TYPE_BULK, "unlink", fullname); 245 "unlink", fullname);
249} 246}
250 247
251 248
@@ -271,8 +268,8 @@ hosts_directory_scan_callback (void *cls, const char *fullname)
271 remove_garbage (fullname); 268 remove_garbage (fullname);
272 return GNUNET_OK; 269 return GNUNET_OK;
273 } 270 }
274 if (GNUNET_OK != GNUNET_CRYPTO_hash_from_string (filename, 271 if (GNUNET_OK !=
275 &identity.hashPubKey)) 272 GNUNET_CRYPTO_hash_from_string (filename, &identity.hashPubKey))
276 { 273 {
277 remove_garbage (fullname); 274 remove_garbage (fullname);
278 return GNUNET_OK; 275 return GNUNET_OK;
@@ -305,11 +302,10 @@ cron_scan_directory_data_hosts (void *cls,
305 GNUNET_DISK_directory_scan (networkIdDirectory, 302 GNUNET_DISK_directory_scan (networkIdDirectory,
306 &hosts_directory_scan_callback, &count); 303 &hosts_directory_scan_callback, &count);
307 if ((0 == count) && (0 == (++retries & 31))) 304 if ((0 == count) && (0 == (++retries & 31)))
308 GNUNET_log (GNUNET_ERROR_TYPE_WARNING | 305 GNUNET_log (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK,
309 GNUNET_ERROR_TYPE_BULK,
310 _("Still no peers found in `%s'!\n"), networkIdDirectory); 306 _("Still no peers found in `%s'!\n"), networkIdDirectory);
311 GNUNET_SCHEDULER_add_delayed (DATA_HOST_FREQ, 307 GNUNET_SCHEDULER_add_delayed (DATA_HOST_FREQ, &cron_scan_directory_data_hosts,
312 &cron_scan_directory_data_hosts, NULL); 308 NULL);
313} 309}
314 310
315 311
@@ -352,9 +348,7 @@ bind_address (const struct GNUNET_PeerIdentity *peer,
352 if (GNUNET_OK == GNUNET_DISK_directory_create_for_file (fn)) 348 if (GNUNET_OK == GNUNET_DISK_directory_create_for_file (fn))
353 { 349 {
354 if (GNUNET_SYSERR == 350 if (GNUNET_SYSERR ==
355 GNUNET_DISK_fn_write (fn, 351 GNUNET_DISK_fn_write (fn, host->hello, GNUNET_HELLO_size (host->hello),
356 host->hello,
357 GNUNET_HELLO_size (host->hello),
358 GNUNET_DISK_PERM_USER_READ | 352 GNUNET_DISK_PERM_USER_READ |
359 GNUNET_DISK_PERM_USER_WRITE | 353 GNUNET_DISK_PERM_USER_WRITE |
360 GNUNET_DISK_PERM_GROUP_READ | 354 GNUNET_DISK_PERM_GROUP_READ |
@@ -425,14 +419,11 @@ discard_hosts_helper (void *cls, const char *fn)
425 return GNUNET_OK; 419 return GNUNET_OK;
426 } 420 }
427 hello = (const struct GNUNET_HELLO_Message *) buffer; 421 hello = (const struct GNUNET_HELLO_Message *) buffer;
428 new_hello = GNUNET_HELLO_iterate_addresses (hello, 422 new_hello =
429 GNUNET_YES, 423 GNUNET_HELLO_iterate_addresses (hello, GNUNET_YES, &discard_expired, now);
430 &discard_expired, now);
431 if (new_hello != NULL) 424 if (new_hello != NULL)
432 { 425 {
433 GNUNET_DISK_fn_write (fn, 426 GNUNET_DISK_fn_write (fn, new_hello, GNUNET_HELLO_size (new_hello),
434 new_hello,
435 GNUNET_HELLO_size (new_hello),
436 GNUNET_DISK_PERM_USER_READ | 427 GNUNET_DISK_PERM_USER_READ |
437 GNUNET_DISK_PERM_USER_WRITE | 428 GNUNET_DISK_PERM_USER_WRITE |
438 GNUNET_DISK_PERM_GROUP_READ | 429 GNUNET_DISK_PERM_GROUP_READ |
@@ -461,8 +452,8 @@ cron_clean_data_hosts (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
461 return; 452 return;
462 now = GNUNET_TIME_absolute_get (); 453 now = GNUNET_TIME_absolute_get ();
463 GNUNET_DISK_directory_scan (networkIdDirectory, &discard_hosts_helper, &now); 454 GNUNET_DISK_directory_scan (networkIdDirectory, &discard_hosts_helper, &now);
464 GNUNET_SCHEDULER_add_delayed (DATA_HOST_CLEAN_FREQ, 455 GNUNET_SCHEDULER_add_delayed (DATA_HOST_CLEAN_FREQ, &cron_clean_data_hosts,
465 &cron_clean_data_hosts, NULL); 456 NULL);
466} 457}
467 458
468 459
@@ -474,8 +465,7 @@ cron_clean_data_hosts (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
474 * @param message the actual message 465 * @param message the actual message
475 */ 466 */
476static void 467static void
477handle_hello (void *cls, 468handle_hello (void *cls, struct GNUNET_SERVER_Client *client,
478 struct GNUNET_SERVER_Client *client,
479 const struct GNUNET_MessageHeader *message) 469 const struct GNUNET_MessageHeader *message)
480{ 470{
481 const struct GNUNET_HELLO_Message *hello; 471 const struct GNUNET_HELLO_Message *hello;
@@ -489,8 +479,7 @@ handle_hello (void *cls,
489 return; 479 return;
490 } 480 }
491#if DEBUG_PEERINFO 481#if DEBUG_PEERINFO
492 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 482 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "`%s' message received for peer `%4s'\n",
493 "`%s' message received for peer `%4s'\n",
494 "HELLO", GNUNET_i2s (&pid)); 483 "HELLO", GNUNET_i2s (&pid));
495#endif 484#endif
496 bind_address (&pid, hello); 485 bind_address (&pid, hello);
@@ -506,8 +495,7 @@ handle_hello (void *cls,
506 * @param message the actual message 495 * @param message the actual message
507 */ 496 */
508static void 497static void
509handle_get (void *cls, 498handle_get (void *cls, struct GNUNET_SERVER_Client *client,
510 struct GNUNET_SERVER_Client *client,
511 const struct GNUNET_MessageHeader *message) 499 const struct GNUNET_MessageHeader *message)
512{ 500{
513 const struct ListPeerMessage *lpm; 501 const struct ListPeerMessage *lpm;
@@ -516,13 +504,11 @@ handle_get (void *cls,
516 lpm = (const struct ListPeerMessage *) message; 504 lpm = (const struct ListPeerMessage *) message;
517 GNUNET_break (0 == ntohl (lpm->reserved)); 505 GNUNET_break (0 == ntohl (lpm->reserved));
518#if DEBUG_PEERINFO 506#if DEBUG_PEERINFO
519 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 507 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "`%s' message received for peer `%4s'\n",
520 "`%s' message received for peer `%4s'\n",
521 "GET", GNUNET_i2s (&lpm->peer)); 508 "GET", GNUNET_i2s (&lpm->peer));
522#endif 509#endif
523 tc = GNUNET_SERVER_transmit_context_create (client); 510 tc = GNUNET_SERVER_transmit_context_create (client);
524 GNUNET_CONTAINER_multihashmap_get_multiple (hostmap, 511 GNUNET_CONTAINER_multihashmap_get_multiple (hostmap, &lpm->peer.hashPubKey,
525 &lpm->peer.hashPubKey,
526 &add_to_tc, tc); 512 &add_to_tc, tc);
527 GNUNET_SERVER_transmit_context_append_data (tc, NULL, 0, 513 GNUNET_SERVER_transmit_context_append_data (tc, NULL, 0,
528 GNUNET_MESSAGE_TYPE_PEERINFO_INFO_END); 514 GNUNET_MESSAGE_TYPE_PEERINFO_INFO_END);
@@ -538,8 +524,7 @@ handle_get (void *cls,
538 * @param message the actual message 524 * @param message the actual message
539 */ 525 */
540static void 526static void
541handle_get_all (void *cls, 527handle_get_all (void *cls, struct GNUNET_SERVER_Client *client,
542 struct GNUNET_SERVER_Client *client,
543 const struct GNUNET_MessageHeader *message) 528 const struct GNUNET_MessageHeader *message)
544{ 529{
545 struct GNUNET_SERVER_TransmitContext *tc; 530 struct GNUNET_SERVER_TransmitContext *tc;
@@ -563,8 +548,8 @@ do_notify_entry (void *cls, const GNUNET_HashCode * key, void *value)
563 struct InfoMessage *msg; 548 struct InfoMessage *msg;
564 549
565 msg = make_info_message (he); 550 msg = make_info_message (he);
566 GNUNET_SERVER_notification_context_unicast (notify_list, 551 GNUNET_SERVER_notification_context_unicast (notify_list, client, &msg->header,
567 client, &msg->header, GNUNET_NO); 552 GNUNET_NO);
568 GNUNET_free (msg); 553 GNUNET_free (msg);
569 return GNUNET_YES; 554 return GNUNET_YES;
570} 555}
@@ -578,8 +563,7 @@ do_notify_entry (void *cls, const GNUNET_HashCode * key, void *value)
578 * @param message the actual message 563 * @param message the actual message
579 */ 564 */
580static void 565static void
581handle_notify (void *cls, 566handle_notify (void *cls, struct GNUNET_SERVER_Client *client,
582 struct GNUNET_SERVER_Client *client,
583 const struct GNUNET_MessageHeader *message) 567 const struct GNUNET_MessageHeader *message)
584{ 568{
585#if DEBUG_PEERINFO 569#if DEBUG_PEERINFO
@@ -630,8 +614,7 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
630 * @param cfg configuration to use 614 * @param cfg configuration to use
631 */ 615 */
632static void 616static void
633run (void *cls, 617run (void *cls, struct GNUNET_SERVER_Handle *server,
634 struct GNUNET_SERVER_Handle *server,
635 const struct GNUNET_CONFIGURATION_Handle *cfg) 618 const struct GNUNET_CONFIGURATION_Handle *cfg)
636{ 619{
637 static const struct GNUNET_SERVER_MessageHandler handlers[] = { 620 static const struct GNUNET_SERVER_MessageHandler handlers[] = {
@@ -649,8 +632,7 @@ run (void *cls,
649 stats = GNUNET_STATISTICS_create ("peerinfo", cfg); 632 stats = GNUNET_STATISTICS_create ("peerinfo", cfg);
650 notify_list = GNUNET_SERVER_notification_context_create (server, 0); 633 notify_list = GNUNET_SERVER_notification_context_create (server, 0);
651 GNUNET_assert (GNUNET_OK == 634 GNUNET_assert (GNUNET_OK ==
652 GNUNET_CONFIGURATION_get_value_filename (cfg, 635 GNUNET_CONFIGURATION_get_value_filename (cfg, "peerinfo",
653 "peerinfo",
654 "HOSTS", 636 "HOSTS",
655 &networkIdDirectory)); 637 &networkIdDirectory));
656 GNUNET_DISK_directory_create (networkIdDirectory); 638 GNUNET_DISK_directory_create (networkIdDirectory);
@@ -658,8 +640,8 @@ run (void *cls,
658 &cron_scan_directory_data_hosts, NULL); 640 &cron_scan_directory_data_hosts, NULL);
659 GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, 641 GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE,
660 &cron_clean_data_hosts, NULL); 642 &cron_clean_data_hosts, NULL);
661 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, 643 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task,
662 &shutdown_task, NULL); 644 NULL);
663 GNUNET_SERVER_add_handlers (server, handlers); 645 GNUNET_SERVER_add_handlers (server, handlers);
664} 646}
665 647
@@ -676,11 +658,10 @@ main (int argc, char *const *argv)
676{ 658{
677 int ret; 659 int ret;
678 660
679 ret = (GNUNET_OK == 661 ret =
680 GNUNET_SERVICE_run (argc, 662 (GNUNET_OK ==
681 argv, 663 GNUNET_SERVICE_run (argc, argv, "peerinfo", GNUNET_SERVICE_OPTION_NONE,
682 "peerinfo", 664 &run, NULL)) ? 0 : 1;
683 GNUNET_SERVICE_OPTION_NONE, &run, NULL)) ? 0 : 1;
684 GNUNET_free_non_null (networkIdDirectory); 665 GNUNET_free_non_null (networkIdDirectory);
685 return ret; 666 return ret;
686} 667}
diff --git a/src/peerinfo/peerinfo_api.c b/src/peerinfo/peerinfo_api.c
index 444ae98e2..4febf2eeb 100644
--- a/src/peerinfo/peerinfo_api.c
+++ b/src/peerinfo/peerinfo_api.c
@@ -240,8 +240,9 @@ reconnect (struct GNUNET_PEERINFO_Handle *h)
240 h->client = GNUNET_CLIENT_connect ("peerinfo", h->cfg); 240 h->client = GNUNET_CLIENT_connect ("peerinfo", h->cfg);
241 if (NULL == h->client) 241 if (NULL == h->client)
242 { 242 {
243 h->r_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, 243 h->r_task =
244 &reconnect_task, h); 244 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &reconnect_task,
245 h);
245 return; 246 return;
246 } 247 }
247 trigger_transmit (h); 248 trigger_transmit (h);
@@ -283,8 +284,8 @@ do_transmit (void *cls, size_t size, void *buf)
283 memcpy (buf, &tqe[1], ret); 284 memcpy (buf, &tqe[1], ret);
284#if DEBUG_PEERINFO 285#if DEBUG_PEERINFO
285 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 286 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
286 "Transmitting request of size %u to `%s' service.\n", 287 "Transmitting request of size %u to `%s' service.\n", ret,
287 ret, "PEERINFO"); 288 "PEERINFO");
288#endif 289#endif
289 GNUNET_CONTAINER_DLL_remove (h->tq_head, h->tq_tail, tqe); 290 GNUNET_CONTAINER_DLL_remove (h->tq_head, h->tq_tail, tqe);
290 if (tqe->cont != NULL) 291 if (tqe->cont != NULL)
@@ -318,11 +319,11 @@ trigger_transmit (struct GNUNET_PEERINFO_Handle *h)
318 reconnect (h); 319 reconnect (h);
319 return; 320 return;
320 } 321 }
321 h->th = GNUNET_CLIENT_notify_transmit_ready (h->client, 322 h->th =
322 tqe->size, 323 GNUNET_CLIENT_notify_transmit_ready (h->client, tqe->size,
323 GNUNET_TIME_absolute_get_remaining 324 GNUNET_TIME_absolute_get_remaining
324 (tqe->timeout), GNUNET_YES, 325 (tqe->timeout), GNUNET_YES,
325 &do_transmit, h); 326 &do_transmit, h);
326} 327}
327 328
328 329
@@ -487,9 +488,8 @@ peerinfo_handler (void *cls, const struct GNUNET_MessageHeader *msg)
487 ic->h->in_receive = GNUNET_YES; 488 ic->h->in_receive = GNUNET_YES;
488 if (ic->callback != NULL) 489 if (ic->callback != NULL)
489 ic->callback (ic->callback_cls, &im->peer, hello, NULL); 490 ic->callback (ic->callback_cls, &im->peer, hello, NULL);
490 GNUNET_CLIENT_receive (ic->h->client, 491 GNUNET_CLIENT_receive (ic->h->client, &peerinfo_handler, ic,
491 &peerinfo_handler, 492 GNUNET_TIME_absolute_get_remaining (ic->timeout));
492 ic, GNUNET_TIME_absolute_get_remaining (ic->timeout));
493} 493}
494 494
495 495
@@ -527,9 +527,8 @@ iterator_start_receive (void *cls, int transmit_success)
527 ic->h->in_receive = GNUNET_YES; 527 ic->h->in_receive = GNUNET_YES;
528 ic->in_receive = GNUNET_YES; 528 ic->in_receive = GNUNET_YES;
529 ic->tqe = NULL; 529 ic->tqe = NULL;
530 GNUNET_CLIENT_receive (ic->h->client, 530 GNUNET_CLIENT_receive (ic->h->client, &peerinfo_handler, ic,
531 &peerinfo_handler, 531 GNUNET_TIME_absolute_get_remaining (ic->timeout));
532 ic, GNUNET_TIME_absolute_get_remaining (ic->timeout));
533} 532}
534 533
535 534
@@ -549,8 +548,7 @@ signal_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
549 GNUNET_CONTAINER_DLL_remove (ic->h->tq_head, ic->h->tq_tail, ic->tqe); 548 GNUNET_CONTAINER_DLL_remove (ic->h->tq_head, ic->h->tq_tail, ic->tqe);
550 else 549 else
551 reconnect (ic->h); 550 reconnect (ic->h);
552 ic->callback (ic->callback_cls, 551 ic->callback (ic->callback_cls, NULL, NULL,
553 NULL, NULL,
554 _ 552 _
555 ("Timeout transmitting iteration request to `PEERINFO' service.\n")); 553 ("Timeout transmitting iteration request to `PEERINFO' service.\n"));
556 ic->callback = NULL; 554 ic->callback = NULL;
@@ -592,8 +590,9 @@ GNUNET_PEERINFO_iterate (struct GNUNET_PEERINFO_Handle *h,
592 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 590 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
593 "Requesting list of peers from PEERINFO service\n"); 591 "Requesting list of peers from PEERINFO service\n");
594#endif 592#endif
595 tqe = GNUNET_malloc (sizeof (struct TransmissionQueueEntry) + 593 tqe =
596 sizeof (struct GNUNET_MessageHeader)); 594 GNUNET_malloc (sizeof (struct TransmissionQueueEntry) +
595 sizeof (struct GNUNET_MessageHeader));
597 tqe->size = sizeof (struct GNUNET_MessageHeader); 596 tqe->size = sizeof (struct GNUNET_MessageHeader);
598 lapm = (struct GNUNET_MessageHeader *) &tqe[1]; 597 lapm = (struct GNUNET_MessageHeader *) &tqe[1];
599 lapm->size = htons (sizeof (struct GNUNET_MessageHeader)); 598 lapm->size = htons (sizeof (struct GNUNET_MessageHeader));
@@ -606,8 +605,9 @@ GNUNET_PEERINFO_iterate (struct GNUNET_PEERINFO_Handle *h,
606 "Requesting information on peer `%4s' from PEERINFO service\n", 605 "Requesting information on peer `%4s' from PEERINFO service\n",
607 GNUNET_i2s (peer)); 606 GNUNET_i2s (peer));
608#endif 607#endif
609 tqe = GNUNET_malloc (sizeof (struct TransmissionQueueEntry) + 608 tqe =
610 sizeof (struct ListPeerMessage)); 609 GNUNET_malloc (sizeof (struct TransmissionQueueEntry) +
610 sizeof (struct ListPeerMessage));
611 tqe->size = sizeof (struct ListPeerMessage); 611 tqe->size = sizeof (struct ListPeerMessage);
612 lpm = (struct ListPeerMessage *) &tqe[1]; 612 lpm = (struct ListPeerMessage *) &tqe[1];
613 lpm->header.size = htons (sizeof (struct ListPeerMessage)); 613 lpm->header.size = htons (sizeof (struct ListPeerMessage));
@@ -620,8 +620,8 @@ GNUNET_PEERINFO_iterate (struct GNUNET_PEERINFO_Handle *h,
620 ic->callback = callback; 620 ic->callback = callback;
621 ic->callback_cls = callback_cls; 621 ic->callback_cls = callback_cls;
622 ic->timeout = GNUNET_TIME_relative_to_absolute (timeout); 622 ic->timeout = GNUNET_TIME_relative_to_absolute (timeout);
623 ic->timeout_task = GNUNET_SCHEDULER_add_delayed (timeout, 623 ic->timeout_task =
624 &signal_timeout, ic); 624 GNUNET_SCHEDULER_add_delayed (timeout, &signal_timeout, ic);
625 tqe->timeout = ic->timeout; 625 tqe->timeout = ic->timeout;
626 tqe->cont = &iterator_start_receive; 626 tqe->cont = &iterator_start_receive;
627 tqe->cont_cls = ic; 627 tqe->cont_cls = ic;
diff --git a/src/peerinfo/peerinfo_api_notify.c b/src/peerinfo/peerinfo_api_notify.c
index 0c7474f4a..4ec7b2192 100644
--- a/src/peerinfo/peerinfo_api_notify.c
+++ b/src/peerinfo/peerinfo_api_notify.c
@@ -104,8 +104,8 @@ reconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
104 if (NULL == nc->client) 104 if (NULL == nc->client)
105 { 105 {
106 /* ugh */ 106 /* ugh */
107 nc->task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, 107 nc->task =
108 &reconnect, nc); 108 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &reconnect, nc);
109 return; 109 return;
110 } 110 }
111 request_notifications (nc); 111 request_notifications (nc);
@@ -176,9 +176,8 @@ process_notification (void *cls, const struct GNUNET_MessageHeader *msg)
176static void 176static void
177receive_notifications (struct GNUNET_PEERINFO_NotifyContext *nc) 177receive_notifications (struct GNUNET_PEERINFO_NotifyContext *nc)
178{ 178{
179 GNUNET_CLIENT_receive (nc->client, 179 GNUNET_CLIENT_receive (nc->client, &process_notification, nc,
180 &process_notification, 180 GNUNET_TIME_UNIT_FOREVER_REL);
181 nc, GNUNET_TIME_UNIT_FOREVER_REL);
182} 181}
183 182
184 183
@@ -223,12 +222,12 @@ static void
223request_notifications (struct GNUNET_PEERINFO_NotifyContext *nc) 222request_notifications (struct GNUNET_PEERINFO_NotifyContext *nc)
224{ 223{
225 GNUNET_assert (NULL == nc->init); 224 GNUNET_assert (NULL == nc->init);
226 nc->init = GNUNET_CLIENT_notify_transmit_ready (nc->client, 225 nc->init =
227 sizeof (struct 226 GNUNET_CLIENT_notify_transmit_ready (nc->client,
228 GNUNET_MessageHeader), 227 sizeof (struct GNUNET_MessageHeader),
229 GNUNET_TIME_UNIT_FOREVER_REL, 228 GNUNET_TIME_UNIT_FOREVER_REL,
230 GNUNET_YES, 229 GNUNET_YES, &transmit_notify_request,
231 &transmit_notify_request, nc); 230 nc);
232} 231}
233 232
234 233
diff --git a/src/peerinfo/perf_peerinfo_api.c b/src/peerinfo/perf_peerinfo_api.c
index d0eadaf94..d9107c8fe 100755
--- a/src/peerinfo/perf_peerinfo_api.c
+++ b/src/peerinfo/perf_peerinfo_api.c
@@ -47,9 +47,7 @@ static struct GNUNET_PEERINFO_Handle *h;
47static unsigned int numpeers; 47static unsigned int numpeers;
48 48
49static int 49static int
50check_it (void *cls, 50check_it (void *cls, const char *tname, struct GNUNET_TIME_Absolute expiration,
51 const char *tname,
52 struct GNUNET_TIME_Absolute expiration,
53 const void *addr, uint16_t addrlen) 51 const void *addr, uint16_t addrlen)
54{ 52{
55#if DEBUG 53#if DEBUG
@@ -74,10 +72,11 @@ address_generator (void *cls, size_t max, void *buf)
74 72
75 GNUNET_asprintf (&address, "Address%d", *agc); 73 GNUNET_asprintf (&address, "Address%d", *agc);
76 74
77 ret = GNUNET_HELLO_add_address ("peerinfotest", 75 ret =
78 GNUNET_TIME_relative_to_absolute 76 GNUNET_HELLO_add_address ("peerinfotest",
79 (GNUNET_TIME_UNIT_HOURS), 77 GNUNET_TIME_relative_to_absolute
80 address, strlen (address) + 1, buf, max); 78 (GNUNET_TIME_UNIT_HOURS), address,
79 strlen (address) + 1, buf, max);
81 GNUNET_free (address); 80 GNUNET_free (address);
82 *agc = 0; 81 *agc = 0;
83 return ret; 82 return ret;
@@ -100,8 +99,7 @@ add_peer (size_t i)
100 99
101 100
102static void 101static void
103process (void *cls, 102process (void *cls, const struct GNUNET_PeerIdentity *peer,
104 const struct GNUNET_PeerIdentity *peer,
105 const struct GNUNET_HELLO_Message *hello, const char *err_msg) 103 const struct GNUNET_HELLO_Message *hello, const char *err_msg)
106{ 104{
107 if (peer == NULL) 105 if (peer == NULL)
@@ -124,9 +122,8 @@ process (void *cls,
124 122
125 123
126static void 124static void
127run (void *cls, 125run (void *cls, char *const *args, const char *cfgfile,
128 char *const *args, 126 const struct GNUNET_CONFIGURATION_Handle *c)
129 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
130{ 127{
131 size_t i; 128 size_t i;
132 129
@@ -136,11 +133,10 @@ run (void *cls,
136 for (i = 0; i < NUM_REQUESTS; i++) 133 for (i = 0; i < NUM_REQUESTS; i++)
137 { 134 {
138 add_peer (i); 135 add_peer (i);
139 ic[i] = GNUNET_PEERINFO_iterate (h, 136 ic[i] =
140 NULL, 137 GNUNET_PEERINFO_iterate (h, NULL,
141 GNUNET_TIME_relative_multiply 138 GNUNET_TIME_relative_multiply
142 (GNUNET_TIME_UNIT_SECONDS, 30), 139 (GNUNET_TIME_UNIT_SECONDS, 30), &process, cls);
143 &process, cls);
144 } 140 }
145} 141}
146 142
@@ -165,21 +161,21 @@ check ()
165 struct GNUNET_GETOPT_CommandLineOption options[] = { 161 struct GNUNET_GETOPT_CommandLineOption options[] = {
166 GNUNET_GETOPT_OPTION_END 162 GNUNET_GETOPT_OPTION_END
167 }; 163 };
168 proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-peerinfo", 164 proc =
169 "gnunet-service-peerinfo", 165 GNUNET_OS_start_process (NULL, NULL, "gnunet-service-peerinfo",
166 "gnunet-service-peerinfo",
170#if DEBUG_PEERINFO 167#if DEBUG_PEERINFO
171 "-L", "DEBUG", 168 "-L", "DEBUG",
172#else 169#else
173 "-L", "ERROR", 170 "-L", "ERROR",
174#endif 171#endif
175 "-c", "test_peerinfo_api_data.conf", NULL); 172 "-c", "test_peerinfo_api_data.conf", NULL);
176#endif 173#endif
177 GNUNET_assert (NULL != proc); 174 GNUNET_assert (NULL != proc);
178 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, 175 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv,
179 argv, "perf-peerinfo-api", "nohelp", options, &run, &ok); 176 "perf-peerinfo-api", "nohelp", options, &run, &ok);
180 fprintf (stderr, 177 fprintf (stderr, "Received %u/%u calls before timeout\n", numpeers,
181 "Received %u/%u calls before timeout\n", 178 NUM_REQUESTS * NUM_REQUESTS / 2);
182 numpeers, NUM_REQUESTS * NUM_REQUESTS / 2);
183 GAUGER ("PEERINFO", "Peerinfo lookups", numpeers / 30, "peers/s"); 179 GAUGER ("PEERINFO", "Peerinfo lookups", numpeers / 30, "peers/s");
184#if START_SERVICE 180#if START_SERVICE
185 if (0 != GNUNET_OS_process_kill (proc, SIGTERM)) 181 if (0 != GNUNET_OS_process_kill (proc, SIGTERM))
diff --git a/src/peerinfo/test_peerinfo_api.c b/src/peerinfo/test_peerinfo_api.c
index e740f1fc9..bbdc591f4 100644
--- a/src/peerinfo/test_peerinfo_api.c
+++ b/src/peerinfo/test_peerinfo_api.c
@@ -45,9 +45,7 @@ static struct GNUNET_PEERINFO_Handle *h;
45static unsigned int retries; 45static unsigned int retries;
46 46
47static int 47static int
48check_it (void *cls, 48check_it (void *cls, const char *tname, struct GNUNET_TIME_Absolute expiration,
49 const char *tname,
50 struct GNUNET_TIME_Absolute expiration,
51 const void *addr, uint16_t addrlen) 49 const void *addr, uint16_t addrlen)
52{ 50{
53 unsigned int *agc = cls; 51 unsigned int *agc = cls;
@@ -70,10 +68,11 @@ address_generator (void *cls, size_t max, void *buf)
70 68
71 if (0 == *agc) 69 if (0 == *agc)
72 return 0; 70 return 0;
73 ret = GNUNET_HELLO_add_address ("peerinfotest", 71 ret =
74 GNUNET_TIME_relative_to_absolute 72 GNUNET_HELLO_add_address ("peerinfotest",
75 (GNUNET_TIME_UNIT_HOURS), "Address", *agc, 73 GNUNET_TIME_relative_to_absolute
76 buf, max); 74 (GNUNET_TIME_UNIT_HOURS), "Address", *agc, buf,
75 max);
77 (*agc)--; 76 (*agc)--;
78 return ret; 77 return ret;
79} 78}
@@ -98,8 +97,7 @@ add_peer ()
98 97
99 98
100static void 99static void
101process (void *cls, 100process (void *cls, const struct GNUNET_PeerIdentity *peer,
102 const struct GNUNET_PeerIdentity *peer,
103 const struct GNUNET_HELLO_Message *hello, const char *err_msg) 101 const struct GNUNET_HELLO_Message *hello, const char *err_msg)
104{ 102{
105 int *ok = cls; 103 int *ok = cls;
@@ -119,11 +117,10 @@ process (void *cls,
119 /* try again */ 117 /* try again */
120 retries++; 118 retries++;
121 add_peer (); 119 add_peer ();
122 ic = GNUNET_PEERINFO_iterate (h, 120 ic = GNUNET_PEERINFO_iterate (h, NULL,
123 NULL,
124 GNUNET_TIME_relative_multiply 121 GNUNET_TIME_relative_multiply
125 (GNUNET_TIME_UNIT_SECONDS, 15), 122 (GNUNET_TIME_UNIT_SECONDS, 15), &process,
126 &process, cls); 123 cls);
127 return; 124 return;
128 } 125 }
129 GNUNET_assert (peer == NULL); 126 GNUNET_assert (peer == NULL);
@@ -145,16 +142,14 @@ process (void *cls,
145 142
146 143
147static void 144static void
148run (void *cls, 145run (void *cls, char *const *args, const char *cfgfile,
149 char *const *args, 146 const struct GNUNET_CONFIGURATION_Handle *c)
150 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
151{ 147{
152 cfg = c; 148 cfg = c;
153 h = GNUNET_PEERINFO_connect (cfg); 149 h = GNUNET_PEERINFO_connect (cfg);
154 GNUNET_assert (h != NULL); 150 GNUNET_assert (h != NULL);
155 add_peer (); 151 add_peer ();
156 ic = GNUNET_PEERINFO_iterate (h, 152 ic = GNUNET_PEERINFO_iterate (h, NULL,
157 NULL,
158 GNUNET_TIME_relative_multiply 153 GNUNET_TIME_relative_multiply
159 (GNUNET_TIME_UNIT_SECONDS, 15), &process, cls); 154 (GNUNET_TIME_UNIT_SECONDS, 15), &process, cls);
160} 155}
@@ -177,15 +172,16 @@ check ()
177 struct GNUNET_GETOPT_CommandLineOption options[] = { 172 struct GNUNET_GETOPT_CommandLineOption options[] = {
178 GNUNET_GETOPT_OPTION_END 173 GNUNET_GETOPT_OPTION_END
179 }; 174 };
180 proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-peerinfo", 175 proc =
181 "gnunet-service-peerinfo", 176 GNUNET_OS_start_process (NULL, NULL, "gnunet-service-peerinfo",
177 "gnunet-service-peerinfo",
182#if DEBUG_PEERINFO 178#if DEBUG_PEERINFO
183 "-L", "DEBUG", 179 "-L", "DEBUG",
184#endif 180#endif
185 "-c", "test_peerinfo_api_data.conf", NULL); 181 "-c", "test_peerinfo_api_data.conf", NULL);
186 GNUNET_assert (NULL != proc); 182 GNUNET_assert (NULL != proc);
187 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, 183 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv,
188 argv, "test-peerinfo-api", "nohelp", options, &run, &ok); 184 "test-peerinfo-api", "nohelp", options, &run, &ok);
189 if (0 != GNUNET_OS_process_kill (proc, SIGTERM)) 185 if (0 != GNUNET_OS_process_kill (proc, SIGTERM))
190 { 186 {
191 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 187 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");