diff options
Diffstat (limited to 'src/core/gnunet-service-core.c')
-rw-r--r-- | src/core/gnunet-service-core.c | 223 |
1 files changed, 186 insertions, 37 deletions
diff --git a/src/core/gnunet-service-core.c b/src/core/gnunet-service-core.c index 5996a81bf..0d714be3f 100644 --- a/src/core/gnunet-service-core.c +++ b/src/core/gnunet-service-core.c | |||
@@ -25,11 +25,7 @@ | |||
25 | * | 25 | * |
26 | * POST-TESTING: | 26 | * POST-TESTING: |
27 | * - revisit API (which arguments are used, needed)? | 27 | * - revisit API (which arguments are used, needed)? |
28 | * - add code to re-transmit key if first attempt failed | 28 | * - add code to send PINGs if we are about to time-out otherwise (?) |
29 | * + timeout on connect / key exchange, etc. | ||
30 | * + timeout for automatic re-try, etc. | ||
31 | * - add code to give up re-transmission of key if many attempts fail | ||
32 | * - add code to send PINGs if we are about to time-out otherwise | ||
33 | * ? add heuristic to do another send_key in "handle_set_key" | 29 | * ? add heuristic to do another send_key in "handle_set_key" |
34 | * in case previous attempt failed / didn't work / persist | 30 | * in case previous attempt failed / didn't work / persist |
35 | * (but don't do it always to avoid storm of SET_KEY's going | 31 | * (but don't do it always to avoid storm of SET_KEY's going |
@@ -47,6 +43,7 @@ | |||
47 | * could ideally be changed to O(1) hash map lookups) | 43 | * could ideally be changed to O(1) hash map lookups) |
48 | */ | 44 | */ |
49 | #include "platform.h" | 45 | #include "platform.h" |
46 | #include "gnunet_constants.h" | ||
50 | #include "gnunet_util_lib.h" | 47 | #include "gnunet_util_lib.h" |
51 | #include "gnunet_hello_lib.h" | 48 | #include "gnunet_hello_lib.h" |
52 | #include "gnunet_peerinfo_service.h" | 49 | #include "gnunet_peerinfo_service.h" |
@@ -63,14 +60,18 @@ | |||
63 | */ | 60 | */ |
64 | #define MAX_WINDOW_TIME (5 * 60 * 1000) | 61 | #define MAX_WINDOW_TIME (5 * 60 * 1000) |
65 | 62 | ||
66 | |||
67 | /** | 63 | /** |
68 | * Amount of bytes per minute (in/out) to assume initially | 64 | * Minimum of bytes per minute (out) to assign to any connected peer. |
69 | * (before either peer has communicated any particular | 65 | * Should be rather low; values larger than DEFAULT_BPM_IN_OUT make no |
70 | * preference). Should be rather low. | 66 | * sense. |
71 | */ | 67 | */ |
72 | #define DEFAULT_BPM_IN_OUT 2048 | 68 | #define MIN_BPM_PER_PEER GNUNET_CONSTANTS_DEFAULT_BPM_IN_OUT |
73 | 69 | ||
70 | /** | ||
71 | * What is the smallest change (in number of bytes per minute) | ||
72 | * that we consider significant enough to bother triggering? | ||
73 | */ | ||
74 | #define MIN_BPM_CHANGE 32 | ||
74 | 75 | ||
75 | /** | 76 | /** |
76 | * After how much time past the "official" expiration time do | 77 | * After how much time past the "official" expiration time do |
@@ -81,61 +82,56 @@ | |||
81 | */ | 82 | */ |
82 | #define PAST_EXPIRATION_DISCARD_TIME GNUNET_TIME_UNIT_SECONDS | 83 | #define PAST_EXPIRATION_DISCARD_TIME GNUNET_TIME_UNIT_SECONDS |
83 | 84 | ||
84 | |||
85 | /** | 85 | /** |
86 | * What is the maximum delay for a SET_KEY message? | 86 | * What is the maximum delay for a SET_KEY message? |
87 | */ | 87 | */ |
88 | #define MAX_SET_KEY_DELAY GNUNET_TIME_UNIT_SECONDS | 88 | #define MAX_SET_KEY_DELAY GNUNET_TIME_UNIT_SECONDS |
89 | 89 | ||
90 | |||
91 | /** | 90 | /** |
92 | * What how long do we wait for SET_KEY confirmation initially? | 91 | * What how long do we wait for SET_KEY confirmation initially? |
93 | */ | 92 | */ |
94 | #define INITIAL_SET_KEY_RETRY_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 3) | 93 | #define INITIAL_SET_KEY_RETRY_FREQUENCY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 3) |
95 | 94 | ||
96 | |||
97 | /** | 95 | /** |
98 | * What is the maximum delay for a PING message? | 96 | * What is the maximum delay for a PING message? |
99 | */ | 97 | */ |
100 | #define MAX_PING_DELAY GNUNET_TIME_UNIT_SECONDS | 98 | #define MAX_PING_DELAY GNUNET_TIME_UNIT_SECONDS |
101 | 99 | ||
102 | |||
103 | /** | 100 | /** |
104 | * What is the maximum delay for a PONG message? | 101 | * What is the maximum delay for a PONG message? |
105 | */ | 102 | */ |
106 | #define MAX_PONG_DELAY GNUNET_TIME_UNIT_SECONDS | 103 | #define MAX_PONG_DELAY GNUNET_TIME_UNIT_SECONDS |
107 | 104 | ||
105 | /** | ||
106 | * How often do we recalculate bandwidth quotas? | ||
107 | */ | ||
108 | #define QUOTA_UPDATE_FREQUENCY GNUNET_TIME_UNIT_SECONDS | ||
108 | 109 | ||
109 | /** | 110 | /** |
110 | * What is the priority for a SET_KEY message? | 111 | * What is the priority for a SET_KEY message? |
111 | */ | 112 | */ |
112 | #define SET_KEY_PRIORITY 0xFFFFFF | 113 | #define SET_KEY_PRIORITY 0xFFFFFF |
113 | 114 | ||
114 | |||
115 | /** | 115 | /** |
116 | * What is the priority for a PING message? | 116 | * What is the priority for a PING message? |
117 | */ | 117 | */ |
118 | #define PING_PRIORITY 0xFFFFFF | 118 | #define PING_PRIORITY 0xFFFFFF |
119 | 119 | ||
120 | |||
121 | /** | 120 | /** |
122 | * What is the priority for a PONG message? | 121 | * What is the priority for a PONG message? |
123 | */ | 122 | */ |
124 | #define PONG_PRIORITY 0xFFFFFF | 123 | #define PONG_PRIORITY 0xFFFFFF |
125 | 124 | ||
126 | |||
127 | /** | 125 | /** |
128 | * How many messages do we queue per peer at most? | 126 | * How many messages do we queue per peer at most? |
129 | */ | 127 | */ |
130 | #define MAX_PEER_QUEUE_SIZE 16 | 128 | #define MAX_PEER_QUEUE_SIZE 16 |
131 | 129 | ||
132 | |||
133 | /** | 130 | /** |
134 | * How many non-mandatory messages do we queue per client at most? | 131 | * How many non-mandatory messages do we queue per client at most? |
135 | */ | 132 | */ |
136 | #define MAX_CLIENT_QUEUE_SIZE 32 | 133 | #define MAX_CLIENT_QUEUE_SIZE 32 |
137 | 134 | ||
138 | |||
139 | /** | 135 | /** |
140 | * What is the maximum age of a message for us to consider | 136 | * What is the maximum age of a message for us to consider |
141 | * processing it? Note that this looks at the timestamp used | 137 | * processing it? Note that this looks at the timestamp used |
@@ -146,7 +142,6 @@ | |||
146 | */ | 142 | */ |
147 | #define MAX_MESSAGE_AGE GNUNET_TIME_UNIT_DAYS | 143 | #define MAX_MESSAGE_AGE GNUNET_TIME_UNIT_DAYS |
148 | 144 | ||
149 | |||
150 | /** | 145 | /** |
151 | * What is the maximum size for encrypted messages? Note that this | 146 | * What is the maximum size for encrypted messages? Note that this |
152 | * number imposes a clear limit on the maximum size of any message. | 147 | * number imposes a clear limit on the maximum size of any message. |
@@ -179,6 +174,7 @@ enum PeerStateMachine | |||
179 | */ | 174 | */ |
180 | #define ENCRYPTED_HEADER_SIZE (sizeof(struct GNUNET_MessageHeader) + sizeof(uint32_t) + sizeof(GNUNET_HashCode)) | 175 | #define ENCRYPTED_HEADER_SIZE (sizeof(struct GNUNET_MessageHeader) + sizeof(uint32_t) + sizeof(GNUNET_HashCode)) |
181 | 176 | ||
177 | |||
182 | /** | 178 | /** |
183 | * Encapsulation for encrypted messages exchanged between | 179 | * Encapsulation for encrypted messages exchanged between |
184 | * peers. Followed by the actual encrypted data. | 180 | * peers. Followed by the actual encrypted data. |
@@ -403,6 +399,11 @@ struct Neighbour | |||
403 | GNUNET_SCHEDULER_TaskIdentifier retry_set_key_task; | 399 | GNUNET_SCHEDULER_TaskIdentifier retry_set_key_task; |
404 | 400 | ||
405 | /** | 401 | /** |
402 | * ID of task used for updating bandwidth quota for this neighbour. | ||
403 | */ | ||
404 | GNUNET_SCHEDULER_TaskIdentifier quota_update_task; | ||
405 | |||
406 | /** | ||
406 | * At what time did we generate our encryption key? | 407 | * At what time did we generate our encryption key? |
407 | */ | 408 | */ |
408 | struct GNUNET_TIME_Absolute encrypt_key_created; | 409 | struct GNUNET_TIME_Absolute encrypt_key_created; |
@@ -430,7 +431,7 @@ struct Neighbour | |||
430 | struct GNUNET_TIME_Relative last_latency; | 431 | struct GNUNET_TIME_Relative last_latency; |
431 | 432 | ||
432 | /** | 433 | /** |
433 | * At what frequency are we currently re-trying SET KEY messages? | 434 | * At what frequency are we currently re-trying SET_KEY messages? |
434 | */ | 435 | */ |
435 | struct GNUNET_TIME_Relative set_key_retry_frequency; | 436 | struct GNUNET_TIME_Relative set_key_retry_frequency; |
436 | 437 | ||
@@ -465,7 +466,7 @@ struct Neighbour | |||
465 | /** | 466 | /** |
466 | * How valueable were the messages of this peer recently? | 467 | * How valueable were the messages of this peer recently? |
467 | */ | 468 | */ |
468 | double current_preference; | 469 | unsigned long long current_preference; |
469 | 470 | ||
470 | /** | 471 | /** |
471 | * Bit map indicating which of the 32 sequence numbers before the last | 472 | * Bit map indicating which of the 32 sequence numbers before the last |
@@ -501,7 +502,7 @@ struct Neighbour | |||
501 | 502 | ||
502 | /** | 503 | /** |
503 | * Internal bandwidth limit set for this peer (initially | 504 | * Internal bandwidth limit set for this peer (initially |
504 | * typcially set to "-1"). "bpm_out" is MAX of | 505 | * typically set to "-1"). "bpm_out" is MAX of |
505 | * "bpm_out_internal_limit" and "bpm_out_external_limit". | 506 | * "bpm_out_internal_limit" and "bpm_out_external_limit". |
506 | */ | 507 | */ |
507 | uint32_t bpm_out_internal_limit; | 508 | uint32_t bpm_out_internal_limit; |
@@ -641,14 +642,63 @@ static struct GNUNET_SERVER_Handle *server; | |||
641 | static struct GNUNET_TRANSPORT_Handle *transport; | 642 | static struct GNUNET_TRANSPORT_Handle *transport; |
642 | 643 | ||
643 | /** | 644 | /** |
645 | * Linked list of our clients. | ||
646 | */ | ||
647 | static struct Client *clients; | ||
648 | |||
649 | /** | ||
644 | * We keep neighbours in a linked list (for now). | 650 | * We keep neighbours in a linked list (for now). |
645 | */ | 651 | */ |
646 | static struct Neighbour *neighbours; | 652 | static struct Neighbour *neighbours; |
647 | 653 | ||
648 | /** | 654 | /** |
649 | * Linked list of our clients. | 655 | * Sum of all preferences among all neighbours. |
650 | */ | 656 | */ |
651 | static struct Client *clients; | 657 | static unsigned long long preference_sum; |
658 | |||
659 | /** | ||
660 | * Total number of neighbours we have. | ||
661 | */ | ||
662 | static unsigned int neighbour_count; | ||
663 | |||
664 | /** | ||
665 | * How much inbound bandwidth are we supposed to be using? | ||
666 | */ | ||
667 | static unsigned long long bandwidth_target_in; | ||
668 | |||
669 | /** | ||
670 | * How much outbound bandwidth are we supposed to be using? | ||
671 | */ | ||
672 | static unsigned long long bandwidth_target_out; | ||
673 | |||
674 | |||
675 | |||
676 | /** | ||
677 | * A preference value for a neighbour was update. Update | ||
678 | * the preference sum accordingly. | ||
679 | * | ||
680 | * @param inc how much was a preference value increased? | ||
681 | */ | ||
682 | static void | ||
683 | update_preference_sum (unsigned long long inc) | ||
684 | { | ||
685 | struct Neighbour *n; | ||
686 | unsigned long long os; | ||
687 | |||
688 | os = preference_sum; | ||
689 | preference_sum += inc; | ||
690 | if (preference_sum >= os) | ||
691 | return; /* done! */ | ||
692 | /* overflow! compensate by cutting all values in half! */ | ||
693 | preference_sum = 0; | ||
694 | n = neighbours; | ||
695 | while (n != NULL) | ||
696 | { | ||
697 | n->current_preference /= 2; | ||
698 | preference_sum += n->current_preference; | ||
699 | n = n->next; | ||
700 | } | ||
701 | } | ||
652 | 702 | ||
653 | 703 | ||
654 | /** | 704 | /** |
@@ -1010,6 +1060,7 @@ handle_client_request_configure (void *cls, | |||
1010 | struct ConfigurationInfoMessage cim; | 1060 | struct ConfigurationInfoMessage cim; |
1011 | struct Client *c; | 1061 | struct Client *c; |
1012 | int reserv; | 1062 | int reserv; |
1063 | unsigned long long old_preference; | ||
1013 | 1064 | ||
1014 | #if DEBUG_CORE_CLIENT | 1065 | #if DEBUG_CORE_CLIENT |
1015 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1066 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -1036,9 +1087,14 @@ handle_client_request_configure (void *cls, | |||
1036 | reserv = n->available_recv_window; | 1087 | reserv = n->available_recv_window; |
1037 | n->available_recv_window -= reserv; | 1088 | n->available_recv_window -= reserv; |
1038 | } | 1089 | } |
1039 | n->current_preference += rcm->preference_change; | 1090 | old_preference = n->current_preference; |
1040 | if (n->current_preference < 0) | 1091 | n->current_preference += GNUNET_ntohll(rcm->preference_change); |
1041 | n->current_preference = 0; | 1092 | if (old_preference > n->current_preference) |
1093 | { | ||
1094 | /* overflow; cap at maximum value */ | ||
1095 | n->current_preference = (unsigned long long) -1; | ||
1096 | } | ||
1097 | update_preference_sum (n->current_preference - old_preference); | ||
1042 | cim.reserved_amount = htonl (reserv); | 1098 | cim.reserved_amount = htonl (reserv); |
1043 | cim.bpm_in = htonl (n->bpm_in); | 1099 | cim.bpm_in = htonl (n->bpm_in); |
1044 | cim.bpm_out = htonl (n->bpm_out); | 1100 | cim.bpm_out = htonl (n->bpm_out); |
@@ -2800,6 +2856,87 @@ handle_transport_receive (void *cls, | |||
2800 | 2856 | ||
2801 | 2857 | ||
2802 | /** | 2858 | /** |
2859 | * Function that recalculates the bandwidth quota for the | ||
2860 | * given neighbour and transmits it to the transport service. | ||
2861 | * | ||
2862 | * @param cls neighbour for the quota update | ||
2863 | * @param tc context | ||
2864 | */ | ||
2865 | static void | ||
2866 | neighbour_quota_update (void *cls, | ||
2867 | const struct GNUNET_SCHEDULER_TaskContext *tc); | ||
2868 | |||
2869 | |||
2870 | /** | ||
2871 | * Schedule the task that will recalculate the bandwidth | ||
2872 | * quota for this peer (and possibly force a disconnect of | ||
2873 | * idle peers by calculating a bandwidth of zero). | ||
2874 | */ | ||
2875 | static void | ||
2876 | schedule_quota_update (struct Neighbour *n) | ||
2877 | { | ||
2878 | GNUNET_assert (n->quota_update_task == | ||
2879 | GNUNET_SCHEDULER_NO_PREREQUISITE_TASK); | ||
2880 | n->quota_update_task | ||
2881 | = GNUNET_SCHEDULER_add_delayed (sched, | ||
2882 | GNUNET_NO, | ||
2883 | GNUNET_SCHEDULER_PRIORITY_IDLE, | ||
2884 | GNUNET_SCHEDULER_NO_PREREQUISITE_TASK, | ||
2885 | QUOTA_UPDATE_FREQUENCY, | ||
2886 | &neighbour_quota_update, | ||
2887 | n); | ||
2888 | } | ||
2889 | |||
2890 | |||
2891 | /** | ||
2892 | * Function that recalculates the bandwidth quota for the | ||
2893 | * given neighbour and transmits it to the transport service. | ||
2894 | * | ||
2895 | * @param cls neighbour for the quota update | ||
2896 | * @param tc context | ||
2897 | */ | ||
2898 | static void | ||
2899 | neighbour_quota_update (void *cls, | ||
2900 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
2901 | { | ||
2902 | struct Neighbour *n = cls; | ||
2903 | uint32_t q_in; | ||
2904 | double pref_rel; | ||
2905 | double share; | ||
2906 | unsigned long long distributable; | ||
2907 | |||
2908 | n->quota_update_task = GNUNET_SCHEDULER_NO_PREREQUISITE_TASK; | ||
2909 | /* calculate relative preference among all neighbours; | ||
2910 | divides by a bit more to avoid division by zero AND to | ||
2911 | account for possibility of new neighbours joining any time | ||
2912 | AND to convert to double... */ | ||
2913 | pref_rel = n->current_preference / (1.0 + preference_sum); | ||
2914 | share = 0; | ||
2915 | distributable = 0; | ||
2916 | if (bandwidth_target_out > neighbour_count * MIN_BPM_PER_PEER) | ||
2917 | distributable = bandwidth_target_out - neighbour_count * MIN_BPM_PER_PEER; | ||
2918 | share = distributable * pref_rel; | ||
2919 | q_in = MIN_BPM_PER_PEER + (unsigned long long) share; | ||
2920 | /* check if we want to disconnect for good due to inactivity */ | ||
2921 | if ( (GNUNET_TIME_absolute_get_duration (n->last_activity).value > GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.value) && | ||
2922 | (GNUNET_TIME_absolute_get_duration (n->time_established).value > GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT.value) ) | ||
2923 | q_in = 0; /* force disconnect */ | ||
2924 | if ( (n->bpm_in + MIN_BPM_CHANGE < q_in) || | ||
2925 | (n->bpm_in - MIN_BPM_CHANGE > q_in) ) | ||
2926 | { | ||
2927 | n->bpm_in = q_in; | ||
2928 | GNUNET_TRANSPORT_set_quota (transport, | ||
2929 | &n->peer, | ||
2930 | n->bpm_in, | ||
2931 | n->bpm_out, | ||
2932 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
2933 | NULL, NULL); | ||
2934 | } | ||
2935 | schedule_quota_update (n); | ||
2936 | } | ||
2937 | |||
2938 | |||
2939 | /** | ||
2803 | * Function called by transport to notify us that | 2940 | * Function called by transport to notify us that |
2804 | * a peer connected to us (on the network level). | 2941 | * a peer connected to us (on the network level). |
2805 | * | 2942 | * |
@@ -2827,6 +2964,7 @@ handle_transport_notify_connect (void *cls, | |||
2827 | n = GNUNET_malloc (sizeof (struct Neighbour)); | 2964 | n = GNUNET_malloc (sizeof (struct Neighbour)); |
2828 | n->next = neighbours; | 2965 | n->next = neighbours; |
2829 | neighbours = n; | 2966 | neighbours = n; |
2967 | neighbour_count++; | ||
2830 | n->peer = *peer; | 2968 | n->peer = *peer; |
2831 | n->last_latency = latency; | 2969 | n->last_latency = latency; |
2832 | GNUNET_CRYPTO_aes_create_session_key (&n->encrypt_key); | 2970 | GNUNET_CRYPTO_aes_create_session_key (&n->encrypt_key); |
@@ -2834,10 +2972,10 @@ handle_transport_notify_connect (void *cls, | |||
2834 | n->set_key_retry_frequency = INITIAL_SET_KEY_RETRY_FREQUENCY; | 2972 | n->set_key_retry_frequency = INITIAL_SET_KEY_RETRY_FREQUENCY; |
2835 | n->last_asw_update = now; | 2973 | n->last_asw_update = now; |
2836 | n->last_arw_update = now; | 2974 | n->last_arw_update = now; |
2837 | n->bpm_in = DEFAULT_BPM_IN_OUT; | 2975 | n->bpm_in = GNUNET_CONSTANTS_DEFAULT_BPM_IN_OUT; |
2838 | n->bpm_out = DEFAULT_BPM_IN_OUT; | 2976 | n->bpm_out = GNUNET_CONSTANTS_DEFAULT_BPM_IN_OUT; |
2839 | n->bpm_out_internal_limit = (uint32_t) - 1; | 2977 | n->bpm_out_internal_limit = (uint32_t) - 1; |
2840 | n->bpm_out_external_limit = DEFAULT_BPM_IN_OUT; | 2978 | n->bpm_out_external_limit = GNUNET_CONSTANTS_DEFAULT_BPM_IN_OUT; |
2841 | n->ping_challenge = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, | 2979 | n->ping_challenge = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, |
2842 | (uint32_t) - 1); | 2980 | (uint32_t) - 1); |
2843 | #if DEBUG_CORE | 2981 | #if DEBUG_CORE |
@@ -2845,9 +2983,10 @@ handle_transport_notify_connect (void *cls, | |||
2845 | "Received connection from `%4s'.\n", | 2983 | "Received connection from `%4s'.\n", |
2846 | GNUNET_i2s (&n->peer)); | 2984 | GNUNET_i2s (&n->peer)); |
2847 | #endif | 2985 | #endif |
2986 | schedule_quota_update (n); | ||
2848 | cnm.header.size = htons (sizeof (struct ConnectNotifyMessage)); | 2987 | cnm.header.size = htons (sizeof (struct ConnectNotifyMessage)); |
2849 | cnm.header.type = htons (GNUNET_MESSAGE_TYPE_CORE_NOTIFY_CONNECT); | 2988 | cnm.header.type = htons (GNUNET_MESSAGE_TYPE_CORE_NOTIFY_CONNECT); |
2850 | cnm.bpm_available = htonl (DEFAULT_BPM_IN_OUT); | 2989 | cnm.bpm_available = htonl (n->bpm_out); |
2851 | cnm.peer = *peer; | 2990 | cnm.peer = *peer; |
2852 | cnm.last_activity = GNUNET_TIME_absolute_hton (now); | 2991 | cnm.last_activity = GNUNET_TIME_absolute_hton (now); |
2853 | send_to_all_clients (&cnm.header, GNUNET_YES); | 2992 | send_to_all_clients (&cnm.header, GNUNET_YES); |
@@ -2857,6 +2996,7 @@ handle_transport_notify_connect (void *cls, | |||
2857 | /** | 2996 | /** |
2858 | * Free the given entry for the neighbour (it has | 2997 | * Free the given entry for the neighbour (it has |
2859 | * already been removed from the list at this point). | 2998 | * already been removed from the list at this point). |
2999 | * | ||
2860 | * @param n neighbour to free | 3000 | * @param n neighbour to free |
2861 | */ | 3001 | */ |
2862 | static void | 3002 | static void |
@@ -2880,6 +3020,8 @@ free_neighbour (struct Neighbour *n) | |||
2880 | GNUNET_SCHEDULER_cancel (sched, n->retry_plaintext_task); | 3020 | GNUNET_SCHEDULER_cancel (sched, n->retry_plaintext_task); |
2881 | if (n->retry_set_key_task != GNUNET_SCHEDULER_NO_PREREQUISITE_TASK) | 3021 | if (n->retry_set_key_task != GNUNET_SCHEDULER_NO_PREREQUISITE_TASK) |
2882 | GNUNET_SCHEDULER_cancel (sched, n->retry_set_key_task); | 3022 | GNUNET_SCHEDULER_cancel (sched, n->retry_set_key_task); |
3023 | if (n->quota_update_task != GNUNET_SCHEDULER_NO_PREREQUISITE_TASK) | ||
3024 | GNUNET_SCHEDULER_cancel (sched, n->quota_update_task); | ||
2883 | GNUNET_free_non_null (n->public_key); | 3025 | GNUNET_free_non_null (n->public_key); |
2884 | GNUNET_free_non_null (n->pending_ping); | 3026 | GNUNET_free_non_null (n->pending_ping); |
2885 | GNUNET_free (n); | 3027 | GNUNET_free (n); |
@@ -2922,6 +3064,8 @@ handle_transport_notify_disconnect (void *cls, | |||
2922 | neighbours = n->next; | 3064 | neighbours = n->next; |
2923 | else | 3065 | else |
2924 | p->next = n->next; | 3066 | p->next = n->next; |
3067 | GNUNET_assert (neighbour_count > 0); | ||
3068 | neighbour_count--; | ||
2925 | cnm.header.size = htons (sizeof (struct ConnectNotifyMessage)); | 3069 | cnm.header.size = htons (sizeof (struct ConnectNotifyMessage)); |
2926 | cnm.header.type = htons (GNUNET_MESSAGE_TYPE_CORE_NOTIFY_DISCONNECT); | 3070 | cnm.header.type = htons (GNUNET_MESSAGE_TYPE_CORE_NOTIFY_DISCONNECT); |
2927 | cnm.bpm_available = htonl (0); | 3071 | cnm.bpm_available = htonl (0); |
@@ -2952,6 +3096,8 @@ cleaning_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
2952 | while (NULL != (n = neighbours)) | 3096 | while (NULL != (n = neighbours)) |
2953 | { | 3097 | { |
2954 | neighbours = n->next; | 3098 | neighbours = n->next; |
3099 | GNUNET_assert (neighbour_count > 0); | ||
3100 | neighbour_count--; | ||
2955 | free_neighbour (n); | 3101 | free_neighbour (n); |
2956 | } | 3102 | } |
2957 | while (NULL != (c = clients)) | 3103 | while (NULL != (c = clients)) |
@@ -2983,12 +3129,17 @@ run (void *cls, | |||
2983 | cfg = c; | 3129 | cfg = c; |
2984 | /* parse configuration */ | 3130 | /* parse configuration */ |
2985 | if ( | 3131 | if ( |
2986 | #if 0 | ||
2987 | (GNUNET_OK != | 3132 | (GNUNET_OK != |
2988 | GNUNET_CONFIGURATION_get_value_number (c, | 3133 | GNUNET_CONFIGURATION_get_value_number (c, |
2989 | "CORE", | 3134 | "CORE", |
2990 | "XX", | 3135 | "TOTAL_QUOTA_IN", |
2991 | &qin)) || | 3136 | &bandwidth_target_in)) || |
3137 | (GNUNET_OK != | ||
3138 | GNUNET_CONFIGURATION_get_value_number (c, | ||
3139 | "CORE", | ||
3140 | "TOTAL_QUOTA_OUT", | ||
3141 | &bandwidth_target_out)) || | ||
3142 | #if 0 | ||
2992 | (GNUNET_OK != | 3143 | (GNUNET_OK != |
2993 | GNUNET_CONFIGURATION_get_value_number (c, | 3144 | GNUNET_CONFIGURATION_get_value_number (c, |
2994 | "CORE", | 3145 | "CORE", |
@@ -3052,8 +3203,6 @@ run (void *cls, | |||
3052 | static void | 3203 | static void |
3053 | cleanup (void *cls, struct GNUNET_CONFIGURATION_Handle *cfg) | 3204 | cleanup (void *cls, struct GNUNET_CONFIGURATION_Handle *cfg) |
3054 | { | 3205 | { |
3055 | |||
3056 | |||
3057 | if (my_private_key != NULL) | 3206 | if (my_private_key != NULL) |
3058 | GNUNET_CRYPTO_rsa_key_free (my_private_key); | 3207 | GNUNET_CRYPTO_rsa_key_free (my_private_key); |
3059 | } | 3208 | } |