aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-08-03 11:34:36 +0000
committerChristian Grothoff <christian@grothoff.org>2015-08-03 11:34:36 +0000
commite71c17ad3aebd7a8f444a08744288dec1415980c (patch)
tree51e7f3781f95e9afd22ba49e15b730f8f711464a /src
parent1e7bd3002f10aef6bd760e7caf13fb22a5f06345 (diff)
downloadgnunet-e71c17ad3aebd7a8f444a08744288dec1415980c.tar.gz
gnunet-e71c17ad3aebd7a8f444a08744288dec1415980c.zip
-improve indentation, reduce duplication of PIDs in core's neighbour map
Diffstat (limited to 'src')
-rw-r--r--src/core/gnunet-service-core_neighbours.c43
-rw-r--r--src/include/gnunet_container_lib.h5
-rw-r--r--src/transport/transport_api.c146
-rw-r--r--src/util/bandwidth.c2
4 files changed, 136 insertions, 60 deletions
diff --git a/src/core/gnunet-service-core_neighbours.c b/src/core/gnunet-service-core_neighbours.c
index f69f99870..5e5ed4db3 100644
--- a/src/core/gnunet-service-core_neighbours.c
+++ b/src/core/gnunet-service-core_neighbours.c
@@ -141,7 +141,8 @@ find_neighbour (const struct GNUNET_PeerIdentity *peer)
141{ 141{
142 if (NULL == neighbours) 142 if (NULL == neighbours)
143 return NULL; 143 return NULL;
144 return GNUNET_CONTAINER_multipeermap_get (neighbours, peer); 144 return GNUNET_CONTAINER_multipeermap_get (neighbours,
145 peer);
145} 146}
146 147
147 148
@@ -218,7 +219,9 @@ process_queue (struct Neighbour *n);
218 * @return number of bytes transmitted 219 * @return number of bytes transmitted
219 */ 220 */
220static size_t 221static size_t
221transmit_ready (void *cls, size_t size, void *buf) 222transmit_ready (void *cls,
223 size_t size,
224 void *buf)
222{ 225{
223 struct Neighbour *n = cls; 226 struct Neighbour *n = cls;
224 struct NeighbourMessageEntry *m; 227 struct NeighbourMessageEntry *m;
@@ -249,13 +252,16 @@ transmit_ready (void *cls, size_t size, void *buf)
249 } 252 }
250 cbuf = buf; 253 cbuf = buf;
251 GNUNET_assert (size >= m->size); 254 GNUNET_assert (size >= m->size);
252 memcpy (cbuf, &m[1], m->size); 255 memcpy (cbuf,
256 &m[1],
257 m->size);
253 ret = m->size; 258 ret = m->size;
254 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 259 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
255 "Copied message of type %u and size %u into transport buffer for `%4s'\n", 260 "Copied message of type %u and size %u into transport buffer for `%4s'\n",
256 (unsigned int) 261 (unsigned int)
257 ntohs (((struct GNUNET_MessageHeader *) &m[1])->type), 262 ntohs (((struct GNUNET_MessageHeader *) &m[1])->type),
258 (unsigned int) ret, GNUNET_i2s (&n->peer)); 263 (unsigned int) ret,
264 GNUNET_i2s (&n->peer));
259 GNUNET_free (m); 265 GNUNET_free (m);
260 n->has_excess_bandwidth = GNUNET_NO; 266 n->has_excess_bandwidth = GNUNET_NO;
261 process_queue (n); 267 process_queue (n);
@@ -336,20 +342,21 @@ handle_transport_notify_connect (void *cls,
336 return; 342 return;
337 } 343 }
338 n = find_neighbour (peer); 344 n = find_neighbour (peer);
339 if (n != NULL) 345 if (NULL != n)
340 { 346 {
341 /* duplicate connect notification!? */ 347 /* duplicate connect notification!? */
342 GNUNET_break (0); 348 GNUNET_break (0);
343 return; 349 return;
344 } 350 }
345 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 351 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
346 "Received connection from `%4s'.\n", 352 "Received connection from `%s'.\n",
347 GNUNET_i2s (peer)); 353 GNUNET_i2s (peer));
348 n = GNUNET_new (struct Neighbour); 354 n = GNUNET_new (struct Neighbour);
349 n->peer = *peer; 355 n->peer = *peer;
350 GNUNET_assert (GNUNET_OK == 356 GNUNET_assert (GNUNET_OK ==
351 GNUNET_CONTAINER_multipeermap_put (neighbours, 357 GNUNET_CONTAINER_multipeermap_put (neighbours,
352 &n->peer, n, 358 &n->peer,
359 n,
353 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); 360 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
354 GNUNET_STATISTICS_set (GSC_stats, 361 GNUNET_STATISTICS_set (GSC_stats,
355 gettext_noop ("# neighbour entries allocated"), 362 gettext_noop ("# neighbour entries allocated"),
@@ -373,7 +380,7 @@ handle_transport_notify_disconnect (void *cls,
373 struct Neighbour *n; 380 struct Neighbour *n;
374 381
375 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 382 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
376 "Peer `%4s' disconnected from us; received notification from transport.\n", 383 "Peer `%s' disconnected from us; received notification from transport.\n",
377 GNUNET_i2s (peer)); 384 GNUNET_i2s (peer));
378 n = find_neighbour (peer); 385 n = find_neighbour (peer);
379 if (NULL == n) 386 if (NULL == n)
@@ -401,15 +408,18 @@ handle_transport_receive (void *cls,
401 uint16_t type; 408 uint16_t type;
402 409
403 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 410 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
404 "Received message of type %u from `%4s', demultiplexing.\n", 411 "Received message of type %u from `%s', demultiplexing.\n",
405 (unsigned int) ntohs (message->type), GNUNET_i2s (peer)); 412 (unsigned int) ntohs (message->type),
406 if (0 == memcmp (peer, &GSC_my_identity, sizeof (struct GNUNET_PeerIdentity))) 413 GNUNET_i2s (peer));
414 if (0 == memcmp (peer,
415 &GSC_my_identity,
416 sizeof (struct GNUNET_PeerIdentity)))
407 { 417 {
408 GNUNET_break (0); 418 GNUNET_break (0);
409 return; 419 return;
410 } 420 }
411 n = find_neighbour (peer); 421 n = find_neighbour (peer);
412 if (n == NULL) 422 if (NULL == n)
413 { 423 {
414 /* received message from peer that is not connected!? */ 424 /* received message from peer that is not connected!? */
415 GNUNET_break (0); 425 GNUNET_break (0);
@@ -556,9 +566,12 @@ GSC_NEIGHBOURS_check_excess_bandwidth (const struct GNUNET_PeerIdentity *target)
556int 566int
557GSC_NEIGHBOURS_init () 567GSC_NEIGHBOURS_init ()
558{ 568{
559 neighbours = GNUNET_CONTAINER_multipeermap_create (128, GNUNET_NO); 569 neighbours = GNUNET_CONTAINER_multipeermap_create (128,
570 GNUNET_YES);
560 transport = 571 transport =
561 GNUNET_TRANSPORT_connect2 (GSC_cfg, &GSC_my_identity, NULL, 572 GNUNET_TRANSPORT_connect2 (GSC_cfg,
573 &GSC_my_identity,
574 NULL,
562 &handle_transport_receive, 575 &handle_transport_receive,
563 &handle_transport_notify_connect, 576 &handle_transport_notify_connect,
564 &handle_transport_notify_disconnect, 577 &handle_transport_notify_disconnect,
@@ -574,7 +587,7 @@ GSC_NEIGHBOURS_init ()
574 587
575 588
576/** 589/**
577 * Wrapper around 'free_neighbour'. 590 * Wrapper around #free_neighbour().
578 * 591 *
579 * @param cls unused 592 * @param cls unused
580 * @param key peer identity 593 * @param key peer identity
diff --git a/src/include/gnunet_container_lib.h b/src/include/gnunet_container_lib.h
index cfa494578..4375cdbb1 100644
--- a/src/include/gnunet_container_lib.h
+++ b/src/include/gnunet_container_lib.h
@@ -986,7 +986,12 @@ typedef int
986 void *value); 986 void *value);
987 987
988 988
989/**
990 * Hash map from peer identities to values.
991 */
989struct GNUNET_CONTAINER_MultiPeerMap; 992struct GNUNET_CONTAINER_MultiPeerMap;
993
994
990/** 995/**
991 * @ingroup hashmap 996 * @ingroup hashmap
992 * Create a multi peer map (hash map for public keys of peers). 997 * Create a multi peer map (hash map for public keys of peers).
diff --git a/src/transport/transport_api.c b/src/transport/transport_api.c
index f9e11ad7c..8ebf82b8a 100644
--- a/src/transport/transport_api.c
+++ b/src/transport/transport_api.c
@@ -414,7 +414,7 @@ struct GNUNET_TRANSPORT_Handle
414 414
415 /** 415 /**
416 * Hash map of the current connected neighbours of this peer. 416 * Hash map of the current connected neighbours of this peer.
417 * Maps peer identities to 'struct Neighbour' entries. 417 * Maps peer identities to `struct Neighbour` entries.
418 */ 418 */
419 struct GNUNET_CONTAINER_MultiPeerMap *neighbours; 419 struct GNUNET_CONTAINER_MultiPeerMap *neighbours;
420 420
@@ -493,7 +493,8 @@ static struct Neighbour *
493neighbour_find (struct GNUNET_TRANSPORT_Handle *h, 493neighbour_find (struct GNUNET_TRANSPORT_Handle *h,
494 const struct GNUNET_PeerIdentity *peer) 494 const struct GNUNET_PeerIdentity *peer)
495{ 495{
496 return GNUNET_CONTAINER_multipeermap_get (h->neighbours, peer); 496 return GNUNET_CONTAINER_multipeermap_get (h->neighbours,
497 peer);
497} 498}
498 499
499 500
@@ -561,14 +562,16 @@ neighbour_add (struct GNUNET_TRANSPORT_Handle *h,
561 n->is_ready = GNUNET_YES; 562 n->is_ready = GNUNET_YES;
562 n->traffic_overhead = 0; 563 n->traffic_overhead = 0;
563 GNUNET_BANDWIDTH_tracker_init2 (&n->out_tracker, 564 GNUNET_BANDWIDTH_tracker_init2 (&n->out_tracker,
564 &outbound_bw_tracker_update, n, 565 &outbound_bw_tracker_update,
566 n,
565 GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT, 567 GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT,
566 MAX_BANDWIDTH_CARRY_S, 568 MAX_BANDWIDTH_CARRY_S,
567 &notify_excess_cb, 569 &notify_excess_cb,
568 n); 570 n);
569 GNUNET_assert (GNUNET_OK == 571 GNUNET_assert (GNUNET_OK ==
570 GNUNET_CONTAINER_multipeermap_put (h->neighbours, 572 GNUNET_CONTAINER_multipeermap_put (h->neighbours,
571 &n->id, n, 573 &n->id,
574 n,
572 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); 575 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
573 return n; 576 return n;
574} 577}
@@ -586,19 +589,22 @@ neighbour_add (struct GNUNET_TRANSPORT_Handle *h,
586 */ 589 */
587static int 590static int
588neighbour_delete (void *cls, 591neighbour_delete (void *cls,
589 const struct GNUNET_PeerIdentity *key, void *value) 592 const struct GNUNET_PeerIdentity *key,
593 void *value)
590{ 594{
591 struct GNUNET_TRANSPORT_Handle *handle = cls; 595 struct GNUNET_TRANSPORT_Handle *handle = cls;
592 struct Neighbour *n = value; 596 struct Neighbour *n = value;
593 597
598 GNUNET_BANDWIDTH_tracker_notification_stop (&n->out_tracker);
594 if (NULL != handle->nd_cb) 599 if (NULL != handle->nd_cb)
595 handle->nd_cb (handle->cls, &n->id); 600 handle->nd_cb (handle->cls,
601 &n->id);
596 GNUNET_assert (NULL == n->th); 602 GNUNET_assert (NULL == n->th);
597 GNUNET_assert (NULL == n->hn); 603 GNUNET_assert (NULL == n->hn);
598 GNUNET_assert (GNUNET_YES == 604 GNUNET_assert (GNUNET_YES ==
599 GNUNET_CONTAINER_multipeermap_remove (handle->neighbours, key, 605 GNUNET_CONTAINER_multipeermap_remove (handle->neighbours,
606 key,
600 n)); 607 n));
601 GNUNET_BANDWIDTH_tracker_notification_stop (&n->out_tracker);
602 GNUNET_free (n); 608 GNUNET_free (n);
603 return GNUNET_YES; 609 return GNUNET_YES;
604} 610}
@@ -642,14 +648,17 @@ demultiplexer (void *cls,
642 disconnect_and_schedule_reconnect (h); 648 disconnect_and_schedule_reconnect (h);
643 return; 649 return;
644 } 650 }
645 GNUNET_CLIENT_receive (h->client, &demultiplexer, h, 651 GNUNET_CLIENT_receive (h->client,
652 &demultiplexer,
653 h,
646 GNUNET_TIME_UNIT_FOREVER_REL); 654 GNUNET_TIME_UNIT_FOREVER_REL);
647 size = ntohs (msg->size); 655 size = ntohs (msg->size);
648 switch (ntohs (msg->type)) 656 switch (ntohs (msg->type))
649 { 657 {
650 case GNUNET_MESSAGE_TYPE_HELLO: 658 case GNUNET_MESSAGE_TYPE_HELLO:
651 if (GNUNET_OK != 659 if (GNUNET_OK !=
652 GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) msg, &me)) 660 GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) msg,
661 &me))
653 { 662 {
654 GNUNET_break (0); 663 GNUNET_break (0);
655 break; 664 break;
@@ -697,15 +706,17 @@ demultiplexer (void *cls,
697 GNUNET_break (0); 706 GNUNET_break (0);
698 break; 707 break;
699 } 708 }
700 n = neighbour_add (h, &cim->id); 709 n = neighbour_add (h,
710 &cim->id);
701 LOG (GNUNET_ERROR_TYPE_DEBUG, 711 LOG (GNUNET_ERROR_TYPE_DEBUG,
702 "Receiving CONNECT message for `%4s' with quota %u\n", 712 "Receiving CONNECT message for `%4s' with quota %u\n",
703 GNUNET_i2s (&cim->id), 713 GNUNET_i2s (&cim->id),
704 ntohl (cim->quota_out.value__)); 714 ntohl (cim->quota_out.value__));
705 GNUNET_BANDWIDTH_tracker_update_quota (&n->out_tracker, 715 GNUNET_BANDWIDTH_tracker_update_quota (&n->out_tracker,
706 cim->quota_out); 716 cim->quota_out);
707 if (h->nc_cb != NULL) 717 if (NULL != h->nc_cb)
708 h->nc_cb (h->cls, &n->id); 718 h->nc_cb (h->cls,
719 &n->id);
709 break; 720 break;
710 case GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT: 721 case GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT:
711 if (size != sizeof (struct DisconnectInfoMessage)) 722 if (size != sizeof (struct DisconnectInfoMessage))
@@ -724,7 +735,9 @@ demultiplexer (void *cls,
724 GNUNET_break (0); 735 GNUNET_break (0);
725 break; 736 break;
726 } 737 }
727 neighbour_delete (h, &dim->peer, n); 738 neighbour_delete (h,
739 &dim->peer,
740 n);
728 break; 741 break;
729 case GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_OK: 742 case GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_OK:
730 if (size != sizeof (struct SendOkMessage)) 743 if (size != sizeof (struct SendOkMessage))
@@ -788,7 +801,9 @@ demultiplexer (void *cls,
788 break; 801 break;
789 } 802 }
790 if (NULL != h->rec) 803 if (NULL != h->rec)
791 h->rec (h->cls, &im->peer, imm); 804 h->rec (h->cls,
805 &im->peer,
806 imm);
792 break; 807 break;
793 case GNUNET_MESSAGE_TYPE_TRANSPORT_SET_QUOTA: 808 case GNUNET_MESSAGE_TYPE_TRANSPORT_SET_QUOTA:
794 if (size != sizeof (struct QuotaSetMessage)) 809 if (size != sizeof (struct QuotaSetMessage))
@@ -837,7 +852,9 @@ timeout_request_due_to_congestion (void *cls,
837 GNUNET_assert (th == n->th); 852 GNUNET_assert (th == n->th);
838 GNUNET_assert (NULL == n->hn); 853 GNUNET_assert (NULL == n->hn);
839 n->th = NULL; 854 n->th = NULL;
840 th->notify (th->notify_cls, 0, NULL); 855 th->notify (th->notify_cls,
856 0,
857 NULL);
841 GNUNET_free (th); 858 GNUNET_free (th);
842} 859}
843 860
@@ -851,7 +868,9 @@ timeout_request_due_to_congestion (void *cls,
851 * @return number of bytes copied to @a buf 868 * @return number of bytes copied to @a buf
852 */ 869 */
853static size_t 870static size_t
854transport_notify_ready (void *cls, size_t size, void *buf) 871transport_notify_ready (void *cls,
872 size_t size,
873 void *buf)
855{ 874{
856 struct GNUNET_TRANSPORT_Handle *h = cls; 875 struct GNUNET_TRANSPORT_Handle *h = cls;
857 struct GNUNET_TRANSPORT_TransmitHandle *th; 876 struct GNUNET_TRANSPORT_TransmitHandle *th;
@@ -874,7 +893,8 @@ transport_notify_ready (void *cls, size_t size, void *buf)
874 cbuf = buf; 893 cbuf = buf;
875 ret = 0; 894 ret = 0;
876 /* first send control messages */ 895 /* first send control messages */
877 while ((NULL != (th = h->control_head)) && (th->notify_size <= size)) 896 while ( (NULL != (th = h->control_head)) &&
897 (th->notify_size <= size) )
878 { 898 {
879 GNUNET_CONTAINER_DLL_remove (h->control_head, 899 GNUNET_CONTAINER_DLL_remove (h->control_head,
880 h->control_tail, 900 h->control_tail,
@@ -1173,23 +1193,31 @@ disconnect_and_schedule_reconnect (struct GNUNET_TRANSPORT_Handle *h)
1173 } 1193 }
1174 /* Forget about all neighbours that we used to be connected to */ 1194 /* Forget about all neighbours that we used to be connected to */
1175 GNUNET_CONTAINER_multipeermap_iterate (h->neighbours, 1195 GNUNET_CONTAINER_multipeermap_iterate (h->neighbours,
1176 &neighbour_delete, h); 1196 &neighbour_delete,
1177 if (h->quota_task != NULL) 1197 h);
1198 if (NULL != h->quota_task)
1178 { 1199 {
1179 GNUNET_SCHEDULER_cancel (h->quota_task); 1200 GNUNET_SCHEDULER_cancel (h->quota_task);
1180 h->quota_task = NULL; 1201 h->quota_task = NULL;
1181 } 1202 }
1182 while ((NULL != (th = h->control_head))) 1203 while ((NULL != (th = h->control_head)))
1183 { 1204 {
1184 GNUNET_CONTAINER_DLL_remove (h->control_head, h->control_tail, th); 1205 GNUNET_CONTAINER_DLL_remove (h->control_head,
1185 th->notify (th->notify_cls, 0, NULL); 1206 h->control_tail,
1207 th);
1208 th->notify (th->notify_cls,
1209 0,
1210 NULL);
1186 GNUNET_free (th); 1211 GNUNET_free (th);
1187 } 1212 }
1188 LOG (GNUNET_ERROR_TYPE_DEBUG, 1213 LOG (GNUNET_ERROR_TYPE_DEBUG,
1189 "Scheduling task to reconnect to transport service in %s.\n", 1214 "Scheduling task to reconnect to transport service in %s.\n",
1190 GNUNET_STRINGS_relative_time_to_string(h->reconnect_delay, GNUNET_YES)); 1215 GNUNET_STRINGS_relative_time_to_string (h->reconnect_delay,
1216 GNUNET_YES));
1191 h->reconnect_task = 1217 h->reconnect_task =
1192 GNUNET_SCHEDULER_add_delayed (h->reconnect_delay, &reconnect, h); 1218 GNUNET_SCHEDULER_add_delayed (h->reconnect_delay,
1219 &reconnect,
1220 h);
1193 h->reconnect_delay = GNUNET_TIME_STD_BACKOFF (h->reconnect_delay); 1221 h->reconnect_delay = GNUNET_TIME_STD_BACKOFF (h->reconnect_delay);
1194} 1222}
1195 1223
@@ -1206,7 +1234,9 @@ cancel_control_transmit (struct GNUNET_TRANSPORT_Handle *th,
1206{ 1234{
1207 LOG (GNUNET_ERROR_TYPE_DEBUG, 1235 LOG (GNUNET_ERROR_TYPE_DEBUG,
1208 "Canceling transmit of contral transmission requested\n"); 1236 "Canceling transmit of contral transmission requested\n");
1209 GNUNET_CONTAINER_DLL_remove (th->control_head, th->control_tail, tth); 1237 GNUNET_CONTAINER_DLL_remove (th->control_head,
1238 th->control_tail,
1239 tth);
1210 GNUNET_free (tth); 1240 GNUNET_free (tth);
1211} 1241}
1212 1242
@@ -1430,7 +1460,9 @@ GNUNET_TRANSPORT_try_disconnect_cancel (struct GNUNET_TRANSPORT_TryDisconnectHan
1430 * @return number of bytes copied to @a buf 1460 * @return number of bytes copied to @a buf
1431 */ 1461 */
1432static size_t 1462static size_t
1433send_hello (void *cls, size_t size, void *buf) 1463send_hello (void *cls,
1464 size_t size,
1465 void *buf)
1434{ 1466{
1435 struct GNUNET_TRANSPORT_OfferHelloHandle *ohh = cls; 1467 struct GNUNET_TRANSPORT_OfferHelloHandle *ohh = cls;
1436 struct GNUNET_MessageHeader *msg = ohh->msg; 1468 struct GNUNET_MessageHeader *msg = ohh->msg;
@@ -1446,9 +1478,12 @@ send_hello (void *cls, size_t size, void *buf)
1446 "Timeout while trying to transmit `%s' request.\n", 1478 "Timeout while trying to transmit `%s' request.\n",
1447 "HELLO"); 1479 "HELLO");
1448 if (NULL != ohh->cont) 1480 if (NULL != ohh->cont)
1449 ohh->cont (ohh->cls, &tc); 1481 ohh->cont (ohh->cls,
1482 &tc);
1450 GNUNET_free (msg); 1483 GNUNET_free (msg);
1451 GNUNET_CONTAINER_DLL_remove (ohh->th->oh_head, ohh->th->oh_tail, ohh); 1484 GNUNET_CONTAINER_DLL_remove (ohh->th->oh_head,
1485 ohh->th->oh_tail,
1486 ohh);
1452 GNUNET_free (ohh); 1487 GNUNET_free (ohh);
1453 return 0; 1488 return 0;
1454 } 1489 }
@@ -1457,12 +1492,17 @@ send_hello (void *cls, size_t size, void *buf)
1457 "HELLO"); 1492 "HELLO");
1458 ssize = ntohs (msg->size); 1493 ssize = ntohs (msg->size);
1459 GNUNET_assert (size >= ssize); 1494 GNUNET_assert (size >= ssize);
1460 memcpy (buf, msg, ssize); 1495 memcpy (buf,
1496 msg,
1497 ssize);
1461 GNUNET_free (msg); 1498 GNUNET_free (msg);
1462 tc.reason = GNUNET_SCHEDULER_REASON_READ_READY; 1499 tc.reason = GNUNET_SCHEDULER_REASON_READ_READY;
1463 if (NULL != ohh->cont) 1500 if (NULL != ohh->cont)
1464 ohh->cont (ohh->cls, &tc); 1501 ohh->cont (ohh->cls,
1465 GNUNET_CONTAINER_DLL_remove (ohh->th->oh_head, ohh->th->oh_tail, ohh); 1502 &tc);
1503 GNUNET_CONTAINER_DLL_remove (ohh->th->oh_head,
1504 ohh->th->oh_tail,
1505 ohh);
1466 GNUNET_free (ohh); 1506 GNUNET_free (ohh);
1467 return ssize; 1507 return ssize;
1468} 1508}
@@ -1556,7 +1596,8 @@ GNUNET_TRANSPORT_set_traffic_metric (struct GNUNET_TRANSPORT_Handle *handle,
1556struct GNUNET_TRANSPORT_OfferHelloHandle * 1596struct GNUNET_TRANSPORT_OfferHelloHandle *
1557GNUNET_TRANSPORT_offer_hello (struct GNUNET_TRANSPORT_Handle *handle, 1597GNUNET_TRANSPORT_offer_hello (struct GNUNET_TRANSPORT_Handle *handle,
1558 const struct GNUNET_MessageHeader *hello, 1598 const struct GNUNET_MessageHeader *hello,
1559 GNUNET_SCHEDULER_TaskCallback cont, void *cls) 1599 GNUNET_SCHEDULER_TaskCallback cont,
1600 void *cls)
1560{ 1601{
1561 struct GNUNET_TRANSPORT_OfferHelloHandle *ohh; 1602 struct GNUNET_TRANSPORT_OfferHelloHandle *ohh;
1562 struct GNUNET_MessageHeader *msg; 1603 struct GNUNET_MessageHeader *msg;
@@ -1569,7 +1610,8 @@ GNUNET_TRANSPORT_offer_hello (struct GNUNET_TRANSPORT_Handle *handle,
1569 size = ntohs (hello->size); 1610 size = ntohs (hello->size);
1570 GNUNET_break (size >= sizeof (struct GNUNET_MessageHeader)); 1611 GNUNET_break (size >= sizeof (struct GNUNET_MessageHeader));
1571 if (GNUNET_OK != 1612 if (GNUNET_OK !=
1572 GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) hello, &peer)) 1613 GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) hello,
1614 &peer))
1573 { 1615 {
1574 GNUNET_break (0); 1616 GNUNET_break (0);
1575 return NULL; 1617 return NULL;
@@ -1604,7 +1646,9 @@ GNUNET_TRANSPORT_offer_hello_cancel (struct GNUNET_TRANSPORT_OfferHelloHandle *o
1604 struct GNUNET_TRANSPORT_Handle *th = ohh->th; 1646 struct GNUNET_TRANSPORT_Handle *th = ohh->th;
1605 1647
1606 cancel_control_transmit (ohh->th, ohh->tth); 1648 cancel_control_transmit (ohh->th, ohh->tth);
1607 GNUNET_CONTAINER_DLL_remove (th->oh_head, th->oh_tail, ohh); 1649 GNUNET_CONTAINER_DLL_remove (th->oh_head,
1650 th->oh_tail,
1651 ohh);
1608 GNUNET_free (ohh->msg); 1652 GNUNET_free (ohh->msg);
1609 GNUNET_free (ohh); 1653 GNUNET_free (ohh);
1610} 1654}
@@ -1712,13 +1756,19 @@ GNUNET_TRANSPORT_get_hello_cancel (struct GNUNET_TRANSPORT_GetHelloHandle *ghh)
1712 */ 1756 */
1713struct GNUNET_TRANSPORT_Handle * 1757struct GNUNET_TRANSPORT_Handle *
1714GNUNET_TRANSPORT_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, 1758GNUNET_TRANSPORT_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
1715 const struct GNUNET_PeerIdentity *self, void *cls, 1759 const struct GNUNET_PeerIdentity *self,
1760 void *cls,
1716 GNUNET_TRANSPORT_ReceiveCallback rec, 1761 GNUNET_TRANSPORT_ReceiveCallback rec,
1717 GNUNET_TRANSPORT_NotifyConnect nc, 1762 GNUNET_TRANSPORT_NotifyConnect nc,
1718 GNUNET_TRANSPORT_NotifyDisconnect nd) 1763 GNUNET_TRANSPORT_NotifyDisconnect nd)
1719{ 1764{
1720 return GNUNET_TRANSPORT_connect2 (cfg, self, cls, 1765 return GNUNET_TRANSPORT_connect2 (cfg,
1721 rec, nc, nd, NULL); 1766 self,
1767 cls,
1768 rec,
1769 nc,
1770 nd,
1771 NULL);
1722} 1772}
1723 1773
1724 1774
@@ -1738,7 +1788,8 @@ GNUNET_TRANSPORT_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
1738 */ 1788 */
1739struct GNUNET_TRANSPORT_Handle * 1789struct GNUNET_TRANSPORT_Handle *
1740GNUNET_TRANSPORT_connect2 (const struct GNUNET_CONFIGURATION_Handle *cfg, 1790GNUNET_TRANSPORT_connect2 (const struct GNUNET_CONFIGURATION_Handle *cfg,
1741 const struct GNUNET_PeerIdentity *self, void *cls, 1791 const struct GNUNET_PeerIdentity *self,
1792 void *cls,
1742 GNUNET_TRANSPORT_ReceiveCallback rec, 1793 GNUNET_TRANSPORT_ReceiveCallback rec,
1743 GNUNET_TRANSPORT_NotifyConnect nc, 1794 GNUNET_TRANSPORT_NotifyConnect nc,
1744 GNUNET_TRANSPORT_NotifyDisconnect nd, 1795 GNUNET_TRANSPORT_NotifyDisconnect nd,
@@ -1761,7 +1812,8 @@ GNUNET_TRANSPORT_connect2 (const struct GNUNET_CONFIGURATION_Handle *cfg,
1761 ret->reconnect_delay = GNUNET_TIME_UNIT_ZERO; 1812 ret->reconnect_delay = GNUNET_TIME_UNIT_ZERO;
1762 LOG (GNUNET_ERROR_TYPE_DEBUG, 1813 LOG (GNUNET_ERROR_TYPE_DEBUG,
1763 "Connecting to transport service.\n"); 1814 "Connecting to transport service.\n");
1764 ret->client = GNUNET_CLIENT_connect ("transport", cfg); 1815 ret->client = GNUNET_CLIENT_connect ("transport",
1816 cfg);
1765 if (NULL == ret->client) 1817 if (NULL == ret->client)
1766 { 1818 {
1767 GNUNET_free (ret); 1819 GNUNET_free (ret);
@@ -1772,8 +1824,10 @@ GNUNET_TRANSPORT_connect2 (const struct GNUNET_CONFIGURATION_Handle *cfg,
1772 GNUNET_YES); 1824 GNUNET_YES);
1773 ret->ready_heap = 1825 ret->ready_heap =
1774 GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); 1826 GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN);
1775 schedule_control_transmit (ret, sizeof (struct StartMessage), 1827 schedule_control_transmit (ret,
1776 &send_start, ret); 1828 sizeof (struct StartMessage),
1829 &send_start,
1830 ret);
1777 return ret; 1831 return ret;
1778} 1832}
1779 1833
@@ -1869,15 +1923,19 @@ GNUNET_TRANSPORT_notify_transmit_ready (struct GNUNET_TRANSPORT_Handle *handle,
1869 th->notify_size = size; 1923 th->notify_size = size;
1870 n->th = th; 1924 n->th = th;
1871 /* calculate when our transmission should be ready */ 1925 /* calculate when our transmission should be ready */
1872 delay = GNUNET_BANDWIDTH_tracker_get_delay (&n->out_tracker, size + n->traffic_overhead); 1926 delay = GNUNET_BANDWIDTH_tracker_get_delay (&n->out_tracker,
1927 size + n->traffic_overhead);
1873 n->traffic_overhead = 0; 1928 n->traffic_overhead = 0;
1874 if (delay.rel_value_us > timeout.rel_value_us) 1929 if (delay.rel_value_us > timeout.rel_value_us)
1875 delay.rel_value_us = 0; /* notify immediately (with failure) */ 1930 delay.rel_value_us = 0; /* notify immediately (with failure) */
1876 LOG (GNUNET_ERROR_TYPE_DEBUG, 1931 LOG (GNUNET_ERROR_TYPE_DEBUG,
1877 "Bandwidth tracker allows next transmission to peer %s in %s\n", 1932 "Bandwidth tracker allows next transmission to peer %s in %s\n",
1878 GNUNET_i2s (target), 1933 GNUNET_i2s (target),
1879 GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES)); 1934 GNUNET_STRINGS_relative_time_to_string (delay,
1880 n->hn = GNUNET_CONTAINER_heap_insert (handle->ready_heap, n, delay.rel_value_us); 1935 GNUNET_YES));
1936 n->hn = GNUNET_CONTAINER_heap_insert (handle->ready_heap,
1937 n,
1938 delay.rel_value_us);
1881 schedule_transmission (handle); 1939 schedule_transmission (handle);
1882 return th; 1940 return th;
1883} 1941}
diff --git a/src/util/bandwidth.c b/src/util/bandwidth.c
index 4afaf4e4b..0270c85f2 100644
--- a/src/util/bandwidth.c
+++ b/src/util/bandwidth.c
@@ -216,7 +216,7 @@ update_excess (struct GNUNET_BANDWIDTH_Tracker *av)
216 * bytes). 216 * bytes).
217 * 217 *
218 * To stop notifications about updates and excess callbacks use 218 * To stop notifications about updates and excess callbacks use
219 * #GNUNET_BANDWIDTH_tracker_notification_stop 219 * #GNUNET_BANDWIDTH_tracker_notification_stop().
220 * 220 *
221 * @param av tracker to initialize 221 * @param av tracker to initialize
222 * @param update_cb callback to notify a client about the tracker being updated 222 * @param update_cb callback to notify a client about the tracker being updated