diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-07-07 06:27:10 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-07-07 06:27:10 +0000 |
commit | ac2de52a5de68f6f4f13b7aa01a481869fffc6aa (patch) | |
tree | 856c9f0b2f55f8cae99f3c7b3bf22beaecbf58da /src/core | |
parent | c1a3c11f8665432d9db6d549c28c0329668e66af (diff) | |
download | gnunet-ac2de52a5de68f6f4f13b7aa01a481869fffc6aa.tar.gz gnunet-ac2de52a5de68f6f4f13b7aa01a481869fffc6aa.zip |
hacks from trip
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/core.h | 58 | ||||
-rw-r--r-- | src/core/core_api.c | 32 | ||||
-rw-r--r-- | src/core/gnunet-service-core.c | 84 | ||||
-rw-r--r-- | src/core/test_core_api.c | 2 | ||||
-rw-r--r-- | src/core/test_core_api_reliability.c | 2 | ||||
-rw-r--r-- | src/core/test_core_api_start_only.c | 2 |
6 files changed, 152 insertions, 28 deletions
diff --git a/src/core/core.h b/src/core/core.h index 88e6b748c..021aa4184 100644 --- a/src/core/core.h +++ b/src/core/core.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | (C) 2009 Christian Grothoff (and other contributing authors) | 3 | (C) 2009, 2010 Christian Grothoff (and other contributing authors) |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -23,6 +23,7 @@ | |||
23 | * @brief common internal definitions for core service | 23 | * @brief common internal definitions for core service |
24 | * @author Christian Grothoff | 24 | * @author Christian Grothoff |
25 | */ | 25 | */ |
26 | #include "gnunet_bandwidth_lib.h" | ||
26 | #include "gnunet_crypto_lib.h" | 27 | #include "gnunet_crypto_lib.h" |
27 | #include "gnunet_time_lib.h" | 28 | #include "gnunet_time_lib.h" |
28 | 29 | ||
@@ -45,10 +46,11 @@ | |||
45 | #define GNUNET_CORE_OPTION_NOTHING 0 | 46 | #define GNUNET_CORE_OPTION_NOTHING 0 |
46 | #define GNUNET_CORE_OPTION_SEND_CONNECT 1 | 47 | #define GNUNET_CORE_OPTION_SEND_CONNECT 1 |
47 | #define GNUNET_CORE_OPTION_SEND_DISCONNECT 2 | 48 | #define GNUNET_CORE_OPTION_SEND_DISCONNECT 2 |
48 | #define GNUNET_CORE_OPTION_SEND_FULL_INBOUND 4 | 49 | #define GNUNET_CORE_OPTION_SEND_STATUS_CHANGE 4 |
49 | #define GNUNET_CORE_OPTION_SEND_HDR_INBOUND 8 | 50 | #define GNUNET_CORE_OPTION_SEND_FULL_INBOUND 8 |
50 | #define GNUNET_CORE_OPTION_SEND_FULL_OUTBOUND 16 | 51 | #define GNUNET_CORE_OPTION_SEND_HDR_INBOUND 16 |
51 | #define GNUNET_CORE_OPTION_SEND_HDR_OUTBOUND 32 | 52 | #define GNUNET_CORE_OPTION_SEND_FULL_OUTBOUND 32 |
53 | #define GNUNET_CORE_OPTION_SEND_HDR_OUTBOUND 64 | ||
52 | 54 | ||
53 | 55 | ||
54 | /** | 56 | /** |
@@ -100,13 +102,12 @@ struct InitReplyMessage | |||
100 | 102 | ||
101 | /** | 103 | /** |
102 | * Message sent by the service to clients to notify them | 104 | * Message sent by the service to clients to notify them |
103 | * about a peer connecting or disconnecting. | 105 | * about a peer connecting. |
104 | */ | 106 | */ |
105 | struct ConnectNotifyMessage | 107 | struct ConnectNotifyMessage |
106 | { | 108 | { |
107 | /** | 109 | /** |
108 | * Header with type GNUNET_MESSAGE_TYPE_CORE_NOTIFY_CONNECT | 110 | * Header with type GNUNET_MESSAGE_TYPE_CORE_NOTIFY_CONNECT |
109 | * or GNUNET_MESSAGE_TYPE_CORE_NOTIFY_DISCONNECT. | ||
110 | */ | 111 | */ |
111 | struct GNUNET_MessageHeader header; | 112 | struct GNUNET_MessageHeader header; |
112 | 113 | ||
@@ -128,6 +129,49 @@ struct ConnectNotifyMessage | |||
128 | }; | 129 | }; |
129 | 130 | ||
130 | 131 | ||
132 | /** | ||
133 | * Message sent by the service to clients to notify them | ||
134 | * about a peer changing status. | ||
135 | */ | ||
136 | struct PeerStatusNotifyMessage | ||
137 | { | ||
138 | /** | ||
139 | * Header with type GNUNET_MESSAGE_TYPE_CORE_NOTIFY_PEER_STATUS | ||
140 | */ | ||
141 | struct GNUNET_MessageHeader header; | ||
142 | |||
143 | /** | ||
144 | * Distance to the peer. | ||
145 | */ | ||
146 | uint32_t distance GNUNET_PACKED; | ||
147 | |||
148 | /** | ||
149 | * Currently observed latency. | ||
150 | */ | ||
151 | struct GNUNET_TIME_RelativeNBO latency; | ||
152 | |||
153 | /** | ||
154 | * When the peer would time out (unless we see activity) | ||
155 | */ | ||
156 | struct GNUNET_TIME_AbsoluteNBO timeout; | ||
157 | |||
158 | /** | ||
159 | * Available bandwidth from the peer. | ||
160 | */ | ||
161 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in; | ||
162 | |||
163 | /** | ||
164 | * Available bandwidth to the peer. | ||
165 | */ | ||
166 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out; | ||
167 | |||
168 | /** | ||
169 | * Identity of the peer. | ||
170 | */ | ||
171 | struct GNUNET_PeerIdentity peer; | ||
172 | |||
173 | }; | ||
174 | |||
131 | 175 | ||
132 | /** | 176 | /** |
133 | * Message sent by the service to clients to notify them | 177 | * Message sent by the service to clients to notify them |
diff --git a/src/core/core_api.c b/src/core/core_api.c index d13166c14..5f21d8478 100644 --- a/src/core/core_api.c +++ b/src/core/core_api.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | (C) 2009 Christian Grothoff (and other contributing authors) | 3 | (C) 2009, 2010 Christian Grothoff (and other contributing authors) |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -67,6 +67,11 @@ struct GNUNET_CORE_Handle | |||
67 | GNUNET_CORE_DisconnectEventHandler disconnects; | 67 | GNUNET_CORE_DisconnectEventHandler disconnects; |
68 | 68 | ||
69 | /** | 69 | /** |
70 | * Function to call whenever we're notified about a peer changing status. | ||
71 | */ | ||
72 | GNUNET_CORE_PeerStatusEventHandler status_events; | ||
73 | |||
74 | /** | ||
70 | * Function to call whenever we receive an inbound message. | 75 | * Function to call whenever we receive an inbound message. |
71 | */ | 76 | */ |
72 | GNUNET_CORE_MessageCallback inbound_notify; | 77 | GNUNET_CORE_MessageCallback inbound_notify; |
@@ -381,6 +386,7 @@ main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
381 | const struct DisconnectNotifyMessage *dnm; | 386 | const struct DisconnectNotifyMessage *dnm; |
382 | const struct NotifyTrafficMessage *ntm; | 387 | const struct NotifyTrafficMessage *ntm; |
383 | const struct GNUNET_MessageHeader *em; | 388 | const struct GNUNET_MessageHeader *em; |
389 | const struct PeerStatusNotifyMessage *psnm; | ||
384 | uint16_t msize; | 390 | uint16_t msize; |
385 | uint16_t et; | 391 | uint16_t et; |
386 | const struct GNUNET_CORE_MessageHandler *mh; | 392 | const struct GNUNET_CORE_MessageHandler *mh; |
@@ -433,6 +439,26 @@ main_notify_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
433 | h->disconnects (h->cls, | 439 | h->disconnects (h->cls, |
434 | &dnm->peer); | 440 | &dnm->peer); |
435 | break; | 441 | break; |
442 | case GNUNET_MESSAGE_TYPE_CORE_NOTIFY_STATUS_CHANGE: | ||
443 | if (NULL == h->status_events) | ||
444 | { | ||
445 | GNUNET_break (0); | ||
446 | break; | ||
447 | } | ||
448 | if (msize != sizeof (struct PeerStatusNotifyMessage)) | ||
449 | { | ||
450 | GNUNET_break (0); | ||
451 | break; | ||
452 | } | ||
453 | psnm = (const struct PeerStatusNotifyMessage *) msg; | ||
454 | h->status_events (h->cls, | ||
455 | &psnm->peer, | ||
456 | GNUNET_TIME_relative_ntoh (psnm->latency), | ||
457 | ntohl (psnm->distance), | ||
458 | psnm->bandwidth_in, | ||
459 | psnm->bandwidth_out, | ||
460 | GNUNET_TIME_absolute_ntoh (psnm->timeout)); | ||
461 | break; | ||
436 | case GNUNET_MESSAGE_TYPE_CORE_NOTIFY_INBOUND: | 462 | case GNUNET_MESSAGE_TYPE_CORE_NOTIFY_INBOUND: |
437 | if (msize < | 463 | if (msize < |
438 | sizeof (struct NotifyTrafficMessage) + | 464 | sizeof (struct NotifyTrafficMessage) + |
@@ -658,6 +684,8 @@ transmit_start (void *cls, size_t size, void *buf) | |||
658 | opt |= GNUNET_CORE_OPTION_SEND_CONNECT; | 684 | opt |= GNUNET_CORE_OPTION_SEND_CONNECT; |
659 | if (h->disconnects != NULL) | 685 | if (h->disconnects != NULL) |
660 | opt |= GNUNET_CORE_OPTION_SEND_DISCONNECT; | 686 | opt |= GNUNET_CORE_OPTION_SEND_DISCONNECT; |
687 | if (h->status_events != NULL) | ||
688 | opt |= GNUNET_CORE_OPTION_SEND_STATUS_CHANGE; | ||
661 | if (h->inbound_notify != NULL) | 689 | if (h->inbound_notify != NULL) |
662 | { | 690 | { |
663 | if (h->inbound_hdr_only) | 691 | if (h->inbound_hdr_only) |
@@ -717,6 +745,7 @@ GNUNET_CORE_connect (struct GNUNET_SCHEDULER_Handle *sched, | |||
717 | GNUNET_CORE_StartupCallback init, | 745 | GNUNET_CORE_StartupCallback init, |
718 | GNUNET_CORE_ConnectEventHandler connects, | 746 | GNUNET_CORE_ConnectEventHandler connects, |
719 | GNUNET_CORE_DisconnectEventHandler disconnects, | 747 | GNUNET_CORE_DisconnectEventHandler disconnects, |
748 | GNUNET_CORE_PeerStatusEventHandler status_events, | ||
720 | GNUNET_CORE_MessageCallback inbound_notify, | 749 | GNUNET_CORE_MessageCallback inbound_notify, |
721 | int inbound_hdr_only, | 750 | int inbound_hdr_only, |
722 | GNUNET_CORE_MessageCallback outbound_notify, | 751 | GNUNET_CORE_MessageCallback outbound_notify, |
@@ -732,6 +761,7 @@ GNUNET_CORE_connect (struct GNUNET_SCHEDULER_Handle *sched, | |||
732 | h->init = init; | 761 | h->init = init; |
733 | h->connects = connects; | 762 | h->connects = connects; |
734 | h->disconnects = disconnects; | 763 | h->disconnects = disconnects; |
764 | h->status_events = status_events; | ||
735 | h->inbound_notify = inbound_notify; | 765 | h->inbound_notify = inbound_notify; |
736 | h->outbound_notify = outbound_notify; | 766 | h->outbound_notify = outbound_notify; |
737 | h->inbound_hdr_only = inbound_hdr_only; | 767 | h->inbound_hdr_only = inbound_hdr_only; |
diff --git a/src/core/gnunet-service-core.c b/src/core/gnunet-service-core.c index 4e5177ca3..8cd598e83 100644 --- a/src/core/gnunet-service-core.c +++ b/src/core/gnunet-service-core.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | (C) 2009 Christian Grothoff (and other contributing authors) | 3 | (C) 2009, 2010 Christian Grothoff (and other contributing authors) |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -830,6 +830,43 @@ send_to_all_clients (const struct GNUNET_MessageHeader *msg, | |||
830 | 830 | ||
831 | 831 | ||
832 | /** | 832 | /** |
833 | * Function called by transport telling us that a peer | ||
834 | * changed status. | ||
835 | * | ||
836 | * @param peer the peer that changed status | ||
837 | */ | ||
838 | static void | ||
839 | handle_peer_status_change (struct Neighbour *n) | ||
840 | { | ||
841 | struct PeerStatusNotifyMessage psnm; | ||
842 | |||
843 | if (! n->is_connected) | ||
844 | return; | ||
845 | #if DEBUG_CORE | ||
846 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
847 | "Peer `%4s' changed status\n", | ||
848 | GNUNET_i2s (peer)); | ||
849 | #endif | ||
850 | psnm.header.size = htons (sizeof (struct PeerStatusNotifyMessage)); | ||
851 | psnm.header.type = htons (GNUNET_MESSAGE_TYPE_CORE_NOTIFY_STATUS_CHANGE); | ||
852 | psnm.distance = htonl (n->last_distance); | ||
853 | psnm.latency = GNUNET_TIME_relative_hton (n->last_latency); | ||
854 | psnm.timeout = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_add (n->last_activity, | ||
855 | GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT)); | ||
856 | psnm.bandwidth_in = n->bw_in; | ||
857 | psnm.bandwidth_out = n->bw_out; | ||
858 | psnm.peer = n->peer; | ||
859 | send_to_all_clients (&psnm.header, | ||
860 | GNUNET_YES, | ||
861 | GNUNET_CORE_OPTION_SEND_STATUS_CHANGE); | ||
862 | GNUNET_STATISTICS_update (stats, | ||
863 | gettext_noop ("# peer status changes"), | ||
864 | 1, | ||
865 | GNUNET_NO); | ||
866 | } | ||
867 | |||
868 | |||
869 | /** | ||
833 | * Handle CORE_INIT request. | 870 | * Handle CORE_INIT request. |
834 | */ | 871 | */ |
835 | static void | 872 | static void |
@@ -997,16 +1034,21 @@ handle_client_request_info (void *cls, | |||
997 | if (n->bw_out_internal_limit.value__ != rcm->limit_outbound.value__) | 1034 | if (n->bw_out_internal_limit.value__ != rcm->limit_outbound.value__) |
998 | { | 1035 | { |
999 | n->bw_out_internal_limit = rcm->limit_outbound; | 1036 | n->bw_out_internal_limit = rcm->limit_outbound; |
1000 | n->bw_out = GNUNET_BANDWIDTH_value_min (n->bw_out_internal_limit, | 1037 | if (n->bw_out.value__ != GNUNET_BANDWIDTH_value_min (n->bw_out_internal_limit, |
1001 | n->bw_out_external_limit); | 1038 | n->bw_out_external_limit).value__) |
1002 | GNUNET_BANDWIDTH_tracker_update_quota (&n->available_recv_window, | 1039 | { |
1003 | n->bw_out); | 1040 | n->bw_out = GNUNET_BANDWIDTH_value_min (n->bw_out_internal_limit, |
1004 | GNUNET_TRANSPORT_set_quota (transport, | 1041 | n->bw_out_external_limit); |
1005 | &n->peer, | 1042 | GNUNET_BANDWIDTH_tracker_update_quota (&n->available_recv_window, |
1006 | n->bw_in, | 1043 | n->bw_out); |
1007 | n->bw_out, | 1044 | GNUNET_TRANSPORT_set_quota (transport, |
1008 | GNUNET_TIME_UNIT_FOREVER_REL, | 1045 | &n->peer, |
1009 | NULL, NULL); | 1046 | n->bw_in, |
1047 | n->bw_out, | ||
1048 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
1049 | NULL, NULL); | ||
1050 | handle_peer_status_change (n); | ||
1051 | } | ||
1010 | } | 1052 | } |
1011 | if (want_reserv < 0) | 1053 | if (want_reserv < 0) |
1012 | { | 1054 | { |
@@ -2359,13 +2401,11 @@ handle_client_request_connect (void *cls, | |||
2359 | * @param cls the 'struct Neighbour' to retry sending the key for | 2401 | * @param cls the 'struct Neighbour' to retry sending the key for |
2360 | * @param peer the peer for which this is the HELLO | 2402 | * @param peer the peer for which this is the HELLO |
2361 | * @param hello HELLO message of that peer | 2403 | * @param hello HELLO message of that peer |
2362 | * @param trust amount of trust we currently have in that peer | ||
2363 | */ | 2404 | */ |
2364 | static void | 2405 | static void |
2365 | process_hello_retry_send_key (void *cls, | 2406 | process_hello_retry_send_key (void *cls, |
2366 | const struct GNUNET_PeerIdentity *peer, | 2407 | const struct GNUNET_PeerIdentity *peer, |
2367 | const struct GNUNET_HELLO_Message *hello, | 2408 | const struct GNUNET_HELLO_Message *hello) |
2368 | uint32_t trust) | ||
2369 | { | 2409 | { |
2370 | struct Neighbour *n = cls; | 2410 | struct Neighbour *n = cls; |
2371 | 2411 | ||
@@ -2516,7 +2556,6 @@ send_key (struct Neighbour *n) | |||
2516 | GNUNET_assert (n->pitr == NULL); | 2556 | GNUNET_assert (n->pitr == NULL); |
2517 | n->pitr = GNUNET_PEERINFO_iterate (peerinfo, | 2557 | n->pitr = GNUNET_PEERINFO_iterate (peerinfo, |
2518 | &n->peer, | 2558 | &n->peer, |
2519 | 0, | ||
2520 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 20), | 2559 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 20), |
2521 | &process_hello_retry_send_key, n); | 2560 | &process_hello_retry_send_key, n); |
2522 | return; | 2561 | return; |
@@ -2666,13 +2705,11 @@ handle_set_key (struct Neighbour *n, | |||
2666 | * @param cls pointer to the set key message | 2705 | * @param cls pointer to the set key message |
2667 | * @param peer the peer for which this is the HELLO | 2706 | * @param peer the peer for which this is the HELLO |
2668 | * @param hello HELLO message of that peer | 2707 | * @param hello HELLO message of that peer |
2669 | * @param trust amount of trust we currently have in that peer | ||
2670 | */ | 2708 | */ |
2671 | static void | 2709 | static void |
2672 | process_hello_retry_handle_set_key (void *cls, | 2710 | process_hello_retry_handle_set_key (void *cls, |
2673 | const struct GNUNET_PeerIdentity *peer, | 2711 | const struct GNUNET_PeerIdentity *peer, |
2674 | const struct GNUNET_HELLO_Message *hello, | 2712 | const struct GNUNET_HELLO_Message *hello) |
2675 | uint32_t trust) | ||
2676 | { | 2713 | { |
2677 | struct Neighbour *n = cls; | 2714 | struct Neighbour *n = cls; |
2678 | struct SetKeyMessage *sm = n->skm; | 2715 | struct SetKeyMessage *sm = n->skm; |
@@ -2922,6 +2959,7 @@ handle_pong (struct Neighbour *n, | |||
2922 | GNUNET_TIME_relative_divide (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, 2), | 2959 | GNUNET_TIME_relative_divide (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, 2), |
2923 | &send_keep_alive, | 2960 | &send_keep_alive, |
2924 | n); | 2961 | n); |
2962 | handle_peer_status_change (n); | ||
2925 | break; | 2963 | break; |
2926 | default: | 2964 | default: |
2927 | GNUNET_break (0); | 2965 | GNUNET_break (0); |
@@ -2974,7 +3012,6 @@ handle_set_key (struct Neighbour *n, const struct SetKeyMessage *m) | |||
2974 | n->skm = m_cpy; | 3012 | n->skm = m_cpy; |
2975 | n->pitr = GNUNET_PEERINFO_iterate (peerinfo, | 3013 | n->pitr = GNUNET_PEERINFO_iterate (peerinfo, |
2976 | &n->peer, | 3014 | &n->peer, |
2977 | 0, | ||
2978 | GNUNET_TIME_UNIT_MINUTES, | 3015 | GNUNET_TIME_UNIT_MINUTES, |
2979 | &process_hello_retry_handle_set_key, n); | 3016 | &process_hello_retry_handle_set_key, n); |
2980 | GNUNET_STATISTICS_update (stats, | 3017 | GNUNET_STATISTICS_update (stats, |
@@ -3364,7 +3401,8 @@ handle_encrypted_message (struct Neighbour *n, | |||
3364 | GNUNET_STATISTICS_set (stats, | 3401 | GNUNET_STATISTICS_set (stats, |
3365 | gettext_noop ("# bytes of payload decrypted"), | 3402 | gettext_noop ("# bytes of payload decrypted"), |
3366 | size - sizeof (struct EncryptedMessage), | 3403 | size - sizeof (struct EncryptedMessage), |
3367 | GNUNET_NO); | 3404 | GNUNET_NO); |
3405 | handle_peer_status_change (n); | ||
3368 | if (GNUNET_OK != GNUNET_SERVER_mst_receive (mst, | 3406 | if (GNUNET_OK != GNUNET_SERVER_mst_receive (mst, |
3369 | n, | 3407 | n, |
3370 | &buf[sizeof (struct EncryptedMessage)], | 3408 | &buf[sizeof (struct EncryptedMessage)], |
@@ -3396,6 +3434,7 @@ handle_transport_receive (void *cls, | |||
3396 | int up; | 3434 | int up; |
3397 | uint16_t type; | 3435 | uint16_t type; |
3398 | uint16_t size; | 3436 | uint16_t size; |
3437 | int changed; | ||
3399 | 3438 | ||
3400 | #if DEBUG_CORE | 3439 | #if DEBUG_CORE |
3401 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3440 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -3411,6 +3450,7 @@ handle_transport_receive (void *cls, | |||
3411 | n = find_neighbour (peer); | 3450 | n = find_neighbour (peer); |
3412 | if (n == NULL) | 3451 | if (n == NULL) |
3413 | n = create_neighbour (peer); | 3452 | n = create_neighbour (peer); |
3453 | changed = (latency.value != n->last_latency.value) || (distance != n->last_distance); | ||
3414 | n->last_latency = latency; | 3454 | n->last_latency = latency; |
3415 | n->last_distance = distance; | 3455 | n->last_distance = distance; |
3416 | up = (n->status == PEER_STATE_KEY_CONFIRMED); | 3456 | up = (n->status == PEER_STATE_KEY_CONFIRMED); |
@@ -3496,6 +3536,7 @@ handle_transport_receive (void *cls, | |||
3496 | { | 3536 | { |
3497 | now = GNUNET_TIME_absolute_get (); | 3537 | now = GNUNET_TIME_absolute_get (); |
3498 | n->last_activity = now; | 3538 | n->last_activity = now; |
3539 | changed = GNUNET_YES; | ||
3499 | if (!up) | 3540 | if (!up) |
3500 | { | 3541 | { |
3501 | GNUNET_STATISTICS_update (stats, gettext_noop ("# established sessions"), 1, GNUNET_NO); | 3542 | GNUNET_STATISTICS_update (stats, gettext_noop ("# established sessions"), 1, GNUNET_NO); |
@@ -3509,6 +3550,8 @@ handle_transport_receive (void *cls, | |||
3509 | &send_keep_alive, | 3550 | &send_keep_alive, |
3510 | n); | 3551 | n); |
3511 | } | 3552 | } |
3553 | if (changed) | ||
3554 | handle_peer_status_change (n); | ||
3512 | } | 3555 | } |
3513 | 3556 | ||
3514 | 3557 | ||
@@ -3591,6 +3634,7 @@ neighbour_quota_update (void *cls, | |||
3591 | n->bw_out, | 3634 | n->bw_out, |
3592 | GNUNET_TIME_UNIT_FOREVER_REL, | 3635 | GNUNET_TIME_UNIT_FOREVER_REL, |
3593 | NULL, NULL); | 3636 | NULL, NULL); |
3637 | handle_peer_status_change (n); | ||
3594 | } | 3638 | } |
3595 | schedule_quota_update (n); | 3639 | schedule_quota_update (n); |
3596 | } | 3640 | } |
diff --git a/src/core/test_core_api.c b/src/core/test_core_api.c index c488a5153..ad82d0a1d 100644 --- a/src/core/test_core_api.c +++ b/src/core/test_core_api.c | |||
@@ -228,6 +228,7 @@ init_notify (void *cls, | |||
228 | &init_notify, | 228 | &init_notify, |
229 | &connect_notify, | 229 | &connect_notify, |
230 | &disconnect_notify, | 230 | &disconnect_notify, |
231 | NULL, | ||
231 | &inbound_notify, | 232 | &inbound_notify, |
232 | GNUNET_YES, | 233 | GNUNET_YES, |
233 | &outbound_notify, GNUNET_YES, handlers); | 234 | &outbound_notify, GNUNET_YES, handlers); |
@@ -321,6 +322,7 @@ run (void *cls, | |||
321 | &init_notify, | 322 | &init_notify, |
322 | &connect_notify, | 323 | &connect_notify, |
323 | &disconnect_notify, | 324 | &disconnect_notify, |
325 | NULL, | ||
324 | &inbound_notify, | 326 | &inbound_notify, |
325 | GNUNET_YES, &outbound_notify, GNUNET_YES, handlers); | 327 | GNUNET_YES, &outbound_notify, GNUNET_YES, handlers); |
326 | } | 328 | } |
diff --git a/src/core/test_core_api_reliability.c b/src/core/test_core_api_reliability.c index 6d3ae04dc..c2375620a 100644 --- a/src/core/test_core_api_reliability.c +++ b/src/core/test_core_api_reliability.c | |||
@@ -375,6 +375,7 @@ init_notify (void *cls, | |||
375 | &init_notify, | 375 | &init_notify, |
376 | &connect_notify, | 376 | &connect_notify, |
377 | &disconnect_notify, | 377 | &disconnect_notify, |
378 | NULL, | ||
378 | &inbound_notify, | 379 | &inbound_notify, |
379 | GNUNET_YES, | 380 | GNUNET_YES, |
380 | &outbound_notify, GNUNET_YES, handlers); | 381 | &outbound_notify, GNUNET_YES, handlers); |
@@ -468,6 +469,7 @@ run (void *cls, | |||
468 | &init_notify, | 469 | &init_notify, |
469 | &connect_notify, | 470 | &connect_notify, |
470 | &disconnect_notify, | 471 | &disconnect_notify, |
472 | NULL, | ||
471 | &inbound_notify, | 473 | &inbound_notify, |
472 | GNUNET_YES, &outbound_notify, GNUNET_YES, handlers); | 474 | GNUNET_YES, &outbound_notify, GNUNET_YES, handlers); |
473 | } | 475 | } |
diff --git a/src/core/test_core_api_start_only.c b/src/core/test_core_api_start_only.c index 4195bdc58..4155bf5d4 100644 --- a/src/core/test_core_api_start_only.c +++ b/src/core/test_core_api_start_only.c | |||
@@ -133,6 +133,7 @@ init_notify (void *cls, | |||
133 | &init_notify, | 133 | &init_notify, |
134 | &connect_notify, | 134 | &connect_notify, |
135 | &disconnect_notify, | 135 | &disconnect_notify, |
136 | NULL, | ||
136 | &inbound_notify, | 137 | &inbound_notify, |
137 | GNUNET_YES, | 138 | GNUNET_YES, |
138 | &outbound_notify, GNUNET_YES, handlers); | 139 | &outbound_notify, GNUNET_YES, handlers); |
@@ -182,6 +183,7 @@ run (void *cls, | |||
182 | &init_notify, | 183 | &init_notify, |
183 | &connect_notify, | 184 | &connect_notify, |
184 | &disconnect_notify, | 185 | &disconnect_notify, |
186 | NULL, | ||
185 | &inbound_notify, | 187 | &inbound_notify, |
186 | GNUNET_YES, &outbound_notify, GNUNET_YES, handlers); | 188 | GNUNET_YES, &outbound_notify, GNUNET_YES, handlers); |
187 | } | 189 | } |