diff options
-rw-r--r-- | doc/documentation/chapters/user.texi | 14 | ||||
-rw-r--r-- | src/cadet/cadet_api.c | 3 | ||||
-rw-r--r-- | src/conversation/gnunet-service-conversation.c | 74 | ||||
-rw-r--r-- | src/include/gnunet_cadet_service.h | 4 | ||||
-rw-r--r-- | src/reclaim-attribute/reclaim_attribute.c | 10 | ||||
-rw-r--r-- | src/reclaim/gnunet-reclaim.c | 123 | ||||
-rw-r--r-- | src/reclaim/gnunet-service-reclaim.c | 2 | ||||
-rw-r--r-- | src/rps/gnunet-service-rps.c | 213 | ||||
-rw-r--r-- | src/rps/gnunet-service-rps_view.c | 8 | ||||
-rw-r--r-- | src/set/gnunet-service-set.c | 31 | ||||
-rw-r--r-- | src/set/gnunet-service-set.h | 9 | ||||
-rw-r--r-- | src/set/gnunet-service-set_union.c | 7 |
12 files changed, 284 insertions, 214 deletions
diff --git a/doc/documentation/chapters/user.texi b/doc/documentation/chapters/user.texi index 35afdf5f7..50b795197 100644 --- a/doc/documentation/chapters/user.texi +++ b/doc/documentation/chapters/user.texi | |||
@@ -1920,17 +1920,17 @@ $ gnunet-identity -C "username" | |||
1920 | 1920 | ||
1921 | Henceforth, you can manage a new user profile of the user ``username''. | 1921 | Henceforth, you can manage a new user profile of the user ``username''. |
1922 | 1922 | ||
1923 | To add an email address to your user profile, simply use the @command{gnunet-idp} command line tool:: | 1923 | To add an email address to your user profile, simply use the @command{gnunet-reclaim} command line tool:: |
1924 | 1924 | ||
1925 | @example | 1925 | @example |
1926 | $ gnunet-idp -e "username" -a "email" -V "username@@example.gnunet" | 1926 | $ gnunet-reclaim -e "username" -a "email" -V "username@@example.gnunet" |
1927 | @end example | 1927 | @end example |
1928 | 1928 | ||
1929 | All of your attributes can be listed using the @command{gnunet-idp} | 1929 | All of your attributes can be listed using the @command{gnunet-reclaim} |
1930 | command line tool as well: | 1930 | command line tool as well: |
1931 | 1931 | ||
1932 | @example | 1932 | @example |
1933 | $ gnunet-idp -e "username" -D | 1933 | $ gnunet-reclaim -e "username" -D |
1934 | @end example | 1934 | @end example |
1935 | 1935 | ||
1936 | Currently, and by default, attribute values are interpreted as plain text. | 1936 | Currently, and by default, attribute values are interpreted as plain text. |
@@ -1942,7 +1942,7 @@ In the future there might be more value types such as X.509 certificate credenti | |||
1942 | If you want to allow a third party such as a website or friend to access to your attributes (or a subset thereof) execute: | 1942 | If you want to allow a third party such as a website or friend to access to your attributes (or a subset thereof) execute: |
1943 | 1943 | ||
1944 | @example | 1944 | @example |
1945 | $ gnunet-idp -e "username" -r "PKEY" -i "attribute1,attribute2,..." | 1945 | $ gnunet-reclaim -e "username" -r "PKEY" -i "attribute1,attribute2,..." |
1946 | @end example | 1946 | @end example |
1947 | 1947 | ||
1948 | Where "PKEY" is the public key of the third party and "attribute1,attribute2,..." is a comma-separated list of attribute names, such as "email", that you want to share. | 1948 | Where "PKEY" is the public key of the third party and "attribute1,attribute2,..." is a comma-separated list of attribute names, such as "email", that you want to share. |
@@ -1953,7 +1953,7 @@ You must give this "ticket" to the requesting third party. | |||
1953 | The third party can then retrieve your shared identity attributes using: | 1953 | The third party can then retrieve your shared identity attributes using: |
1954 | 1954 | ||
1955 | @example | 1955 | @example |
1956 | $ gnunet-idp -e "friend" -C "ticket" | 1956 | $ gnunet-reclaim -e "friend" -C "ticket" |
1957 | @end example | 1957 | @end example |
1958 | 1958 | ||
1959 | This will retrieve and list the shared identity attributes. | 1959 | This will retrieve and list the shared identity attributes. |
@@ -1962,7 +1962,7 @@ Further, the "ticket" can be re-used later to retrieve up-to-date attributes in | |||
1962 | 1962 | ||
1963 | To list all given authorizations (tickets) you can execute: | 1963 | To list all given authorizations (tickets) you can execute: |
1964 | @example | 1964 | @example |
1965 | $ gnunet-idp -e "friend" -T (TODO there is only a REST API for this ATM) | 1965 | $ gnunet-reclaim -e "friend" -T (TODO there is only a REST API for this ATM) |
1966 | @end example | 1966 | @end example |
1967 | 1967 | ||
1968 | 1968 | ||
diff --git a/src/cadet/cadet_api.c b/src/cadet/cadet_api.c index 92dd39b97..e2ca461a5 100644 --- a/src/cadet/cadet_api.c +++ b/src/cadet/cadet_api.c | |||
@@ -1277,7 +1277,7 @@ GNUNET_CADET_close_port (struct GNUNET_CADET_Port *p) | |||
1277 | /** | 1277 | /** |
1278 | * Destroy an existing channel. | 1278 | * Destroy an existing channel. |
1279 | * | 1279 | * |
1280 | * The existing end callback for the channel will be called immediately. | 1280 | * The existing end callback for the channel will NOT be called. |
1281 | * Any pending outgoing messages will be sent but no incoming messages will be | 1281 | * Any pending outgoing messages will be sent but no incoming messages will be |
1282 | * accepted and no data callbacks will be called. | 1282 | * accepted and no data callbacks will be called. |
1283 | * | 1283 | * |
@@ -1300,6 +1300,7 @@ GNUNET_CADET_channel_destroy (struct GNUNET_CADET_Channel *channel) | |||
1300 | } | 1300 | } |
1301 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1301 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
1302 | "Destroying channel due to GNUNET_CADET_channel_destroy()\n"); | 1302 | "Destroying channel due to GNUNET_CADET_channel_destroy()\n"); |
1303 | channel->disconnects = NULL; | ||
1303 | destroy_channel (channel); | 1304 | destroy_channel (channel); |
1304 | } | 1305 | } |
1305 | 1306 | ||
diff --git a/src/conversation/gnunet-service-conversation.c b/src/conversation/gnunet-service-conversation.c index fb9eec26e..059bb158b 100644 --- a/src/conversation/gnunet-service-conversation.c +++ b/src/conversation/gnunet-service-conversation.c | |||
@@ -303,6 +303,47 @@ handle_client_pickup_message (void *cls, | |||
303 | 303 | ||
304 | 304 | ||
305 | /** | 305 | /** |
306 | * Channel went down, notify client and free data | ||
307 | * structure. | ||
308 | * | ||
309 | * @param ch channel that went down | ||
310 | */ | ||
311 | static void | ||
312 | clean_up_channel (struct Channel *ch) | ||
313 | { | ||
314 | struct Line *line = ch->line; | ||
315 | struct GNUNET_MQ_Envelope *env; | ||
316 | struct ClientPhoneHangupMessage *hup; | ||
317 | |||
318 | switch (ch->status) | ||
319 | { | ||
320 | case CS_CALLEE_INIT: | ||
321 | case CS_CALLEE_SHUTDOWN: | ||
322 | case CS_CALLER_SHUTDOWN: | ||
323 | break; | ||
324 | case CS_CALLEE_RINGING: | ||
325 | case CS_CALLEE_CONNECTED: | ||
326 | case CS_CALLER_CALLING: | ||
327 | case CS_CALLER_CONNECTED: | ||
328 | if (NULL != line) | ||
329 | { | ||
330 | env = GNUNET_MQ_msg (hup, | ||
331 | GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_HANG_UP); | ||
332 | hup->cid = ch->cid; | ||
333 | GNUNET_MQ_send (line->mq, | ||
334 | env); | ||
335 | } | ||
336 | break; | ||
337 | } | ||
338 | if (NULL != line) | ||
339 | GNUNET_CONTAINER_DLL_remove (line->channel_head, | ||
340 | line->channel_tail, | ||
341 | ch); | ||
342 | GNUNET_free (ch); | ||
343 | } | ||
344 | |||
345 | |||
346 | /** | ||
306 | * Destroy a channel. | 347 | * Destroy a channel. |
307 | * | 348 | * |
308 | * @param ch channel to destroy. | 349 | * @param ch channel to destroy. |
@@ -313,7 +354,11 @@ destroy_line_cadet_channels (struct Channel *ch) | |||
313 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 354 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
314 | "Destroying cadet channels\n"); | 355 | "Destroying cadet channels\n"); |
315 | if (NULL != ch->channel) | 356 | if (NULL != ch->channel) |
357 | { | ||
316 | GNUNET_CADET_channel_destroy (ch->channel); | 358 | GNUNET_CADET_channel_destroy (ch->channel); |
359 | ch->channel = NULL; | ||
360 | } | ||
361 | clean_up_channel (ch); | ||
317 | } | 362 | } |
318 | 363 | ||
319 | 364 | ||
@@ -1027,40 +1072,13 @@ inbound_end (void *cls, | |||
1027 | const struct GNUNET_CADET_Channel *channel) | 1072 | const struct GNUNET_CADET_Channel *channel) |
1028 | { | 1073 | { |
1029 | struct Channel *ch = cls; | 1074 | struct Channel *ch = cls; |
1030 | struct Line *line = ch->line; | ||
1031 | struct GNUNET_MQ_Envelope *env; | ||
1032 | struct ClientPhoneHangupMessage *hup; | ||
1033 | 1075 | ||
1034 | GNUNET_assert (channel == ch->channel); | 1076 | GNUNET_assert (channel == ch->channel); |
1035 | ch->channel = NULL; | 1077 | ch->channel = NULL; |
1036 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1078 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1037 | "Channel destroyed by CADET in state %d\n", | 1079 | "Channel destroyed by CADET in state %d\n", |
1038 | ch->status); | 1080 | ch->status); |
1039 | switch (ch->status) | 1081 | clean_up_channel (ch); |
1040 | { | ||
1041 | case CS_CALLEE_INIT: | ||
1042 | case CS_CALLEE_SHUTDOWN: | ||
1043 | case CS_CALLER_SHUTDOWN: | ||
1044 | break; | ||
1045 | case CS_CALLEE_RINGING: | ||
1046 | case CS_CALLEE_CONNECTED: | ||
1047 | case CS_CALLER_CALLING: | ||
1048 | case CS_CALLER_CONNECTED: | ||
1049 | if (NULL != line) | ||
1050 | { | ||
1051 | env = GNUNET_MQ_msg (hup, | ||
1052 | GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_HANG_UP); | ||
1053 | hup->cid = ch->cid; | ||
1054 | GNUNET_MQ_send (line->mq, | ||
1055 | env); | ||
1056 | } | ||
1057 | break; | ||
1058 | } | ||
1059 | if (NULL != line) | ||
1060 | GNUNET_CONTAINER_DLL_remove (line->channel_head, | ||
1061 | line->channel_tail, | ||
1062 | ch); | ||
1063 | GNUNET_free (ch); | ||
1064 | } | 1082 | } |
1065 | 1083 | ||
1066 | 1084 | ||
diff --git a/src/include/gnunet_cadet_service.h b/src/include/gnunet_cadet_service.h index 552763055..276fe4dbc 100644 --- a/src/include/gnunet_cadet_service.h +++ b/src/include/gnunet_cadet_service.h | |||
@@ -151,7 +151,7 @@ typedef void * | |||
151 | 151 | ||
152 | 152 | ||
153 | /** | 153 | /** |
154 | * Function called whenever an MQ-channel is destroyed, even if the destruction | 154 | * Function called whenever an MQ-channel is destroyed, unless the destruction |
155 | * was requested by #GNUNET_CADET_channel_destroy. | 155 | * was requested by #GNUNET_CADET_channel_destroy. |
156 | * It must NOT call #GNUNET_CADET_channel_destroy on the channel. | 156 | * It must NOT call #GNUNET_CADET_channel_destroy on the channel. |
157 | * | 157 | * |
@@ -277,7 +277,7 @@ GNUNET_CADET_channel_create (struct GNUNET_CADET_Handle *h, | |||
277 | /** | 277 | /** |
278 | * Destroy an existing channel. | 278 | * Destroy an existing channel. |
279 | * | 279 | * |
280 | * The existing end callback for the channel will be called immediately. | 280 | * The existing end callback for the channel will NOT be called. |
281 | * Any pending outgoing messages will be sent but no incoming messages will be | 281 | * Any pending outgoing messages will be sent but no incoming messages will be |
282 | * accepted and no data callbacks will be called. | 282 | * accepted and no data callbacks will be called. |
283 | * | 283 | * |
diff --git a/src/reclaim-attribute/reclaim_attribute.c b/src/reclaim-attribute/reclaim_attribute.c index 74d668ea8..1ffa9618f 100644 --- a/src/reclaim-attribute/reclaim_attribute.c +++ b/src/reclaim-attribute/reclaim_attribute.c | |||
@@ -218,23 +218,27 @@ GNUNET_RECLAIM_ATTRIBUTE_claim_new (const char* attr_name, | |||
218 | { | 218 | { |
219 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr; | 219 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr; |
220 | char *write_ptr; | 220 | char *write_ptr; |
221 | char *attr_name_tmp = GNUNET_strdup (attr_name); | ||
222 | |||
223 | GNUNET_STRINGS_utf8_tolower (attr_name, attr_name_tmp); | ||
221 | 224 | ||
222 | attr = GNUNET_malloc (sizeof (struct GNUNET_RECLAIM_ATTRIBUTE_Claim) + | 225 | attr = GNUNET_malloc (sizeof (struct GNUNET_RECLAIM_ATTRIBUTE_Claim) + |
223 | strlen (attr_name) + 1 + | 226 | strlen (attr_name_tmp) + 1 + |
224 | data_size); | 227 | data_size); |
225 | attr->type = type; | 228 | attr->type = type; |
226 | attr->data_size = data_size; | 229 | attr->data_size = data_size; |
227 | attr->version = 0; | 230 | attr->version = 0; |
228 | write_ptr = (char*)&attr[1]; | 231 | write_ptr = (char*)&attr[1]; |
229 | GNUNET_memcpy (write_ptr, | 232 | GNUNET_memcpy (write_ptr, |
230 | attr_name, | 233 | attr_name_tmp, |
231 | strlen (attr_name) + 1); | 234 | strlen (attr_name_tmp) + 1); |
232 | attr->name = write_ptr; | 235 | attr->name = write_ptr; |
233 | write_ptr += strlen (attr->name) + 1; | 236 | write_ptr += strlen (attr->name) + 1; |
234 | GNUNET_memcpy (write_ptr, | 237 | GNUNET_memcpy (write_ptr, |
235 | data, | 238 | data, |
236 | data_size); | 239 | data_size); |
237 | attr->data = write_ptr; | 240 | attr->data = write_ptr; |
241 | GNUNET_free (attr_name_tmp); | ||
238 | return attr; | 242 | return attr; |
239 | } | 243 | } |
240 | 244 | ||
diff --git a/src/reclaim/gnunet-reclaim.c b/src/reclaim/gnunet-reclaim.c index 9947eac6d..677e9f49f 100644 --- a/src/reclaim/gnunet-reclaim.c +++ b/src/reclaim/gnunet-reclaim.c | |||
@@ -134,9 +134,20 @@ static struct GNUNET_TIME_Relative exp_interval; | |||
134 | */ | 134 | */ |
135 | static struct GNUNET_SCHEDULER_Task *timeout; | 135 | static struct GNUNET_SCHEDULER_Task *timeout; |
136 | 136 | ||
137 | /** | ||
138 | * Cleanup task | ||
139 | */ | ||
140 | static struct GNUNET_SCHEDULER_Task *cleanup_task; | ||
141 | |||
142 | /** | ||
143 | * Claim to store | ||
144 | */ | ||
145 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim; | ||
146 | |||
137 | static void | 147 | static void |
138 | do_cleanup(void *cls) | 148 | do_cleanup(void *cls) |
139 | { | 149 | { |
150 | cleanup_task = NULL; | ||
140 | if (NULL != timeout) | 151 | if (NULL != timeout) |
141 | GNUNET_SCHEDULER_cancel (timeout); | 152 | GNUNET_SCHEDULER_cancel (timeout); |
142 | if (NULL != reclaim_op) | 153 | if (NULL != reclaim_op) |
@@ -166,7 +177,7 @@ ticket_issue_cb (void* cls, | |||
166 | ticket_str); | 177 | ticket_str); |
167 | GNUNET_free (ticket_str); | 178 | GNUNET_free (ticket_str); |
168 | } | 179 | } |
169 | GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); | 180 | cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); |
170 | } | 181 | } |
171 | 182 | ||
172 | static void | 183 | static void |
@@ -176,10 +187,10 @@ store_attr_cont (void *cls, | |||
176 | { | 187 | { |
177 | reclaim_op = NULL; | 188 | reclaim_op = NULL; |
178 | if (GNUNET_SYSERR == success) { | 189 | if (GNUNET_SYSERR == success) { |
179 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 190 | fprintf (stderr, |
180 | "%s\n", emsg); | 191 | "%s\n", emsg); |
181 | } | 192 | } |
182 | GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); | 193 | cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); |
183 | } | 194 | } |
184 | 195 | ||
185 | static void | 196 | static void |
@@ -188,10 +199,12 @@ process_attrs (void *cls, | |||
188 | const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr) | 199 | const struct GNUNET_RECLAIM_ATTRIBUTE_Claim *attr) |
189 | { | 200 | { |
190 | char *value_str; | 201 | char *value_str; |
202 | const char* attr_type; | ||
203 | |||
191 | if (NULL == identity) | 204 | if (NULL == identity) |
192 | { | 205 | { |
193 | reclaim_op = NULL; | 206 | reclaim_op = NULL; |
194 | GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); | 207 | cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); |
195 | return; | 208 | return; |
196 | } | 209 | } |
197 | if (NULL == attr) | 210 | if (NULL == attr) |
@@ -202,8 +215,9 @@ process_attrs (void *cls, | |||
202 | value_str = GNUNET_RECLAIM_ATTRIBUTE_value_to_string (attr->type, | 215 | value_str = GNUNET_RECLAIM_ATTRIBUTE_value_to_string (attr->type, |
203 | attr->data, | 216 | attr->data, |
204 | attr->data_size); | 217 | attr->data_size); |
205 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, | 218 | attr_type = GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (attr->type); |
206 | "%s: %s\n", attr->name, value_str); | 219 | fprintf (stdout, |
220 | "%s: %s [%s,v%u]\n", attr->name, value_str, attr_type, attr->version); | ||
207 | } | 221 | } |
208 | 222 | ||
209 | 223 | ||
@@ -211,9 +225,9 @@ static void | |||
211 | iter_error (void *cls) | 225 | iter_error (void *cls) |
212 | { | 226 | { |
213 | attr_iterator = NULL; | 227 | attr_iterator = NULL; |
214 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 228 | fprintf (stderr, |
215 | "Failed to iterate over attributes\n"); | 229 | "Failed to iterate over attributes\n"); |
216 | GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); | 230 | cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); |
217 | } | 231 | } |
218 | 232 | ||
219 | static void | 233 | static void |
@@ -221,9 +235,10 @@ timeout_task (void *cls) | |||
221 | { | 235 | { |
222 | timeout = NULL; | 236 | timeout = NULL; |
223 | ret = 1; | 237 | ret = 1; |
224 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, | 238 | fprintf (stderr, |
225 | "Timeout\n"); | 239 | "Timeout\n"); |
226 | GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); | 240 | if (NULL == cleanup_task) |
241 | cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); | ||
227 | } | 242 | } |
228 | 243 | ||
229 | static void | 244 | static void |
@@ -232,17 +247,16 @@ process_rvk (void *cls, int success, const char* msg) | |||
232 | reclaim_op = NULL; | 247 | reclaim_op = NULL; |
233 | if (GNUNET_OK != success) | 248 | if (GNUNET_OK != success) |
234 | { | 249 | { |
235 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, | 250 | fprintf (stderr, |
236 | "Revocation failed.\n"); | 251 | "Revocation failed.\n"); |
237 | ret = 1; | 252 | ret = 1; |
238 | } | 253 | } |
239 | GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); | 254 | cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); |
240 | } | 255 | } |
241 | 256 | ||
242 | static void | 257 | static void |
243 | iter_finished (void *cls) | 258 | iter_finished (void *cls) |
244 | { | 259 | { |
245 | struct GNUNET_RECLAIM_ATTRIBUTE_Claim *claim; | ||
246 | char *data; | 260 | char *data; |
247 | size_t data_size; | 261 | size_t data_size; |
248 | int type; | 262 | int type; |
@@ -250,7 +264,7 @@ iter_finished (void *cls) | |||
250 | attr_iterator = NULL; | 264 | attr_iterator = NULL; |
251 | if (list) | 265 | if (list) |
252 | { | 266 | { |
253 | GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); | 267 | cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); |
254 | return; | 268 | return; |
255 | } | 269 | } |
256 | 270 | ||
@@ -296,19 +310,30 @@ iter_finished (void *cls) | |||
296 | attr_value, | 310 | attr_value, |
297 | (void**)&data, | 311 | (void**)&data, |
298 | &data_size)); | 312 | &data_size)); |
299 | claim = GNUNET_RECLAIM_ATTRIBUTE_claim_new (attr_name, | 313 | if (NULL != claim) |
300 | type, | 314 | { |
301 | data, | 315 | claim->type = type; |
302 | data_size); | 316 | claim->data = data; |
317 | claim->data_size = data_size; | ||
318 | } | ||
319 | else | ||
320 | { | ||
321 | claim = GNUNET_RECLAIM_ATTRIBUTE_claim_new (attr_name, | ||
322 | type, | ||
323 | data, | ||
324 | data_size); | ||
325 | } | ||
303 | reclaim_op = GNUNET_RECLAIM_attribute_store (reclaim_handle, | 326 | reclaim_op = GNUNET_RECLAIM_attribute_store (reclaim_handle, |
304 | pkey, | 327 | pkey, |
305 | claim, | 328 | claim, |
306 | &exp_interval, | 329 | &exp_interval, |
307 | &store_attr_cont, | 330 | &store_attr_cont, |
308 | NULL); | 331 | NULL); |
332 | GNUNET_free (data); | ||
333 | GNUNET_free (claim); | ||
309 | return; | 334 | return; |
310 | } | 335 | } |
311 | GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); | 336 | cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); |
312 | } | 337 | } |
313 | 338 | ||
314 | static void | 339 | static void |
@@ -319,13 +344,24 @@ iter_cb (void *cls, | |||
319 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; | 344 | struct GNUNET_RECLAIM_ATTRIBUTE_ClaimListEntry *le; |
320 | char *attrs_tmp; | 345 | char *attrs_tmp; |
321 | char *attr_str; | 346 | char *attr_str; |
347 | const char *attr_type; | ||
322 | 348 | ||
323 | if (issue_attrs) | 349 | if ((NULL != attr_name) && (NULL != claim)) |
350 | { | ||
351 | if (0 == strcasecmp (attr_name, attr->name)) | ||
352 | { | ||
353 | claim = GNUNET_RECLAIM_ATTRIBUTE_claim_new (attr->name, | ||
354 | attr->type, | ||
355 | attr->data, | ||
356 | attr->data_size); | ||
357 | } | ||
358 | } | ||
359 | else if (issue_attrs) | ||
324 | { | 360 | { |
325 | attrs_tmp = GNUNET_strdup (issue_attrs); | 361 | attrs_tmp = GNUNET_strdup (issue_attrs); |
326 | attr_str = strtok (attrs_tmp, ","); | 362 | attr_str = strtok (attrs_tmp, ","); |
327 | while (NULL != attr_str) { | 363 | while (NULL != attr_str) { |
328 | if (0 != strcmp (attr_str, attr->name)) { | 364 | if (0 != strcasecmp (attr_str, attr->name)) { |
329 | attr_str = strtok (NULL, ","); | 365 | attr_str = strtok (NULL, ","); |
330 | continue; | 366 | continue; |
331 | } | 367 | } |
@@ -334,26 +370,34 @@ iter_cb (void *cls, | |||
334 | attr->type, | 370 | attr->type, |
335 | attr->data, | 371 | attr->data, |
336 | attr->data_size); | 372 | attr->data_size); |
373 | le->claim->version = attr->version; | ||
337 | GNUNET_CONTAINER_DLL_insert (attr_list->list_head, | 374 | GNUNET_CONTAINER_DLL_insert (attr_list->list_head, |
338 | attr_list->list_tail, | 375 | attr_list->list_tail, |
339 | le); | 376 | le); |
340 | break; | 377 | break; |
341 | } | 378 | } |
342 | GNUNET_free (attrs_tmp); | 379 | GNUNET_free (attrs_tmp); |
343 | } else if (list) { | 380 | } |
344 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, | 381 | else if (list) |
345 | "%s: %s\n", attr->name, (char*)attr->data); | 382 | { |
383 | attr_str = GNUNET_RECLAIM_ATTRIBUTE_value_to_string (attr->type, | ||
384 | attr->data, | ||
385 | attr->data_size); | ||
386 | attr_type = GNUNET_RECLAIM_ATTRIBUTE_number_to_typename (attr->type); | ||
387 | fprintf (stdout, | ||
388 | "%s: %s [%s,v%u]\n", attr->name, attr_str, attr_type, attr->version); | ||
346 | } | 389 | } |
347 | GNUNET_RECLAIM_get_attributes_next (attr_iterator); | 390 | GNUNET_RECLAIM_get_attributes_next (attr_iterator); |
348 | } | 391 | } |
349 | 392 | ||
350 | static void | 393 | static void |
351 | ego_iter_finished (void *cls) | 394 | start_get_attributes () |
352 | { | 395 | { |
353 | if (NULL == pkey) | 396 | if (NULL == pkey) |
354 | { | 397 | { |
355 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, | 398 | fprintf (stderr, |
356 | "Ego %s not found\n", ego_name); | 399 | "Ego %s not found\n", ego_name); |
400 | cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL); | ||
357 | return; | 401 | return; |
358 | } | 402 | } |
359 | 403 | ||
@@ -372,9 +416,8 @@ ego_iter_finished (void *cls) | |||
372 | &ticket, | 416 | &ticket, |
373 | sizeof (struct GNUNET_RECLAIM_Ticket)); | 417 | sizeof (struct GNUNET_RECLAIM_Ticket)); |
374 | 418 | ||
375 | |||
376 | attr_list = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList); | 419 | attr_list = GNUNET_new (struct GNUNET_RECLAIM_ATTRIBUTE_ClaimList); |
377 | 420 | claim = NULL; | |
378 | attr_iterator = GNUNET_RECLAIM_get_attributes_start (reclaim_handle, | 421 | attr_iterator = GNUNET_RECLAIM_get_attributes_start (reclaim_handle, |
379 | pkey, | 422 | pkey, |
380 | &iter_error, | 423 | &iter_error, |
@@ -398,7 +441,7 @@ ego_cb (void *cls, | |||
398 | if (NULL == name) { | 441 | if (NULL == name) { |
399 | if (GNUNET_YES == init) { | 442 | if (GNUNET_YES == init) { |
400 | init = GNUNET_NO; | 443 | init = GNUNET_NO; |
401 | GNUNET_SCHEDULER_add_now (&ego_iter_finished, NULL); | 444 | start_get_attributes(); |
402 | } | 445 | } |
403 | return; | 446 | return; |
404 | } | 447 | } |
@@ -418,24 +461,24 @@ run (void *cls, | |||
418 | if (NULL == ego_name) | 461 | if (NULL == ego_name) |
419 | { | 462 | { |
420 | ret = 1; | 463 | ret = 1; |
421 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, | 464 | fprintf (stderr, |
422 | _("Ego is required\n")); | 465 | _("Ego is required\n")); |
423 | return; | 466 | return; |
424 | } | 467 | } |
425 | 468 | ||
426 | if ( (NULL == attr_value) && (NULL != attr_name) ) | 469 | if ( (NULL == attr_value) && (NULL != attr_name) ) |
427 | { | 470 | { |
428 | ret = 1; | 471 | ret = 1; |
429 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, | 472 | fprintf (stderr, |
430 | _("Attribute value missing!\n")); | 473 | _("Attribute value missing!\n")); |
431 | return; | 474 | return; |
432 | } | 475 | } |
433 | 476 | ||
434 | if ( (NULL == rp) && (NULL != issue_attrs) ) | 477 | if ( (NULL == rp) && (NULL != issue_attrs) ) |
435 | { | 478 | { |
436 | ret = 1; | 479 | ret = 1; |
437 | GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, | 480 | fprintf (stderr, |
438 | _("Requesting party key is required!\n")); | 481 | _("Requesting party key is required!\n")); |
439 | return; | 482 | return; |
440 | } | 483 | } |
441 | 484 | ||
diff --git a/src/reclaim/gnunet-service-reclaim.c b/src/reclaim/gnunet-service-reclaim.c index bf8780a92..3321a79d8 100644 --- a/src/reclaim/gnunet-service-reclaim.c +++ b/src/reclaim/gnunet-service-reclaim.c | |||
@@ -1439,9 +1439,9 @@ check_attr_cb (void *cls, | |||
1439 | 1439 | ||
1440 | buf_size = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (rh->attrs->list_head->claim); | 1440 | buf_size = GNUNET_RECLAIM_ATTRIBUTE_serialize_get_size (rh->attrs->list_head->claim); |
1441 | buf = GNUNET_malloc (buf_size); | 1441 | buf = GNUNET_malloc (buf_size); |
1442 | rh->attrs->list_head->claim->version++; | ||
1442 | GNUNET_RECLAIM_ATTRIBUTE_serialize (rh->attrs->list_head->claim, | 1443 | GNUNET_RECLAIM_ATTRIBUTE_serialize (rh->attrs->list_head->claim, |
1443 | buf); | 1444 | buf); |
1444 | rh->attrs->list_head->claim->version++; | ||
1445 | GNUNET_asprintf (&policy, "%s_%lu", | 1445 | GNUNET_asprintf (&policy, "%s_%lu", |
1446 | rh->attrs->list_head->claim->name, | 1446 | rh->attrs->list_head->claim->name, |
1447 | rh->attrs->list_head->claim->version); | 1447 | rh->attrs->list_head->claim->version); |
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c index 21963ee42..6b0ecc58c 100644 --- a/src/rps/gnunet-service-rps.c +++ b/src/rps/gnunet-service-rps.c | |||
@@ -823,7 +823,7 @@ check_operation_scheduled (const struct GNUNET_PeerIdentity *peer, | |||
823 | return GNUNET_NO; | 823 | return GNUNET_NO; |
824 | } | 824 | } |
825 | 825 | ||
826 | int | 826 | static int |
827 | Peers_remove_peer (const struct GNUNET_PeerIdentity *peer); | 827 | Peers_remove_peer (const struct GNUNET_PeerIdentity *peer); |
828 | 828 | ||
829 | /** | 829 | /** |
@@ -1099,12 +1099,12 @@ Peers_initialise (char* fn_valid_peers, | |||
1099 | /** | 1099 | /** |
1100 | * @brief Delete storage of peers that was created with #Peers_initialise () | 1100 | * @brief Delete storage of peers that was created with #Peers_initialise () |
1101 | */ | 1101 | */ |
1102 | void | 1102 | static void |
1103 | Peers_terminate () | 1103 | peers_terminate () |
1104 | { | 1104 | { |
1105 | if (GNUNET_SYSERR == | 1105 | if (GNUNET_SYSERR == |
1106 | GNUNET_CONTAINER_multipeermap_iterate (peer_map, | 1106 | GNUNET_CONTAINER_multipeermap_iterate (peer_map, |
1107 | peermap_clear_iterator, | 1107 | &peermap_clear_iterator, |
1108 | NULL)) | 1108 | NULL)) |
1109 | { | 1109 | { |
1110 | LOG (GNUNET_ERROR_TYPE_WARNING, | 1110 | LOG (GNUNET_ERROR_TYPE_WARNING, |
@@ -1114,7 +1114,9 @@ Peers_terminate () | |||
1114 | peer_map = NULL; | 1114 | peer_map = NULL; |
1115 | store_valid_peers (); | 1115 | store_valid_peers (); |
1116 | GNUNET_free (filename_valid_peers); | 1116 | GNUNET_free (filename_valid_peers); |
1117 | filename_valid_peers = NULL; | ||
1117 | GNUNET_CONTAINER_multipeermap_destroy (valid_peers); | 1118 | GNUNET_CONTAINER_multipeermap_destroy (valid_peers); |
1119 | valid_peers = NULL; | ||
1118 | } | 1120 | } |
1119 | 1121 | ||
1120 | 1122 | ||
@@ -1257,6 +1259,11 @@ Peers_get_channel_flag (const struct GNUNET_PeerIdentity *peer, | |||
1257 | int | 1259 | int |
1258 | Peers_check_channel_flag (uint32_t *channel_flags, enum Peers_ChannelFlags flags); | 1260 | Peers_check_channel_flag (uint32_t *channel_flags, enum Peers_ChannelFlags flags); |
1259 | 1261 | ||
1262 | /** | ||
1263 | * @brief Callback for the scheduler to destroy the knowledge of a peer. | ||
1264 | * | ||
1265 | * @param cls Context of the peer | ||
1266 | */ | ||
1260 | static void | 1267 | static void |
1261 | destroy_peer (void *cls) | 1268 | destroy_peer (void *cls) |
1262 | { | 1269 | { |
@@ -1267,10 +1274,18 @@ destroy_peer (void *cls) | |||
1267 | Peers_remove_peer (&peer_ctx->peer_id); | 1274 | Peers_remove_peer (&peer_ctx->peer_id); |
1268 | } | 1275 | } |
1269 | 1276 | ||
1277 | |||
1270 | static void | 1278 | static void |
1271 | destroy_channel (void *cls); | 1279 | destroy_channel (void *cls); |
1272 | 1280 | ||
1273 | 1281 | ||
1282 | /** | ||
1283 | * @brief Schedule the destruction of the given channel. | ||
1284 | * | ||
1285 | * Do so only if it was not already scheduled and not during shutdown. | ||
1286 | * | ||
1287 | * @param channel_ctx The context of the channel to destroy. | ||
1288 | */ | ||
1274 | static void | 1289 | static void |
1275 | schedule_channel_destruction (struct ChannelCtx *channel_ctx) | 1290 | schedule_channel_destruction (struct ChannelCtx *channel_ctx) |
1276 | { | 1291 | { |
@@ -1279,11 +1294,19 @@ schedule_channel_destruction (struct ChannelCtx *channel_ctx) | |||
1279 | GNUNET_NO == in_shutdown) | 1294 | GNUNET_NO == in_shutdown) |
1280 | { | 1295 | { |
1281 | channel_ctx->destruction_task = | 1296 | channel_ctx->destruction_task = |
1282 | GNUNET_SCHEDULER_add_now (destroy_channel, channel_ctx); | 1297 | GNUNET_SCHEDULER_add_now (&destroy_channel, |
1298 | channel_ctx); | ||
1283 | } | 1299 | } |
1284 | } | 1300 | } |
1285 | 1301 | ||
1286 | 1302 | ||
1303 | /** | ||
1304 | * @brief Schedule the destruction of the given peer. | ||
1305 | * | ||
1306 | * Do so only if it was not already scheduled and not during shutdown. | ||
1307 | * | ||
1308 | * @param peer_ctx The context of the peer to destroy. | ||
1309 | */ | ||
1287 | static void | 1310 | static void |
1288 | schedule_peer_destruction (struct PeerContext *peer_ctx) | 1311 | schedule_peer_destruction (struct PeerContext *peer_ctx) |
1289 | { | 1312 | { |
@@ -1292,7 +1315,8 @@ schedule_peer_destruction (struct PeerContext *peer_ctx) | |||
1292 | GNUNET_NO == in_shutdown) | 1315 | GNUNET_NO == in_shutdown) |
1293 | { | 1316 | { |
1294 | peer_ctx->destruction_task = | 1317 | peer_ctx->destruction_task = |
1295 | GNUNET_SCHEDULER_add_now (destroy_peer, peer_ctx); | 1318 | GNUNET_SCHEDULER_add_now (&destroy_peer, |
1319 | peer_ctx); | ||
1296 | } | 1320 | } |
1297 | } | 1321 | } |
1298 | 1322 | ||
@@ -1304,18 +1328,18 @@ schedule_peer_destruction (struct PeerContext *peer_ctx) | |||
1304 | * @return #GNUNET_YES if peer was removed | 1328 | * @return #GNUNET_YES if peer was removed |
1305 | * #GNUNET_NO otherwise | 1329 | * #GNUNET_NO otherwise |
1306 | */ | 1330 | */ |
1307 | int | 1331 | static int |
1308 | Peers_remove_peer (const struct GNUNET_PeerIdentity *peer) | 1332 | Peers_remove_peer (const struct GNUNET_PeerIdentity *peer) |
1309 | { | 1333 | { |
1310 | struct PeerContext *peer_ctx; | 1334 | struct PeerContext *peer_ctx; |
1311 | 1335 | ||
1312 | GNUNET_assert (NULL != peer_map); | 1336 | GNUNET_assert (NULL != peer_map); |
1313 | 1337 | if (GNUNET_NO == | |
1314 | if (GNUNET_NO == GNUNET_CONTAINER_multipeermap_contains (peer_map, peer)) | 1338 | GNUNET_CONTAINER_multipeermap_contains (peer_map, |
1339 | peer)) | ||
1315 | { | 1340 | { |
1316 | return GNUNET_NO; | 1341 | return GNUNET_NO; |
1317 | } | 1342 | } |
1318 | |||
1319 | peer_ctx = get_peer_ctx (peer); | 1343 | peer_ctx = get_peer_ctx (peer); |
1320 | set_peer_flag (peer_ctx, Peers_TO_DESTROY); | 1344 | set_peer_flag (peer_ctx, Peers_TO_DESTROY); |
1321 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1345 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
@@ -1326,14 +1350,15 @@ Peers_remove_peer (const struct GNUNET_PeerIdentity *peer) | |||
1326 | /* Clear list of pending operations */ | 1350 | /* Clear list of pending operations */ |
1327 | // TODO this probably leaks memory | 1351 | // TODO this probably leaks memory |
1328 | // ('only' the cls to the function. Not sure what to do with it) | 1352 | // ('only' the cls to the function. Not sure what to do with it) |
1329 | GNUNET_array_grow (peer_ctx->pending_ops, peer_ctx->num_pending_ops, 0); | 1353 | GNUNET_array_grow (peer_ctx->pending_ops, |
1330 | 1354 | peer_ctx->num_pending_ops, | |
1355 | 0); | ||
1331 | /* Remove all pending messages */ | 1356 | /* Remove all pending messages */ |
1332 | while (NULL != peer_ctx->pending_messages_head) | 1357 | while (NULL != peer_ctx->pending_messages_head) |
1333 | { | 1358 | { |
1334 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1359 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1335 | "Removing unsent %s\n", | 1360 | "Removing unsent %s\n", |
1336 | peer_ctx->pending_messages_head->type); | 1361 | peer_ctx->pending_messages_head->type); |
1337 | /* Cancle pending message, too */ | 1362 | /* Cancle pending message, too */ |
1338 | if ( (NULL != peer_ctx->liveliness_check_pending) && | 1363 | if ( (NULL != peer_ctx->liveliness_check_pending) && |
1339 | (0 == memcmp (peer_ctx->pending_messages_head, | 1364 | (0 == memcmp (peer_ctx->pending_messages_head, |
@@ -1343,7 +1368,8 @@ Peers_remove_peer (const struct GNUNET_PeerIdentity *peer) | |||
1343 | // TODO this may leak memory | 1368 | // TODO this may leak memory |
1344 | peer_ctx->liveliness_check_pending = NULL; | 1369 | peer_ctx->liveliness_check_pending = NULL; |
1345 | } | 1370 | } |
1346 | remove_pending_message (peer_ctx->pending_messages_head, GNUNET_YES); | 1371 | remove_pending_message (peer_ctx->pending_messages_head, |
1372 | GNUNET_YES); | ||
1347 | } | 1373 | } |
1348 | 1374 | ||
1349 | /* If we are still waiting for notification whether this peer is live | 1375 | /* If we are still waiting for notification whether this peer is live |
@@ -1351,11 +1377,12 @@ Peers_remove_peer (const struct GNUNET_PeerIdentity *peer) | |||
1351 | if (NULL != peer_ctx->liveliness_check_pending) | 1377 | if (NULL != peer_ctx->liveliness_check_pending) |
1352 | { | 1378 | { |
1353 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1379 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1354 | "Removing pending liveliness check for peer %s\n", | 1380 | "Removing pending liveliness check for peer %s\n", |
1355 | GNUNET_i2s (&peer_ctx->peer_id)); | 1381 | GNUNET_i2s (&peer_ctx->peer_id)); |
1356 | // TODO wait until cadet sets mq->cancel_impl | 1382 | // TODO wait until cadet sets mq->cancel_impl |
1357 | //GNUNET_MQ_send_cancel (peer_ctx->liveliness_check_pending->ev); | 1383 | //GNUNET_MQ_send_cancel (peer_ctx->liveliness_check_pending->ev); |
1358 | remove_pending_message (peer_ctx->liveliness_check_pending, GNUNET_YES); | 1384 | remove_pending_message (peer_ctx->liveliness_check_pending, |
1385 | GNUNET_YES); | ||
1359 | peer_ctx->liveliness_check_pending = NULL; | 1386 | peer_ctx->liveliness_check_pending = NULL; |
1360 | } | 1387 | } |
1361 | 1388 | ||
@@ -1363,8 +1390,7 @@ Peers_remove_peer (const struct GNUNET_PeerIdentity *peer) | |||
1363 | /* Do we still have to wait for destruction of channels | 1390 | /* Do we still have to wait for destruction of channels |
1364 | * or issue the destruction? */ | 1391 | * or issue the destruction? */ |
1365 | if (NULL != peer_ctx->send_channel_ctx && | 1392 | if (NULL != peer_ctx->send_channel_ctx && |
1366 | NULL != peer_ctx->send_channel_ctx->destruction_task | 1393 | NULL != peer_ctx->send_channel_ctx->destruction_task) |
1367 | ) | ||
1368 | { | 1394 | { |
1369 | schedule_peer_destruction (peer_ctx); | 1395 | schedule_peer_destruction (peer_ctx); |
1370 | return GNUNET_NO; | 1396 | return GNUNET_NO; |
@@ -1393,14 +1419,18 @@ Peers_remove_peer (const struct GNUNET_PeerIdentity *peer) | |||
1393 | GNUNET_SCHEDULER_cancel (peer_ctx->destruction_task); | 1419 | GNUNET_SCHEDULER_cancel (peer_ctx->destruction_task); |
1394 | } | 1420 | } |
1395 | 1421 | ||
1396 | if (GNUNET_YES != GNUNET_CONTAINER_multipeermap_remove_all (peer_map, &peer_ctx->peer_id)) | 1422 | if (GNUNET_YES != |
1423 | GNUNET_CONTAINER_multipeermap_remove_all (peer_map, | ||
1424 | &peer_ctx->peer_id)) | ||
1397 | { | 1425 | { |
1398 | LOG (GNUNET_ERROR_TYPE_WARNING, "removing peer from peer_map failed\n"); | 1426 | LOG (GNUNET_ERROR_TYPE_WARNING, |
1427 | "removing peer from peer_map failed\n"); | ||
1399 | } | 1428 | } |
1400 | GNUNET_free (peer_ctx); | 1429 | GNUNET_free (peer_ctx); |
1401 | return GNUNET_YES; | 1430 | return GNUNET_YES; |
1402 | } | 1431 | } |
1403 | 1432 | ||
1433 | |||
1404 | /** | 1434 | /** |
1405 | * @brief set flags on a given peer. | 1435 | * @brief set flags on a given peer. |
1406 | * | 1436 | * |
@@ -1571,6 +1601,7 @@ Peers_handle_inbound_channel (void *cls, | |||
1571 | "Already got one receive channel. Destroying old one.\n"); | 1601 | "Already got one receive channel. Destroying old one.\n"); |
1572 | GNUNET_break_op (0); | 1602 | GNUNET_break_op (0); |
1573 | GNUNET_CADET_channel_destroy (peer_ctx->recv_channel_ctx->channel); | 1603 | GNUNET_CADET_channel_destroy (peer_ctx->recv_channel_ctx->channel); |
1604 | peer_ctx->recv_channel_ctx->channel = NULL; | ||
1574 | remove_channel_ctx (peer_ctx->recv_channel_ctx); | 1605 | remove_channel_ctx (peer_ctx->recv_channel_ctx); |
1575 | peer_ctx->recv_channel_ctx = channel_ctx; | 1606 | peer_ctx->recv_channel_ctx = channel_ctx; |
1576 | /* return the channel context */ | 1607 | /* return the channel context */ |
@@ -1678,6 +1709,11 @@ Peers_destroy_sending_channel (const struct GNUNET_PeerIdentity *peer) | |||
1678 | return GNUNET_NO; | 1709 | return GNUNET_NO; |
1679 | } | 1710 | } |
1680 | 1711 | ||
1712 | /** | ||
1713 | * @brief Callback for scheduler to destroy a channel | ||
1714 | * | ||
1715 | * @param cls Context of the channel | ||
1716 | */ | ||
1681 | static void | 1717 | static void |
1682 | destroy_channel (void *cls) | 1718 | destroy_channel (void *cls) |
1683 | { | 1719 | { |
@@ -1692,58 +1728,6 @@ destroy_channel (void *cls) | |||
1692 | remove_channel_ctx (peer_ctx->send_channel_ctx); | 1728 | remove_channel_ctx (peer_ctx->send_channel_ctx); |
1693 | } | 1729 | } |
1694 | 1730 | ||
1695 | /** | ||
1696 | * This is called when a channel is destroyed. | ||
1697 | * | ||
1698 | * @param cls The closure | ||
1699 | * @param channel The channel being closed | ||
1700 | */ | ||
1701 | void | ||
1702 | Peers_cleanup_destroyed_channel (void *cls, | ||
1703 | const struct GNUNET_CADET_Channel *channel) | ||
1704 | { | ||
1705 | struct ChannelCtx *channel_ctx = cls; | ||
1706 | const struct GNUNET_PeerIdentity *peer = &channel_ctx->peer_ctx->peer_id; | ||
1707 | struct PeerContext *peer_ctx = channel_ctx->peer_ctx; | ||
1708 | |||
1709 | if (GNUNET_NO == Peers_check_peer_known (peer)) | ||
1710 | {/* We don't want to implicitly create a context that we're about to kill */ | ||
1711 | LOG (GNUNET_ERROR_TYPE_WARNING, | ||
1712 | "channel (%s) without associated context was destroyed\n", | ||
1713 | GNUNET_i2s (peer)); | ||
1714 | return; | ||
1715 | } | ||
1716 | |||
1717 | /* If our peer issued the destruction of the channel, the #Peers_TO_DESTROY | ||
1718 | * flag will be set. In this case simply make sure that the channels are | ||
1719 | * cleaned. */ | ||
1720 | /* The distinction seems to be redundant */ | ||
1721 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
1722 | "Peer is NOT in the process of being destroyed\n"); | ||
1723 | if ( (NULL != peer_ctx->send_channel_ctx) && | ||
1724 | (channel == peer_ctx->send_channel_ctx->channel) ) | ||
1725 | { /* Something (but us) killd the channel - clean up peer */ | ||
1726 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
1727 | "send channel (%s) was destroyed - cleaning up\n", | ||
1728 | GNUNET_i2s (peer)); | ||
1729 | remove_channel_ctx (peer_ctx->send_channel_ctx); | ||
1730 | } | ||
1731 | else if ( (NULL != peer_ctx->recv_channel_ctx) && | ||
1732 | (channel == peer_ctx->recv_channel_ctx->channel) ) | ||
1733 | { /* Other peer doesn't want to send us messages anymore */ | ||
1734 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
1735 | "Peer %s destroyed recv channel - cleaning up channel\n", | ||
1736 | GNUNET_i2s (peer)); | ||
1737 | remove_channel_ctx (peer_ctx->send_channel_ctx); | ||
1738 | } | ||
1739 | else | ||
1740 | { | ||
1741 | LOG (GNUNET_ERROR_TYPE_WARNING, | ||
1742 | "unknown channel (%s) was destroyed\n", | ||
1743 | GNUNET_i2s (peer)); | ||
1744 | } | ||
1745 | (void) Peers_check_connected (peer); | ||
1746 | } | ||
1747 | 1731 | ||
1748 | /** | 1732 | /** |
1749 | * @brief Send a message to another peer. | 1733 | * @brief Send a message to another peer. |
@@ -2680,6 +2664,7 @@ add_channel_ctx (struct PeerContext *peer_ctx) | |||
2680 | return channel_ctx; | 2664 | return channel_ctx; |
2681 | } | 2665 | } |
2682 | 2666 | ||
2667 | |||
2683 | /** | 2668 | /** |
2684 | * @brief Remove the channel context from the DLL and free the memory. | 2669 | * @brief Remove the channel context from the DLL and free the memory. |
2685 | * | 2670 | * |
@@ -2689,12 +2674,12 @@ static void | |||
2689 | remove_channel_ctx (struct ChannelCtx *channel_ctx) | 2674 | remove_channel_ctx (struct ChannelCtx *channel_ctx) |
2690 | { | 2675 | { |
2691 | struct PeerContext *peer_ctx = channel_ctx->peer_ctx; | 2676 | struct PeerContext *peer_ctx = channel_ctx->peer_ctx; |
2677 | |||
2692 | if (NULL != channel_ctx->destruction_task) | 2678 | if (NULL != channel_ctx->destruction_task) |
2693 | { | 2679 | { |
2694 | GNUNET_SCHEDULER_cancel (channel_ctx->destruction_task); | 2680 | GNUNET_SCHEDULER_cancel (channel_ctx->destruction_task); |
2695 | } | 2681 | } |
2696 | GNUNET_free (channel_ctx); | 2682 | GNUNET_free (channel_ctx); |
2697 | |||
2698 | if (channel_ctx == peer_ctx->send_channel_ctx) | 2683 | if (channel_ctx == peer_ctx->send_channel_ctx) |
2699 | { | 2684 | { |
2700 | peer_ctx->send_channel_ctx = NULL; | 2685 | peer_ctx->send_channel_ctx = NULL; |
@@ -2706,16 +2691,11 @@ remove_channel_ctx (struct ChannelCtx *channel_ctx) | |||
2706 | } | 2691 | } |
2707 | else | 2692 | else |
2708 | { | 2693 | { |
2709 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
2710 | "Trying to remove channel_ctx that is not associated with a peer\n"); | ||
2711 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
2712 | "\trecv: %p\n", peer_ctx->recv_channel_ctx); | ||
2713 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
2714 | "\tsend: %p\n", peer_ctx->send_channel_ctx); | ||
2715 | GNUNET_assert (0); | 2694 | GNUNET_assert (0); |
2716 | } | 2695 | } |
2717 | } | 2696 | } |
2718 | 2697 | ||
2698 | |||
2719 | /** | 2699 | /** |
2720 | * @brief This is called when a channel is destroyed. | 2700 | * @brief This is called when a channel is destroyed. |
2721 | * | 2701 | * |
@@ -2733,21 +2713,7 @@ cleanup_destroyed_channel (void *cls, | |||
2733 | const struct GNUNET_CADET_Channel *channel) | 2713 | const struct GNUNET_CADET_Channel *channel) |
2734 | { | 2714 | { |
2735 | struct ChannelCtx *channel_ctx = cls; | 2715 | struct ChannelCtx *channel_ctx = cls; |
2736 | struct GNUNET_PeerIdentity *peer = &channel_ctx->peer_ctx->peer_id; | 2716 | struct PeerContext *peer_ctx = channel_ctx->peer_ctx; |
2737 | struct PeerContext *peer_ctx; | ||
2738 | |||
2739 | GNUNET_assert (NULL != peer); | ||
2740 | |||
2741 | if (GNUNET_NO == Peers_check_peer_known (peer)) | ||
2742 | { /* We don't know a context to that peer */ | ||
2743 | LOG (GNUNET_ERROR_TYPE_WARNING, | ||
2744 | "channel (%s) without associated context was destroyed\n", | ||
2745 | GNUNET_i2s (peer)); | ||
2746 | remove_channel_ctx (channel_ctx); | ||
2747 | return; | ||
2748 | } | ||
2749 | |||
2750 | peer_ctx = get_peer_ctx (peer); | ||
2751 | 2717 | ||
2752 | // What should be done here: | 2718 | // What should be done here: |
2753 | // * cleanup everything related to the channel | 2719 | // * cleanup everything related to the channel |
@@ -4118,12 +4084,14 @@ shutdown_task (void *cls) | |||
4118 | reply_cls); | 4084 | reply_cls); |
4119 | GNUNET_free (reply_cls); | 4085 | GNUNET_free (reply_cls); |
4120 | } | 4086 | } |
4121 | GNUNET_CONTAINER_DLL_remove (cli_ctx_head, cli_ctx_tail, client_ctx); | 4087 | GNUNET_CONTAINER_DLL_remove (cli_ctx_head, |
4088 | cli_ctx_tail, | ||
4089 | client_ctx); | ||
4122 | GNUNET_free (client_ctx); | 4090 | GNUNET_free (client_ctx); |
4123 | } | 4091 | } |
4124 | GNUNET_PEERINFO_notify_cancel (peerinfo_notify_handle); | 4092 | GNUNET_PEERINFO_notify_cancel (peerinfo_notify_handle); |
4125 | GNUNET_PEERINFO_disconnect (peerinfo_handle); | 4093 | GNUNET_PEERINFO_disconnect (peerinfo_handle); |
4126 | 4094 | peerinfo_handle = NULL; | |
4127 | if (NULL != do_round_task) | 4095 | if (NULL != do_round_task) |
4128 | { | 4096 | { |
4129 | GNUNET_SCHEDULER_cancel (do_round_task); | 4097 | GNUNET_SCHEDULER_cancel (do_round_task); |
@@ -4142,18 +4110,21 @@ shutdown_task (void *cls) | |||
4142 | CustomPeerMap_destroy (pull_map); | 4110 | CustomPeerMap_destroy (pull_map); |
4143 | if (NULL != stats) | 4111 | if (NULL != stats) |
4144 | { | 4112 | { |
4145 | GNUNET_STATISTICS_destroy (stats, GNUNET_NO); | 4113 | GNUNET_STATISTICS_destroy (stats, |
4114 | GNUNET_NO); | ||
4146 | stats = NULL; | 4115 | stats = NULL; |
4147 | } | 4116 | } |
4148 | #ifdef ENABLE_MALICIOUS | 4117 | #ifdef ENABLE_MALICIOUS |
4149 | struct AttackedPeer *tmp_att_peer; | 4118 | struct AttackedPeer *tmp_att_peer; |
4150 | /* it is ok to free this const during shutdown: */ | 4119 | /* it is ok to free this const during shutdown: */ |
4151 | GNUNET_free ((char *) file_name_view_log); | 4120 | GNUNET_free ((char *) file_name_view_log); |
4152 | #ifdef TO_FILE | 4121 | #ifdef TO_FILE |
4153 | GNUNET_free ((char *) file_name_observed_log); | 4122 | GNUNET_free ((char *) file_name_observed_log); |
4154 | GNUNET_CONTAINER_multipeermap_destroy (observed_unique_peers); | 4123 | GNUNET_CONTAINER_multipeermap_destroy (observed_unique_peers); |
4155 | #endif /* TO_FILE */ | 4124 | #endif /* TO_FILE */ |
4156 | GNUNET_array_grow (mal_peers, num_mal_peers, 0); | 4125 | GNUNET_array_grow (mal_peers, |
4126 | num_mal_peers, | ||
4127 | 0); | ||
4157 | if (NULL != mal_peer_set) | 4128 | if (NULL != mal_peer_set) |
4158 | GNUNET_CONTAINER_multipeermap_destroy (mal_peer_set); | 4129 | GNUNET_CONTAINER_multipeermap_destroy (mal_peer_set); |
4159 | if (NULL != att_peer_set) | 4130 | if (NULL != att_peer_set) |
@@ -4161,10 +4132,12 @@ shutdown_task (void *cls) | |||
4161 | while (NULL != att_peers_head) | 4132 | while (NULL != att_peers_head) |
4162 | { | 4133 | { |
4163 | tmp_att_peer = att_peers_head; | 4134 | tmp_att_peer = att_peers_head; |
4164 | GNUNET_CONTAINER_DLL_remove (att_peers_head, att_peers_tail, tmp_att_peer); | 4135 | GNUNET_CONTAINER_DLL_remove (att_peers_head, |
4136 | att_peers_tail, | ||
4137 | tmp_att_peer); | ||
4165 | GNUNET_free (tmp_att_peer); | 4138 | GNUNET_free (tmp_att_peer); |
4166 | } | 4139 | } |
4167 | #endif /* ENABLE_MALICIOUS */ | 4140 | #endif /* ENABLE_MALICIOUS */ |
4168 | } | 4141 | } |
4169 | 4142 | ||
4170 | 4143 | ||
@@ -4211,6 +4184,7 @@ client_disconnect_cb (void *cls, | |||
4211 | { | 4184 | { |
4212 | struct ClientContext *cli_ctx = internal_cls; | 4185 | struct ClientContext *cli_ctx = internal_cls; |
4213 | 4186 | ||
4187 | (void) cls; | ||
4214 | GNUNET_assert (client == cli_ctx->client); | 4188 | GNUNET_assert (client == cli_ctx->client); |
4215 | if (NULL == client) | 4189 | if (NULL == client) |
4216 | {/* shutdown task - destroy all clients */ | 4190 | {/* shutdown task - destroy all clients */ |
@@ -4238,28 +4212,31 @@ run (void *cls, | |||
4238 | const struct GNUNET_CONFIGURATION_Handle *c, | 4212 | const struct GNUNET_CONFIGURATION_Handle *c, |
4239 | struct GNUNET_SERVICE_Handle *service) | 4213 | struct GNUNET_SERVICE_Handle *service) |
4240 | { | 4214 | { |
4241 | char* fn_valid_peers; | 4215 | char *fn_valid_peers; |
4242 | 4216 | ||
4243 | GNUNET_log_setup ("rps", GNUNET_error_type_to_string (GNUNET_ERROR_TYPE_DEBUG), NULL); | 4217 | (void) cls; |
4218 | (void) service; | ||
4219 | GNUNET_log_setup ("rps", | ||
4220 | GNUNET_error_type_to_string (GNUNET_ERROR_TYPE_DEBUG), | ||
4221 | NULL); | ||
4244 | cfg = c; | 4222 | cfg = c; |
4245 | |||
4246 | |||
4247 | /* Get own ID */ | 4223 | /* Get own ID */ |
4248 | GNUNET_CRYPTO_get_peer_identity (cfg, &own_identity); // TODO check return value | 4224 | GNUNET_CRYPTO_get_peer_identity (cfg, |
4225 | &own_identity); // TODO check return value | ||
4249 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 4226 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
4250 | "STARTING SERVICE (rps) for peer [%s]\n", | 4227 | "STARTING SERVICE (rps) for peer [%s]\n", |
4251 | GNUNET_i2s (&own_identity)); | 4228 | GNUNET_i2s (&own_identity)); |
4252 | #ifdef ENABLE_MALICIOUS | 4229 | #ifdef ENABLE_MALICIOUS |
4253 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 4230 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
4254 | "Malicious execution compiled in.\n"); | 4231 | "Malicious execution compiled in.\n"); |
4255 | #endif /* ENABLE_MALICIOUS */ | 4232 | #endif /* ENABLE_MALICIOUS */ |
4256 | |||
4257 | |||
4258 | 4233 | ||
4259 | /* Get time interval from the configuration */ | 4234 | /* Get time interval from the configuration */ |
4260 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_time (cfg, "RPS", | 4235 | if (GNUNET_OK != |
4261 | "ROUNDINTERVAL", | 4236 | GNUNET_CONFIGURATION_get_value_time (cfg, |
4262 | &round_interval)) | 4237 | "RPS", |
4238 | "ROUNDINTERVAL", | ||
4239 | &round_interval)) | ||
4263 | { | 4240 | { |
4264 | GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, | 4241 | GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, |
4265 | "RPS", "ROUNDINTERVAL"); | 4242 | "RPS", "ROUNDINTERVAL"); |
@@ -4341,7 +4318,7 @@ run (void *cls, | |||
4341 | &Peers_handle_inbound_channel, /* Connect handler */ | 4318 | &Peers_handle_inbound_channel, /* Connect handler */ |
4342 | NULL, /* cls */ | 4319 | NULL, /* cls */ |
4343 | NULL, /* WindowSize handler */ | 4320 | NULL, /* WindowSize handler */ |
4344 | cleanup_destroyed_channel, /* Disconnect handler */ | 4321 | &cleanup_destroyed_channel, /* Disconnect handler */ |
4345 | cadet_handlers); | 4322 | cadet_handlers); |
4346 | if (NULL == cadet_port) | 4323 | if (NULL == cadet_port) |
4347 | { | 4324 | { |
diff --git a/src/rps/gnunet-service-rps_view.c b/src/rps/gnunet-service-rps_view.c index 1fa75fc53..26a0b22bc 100644 --- a/src/rps/gnunet-service-rps_view.c +++ b/src/rps/gnunet-service-rps_view.c | |||
@@ -229,11 +229,10 @@ View_get_peer_by_index (uint32_t index) | |||
229 | void | 229 | void |
230 | View_clear () | 230 | View_clear () |
231 | { | 231 | { |
232 | uint32_t i; | 232 | for (uint32_t i = 0; 0 < View_size (); i++) |
233 | uint32_t *index; | ||
234 | |||
235 | for (i = 0; 0 < View_size (); i++) | ||
236 | { /* Need to free indices stored at peers */ | 233 | { /* Need to free indices stored at peers */ |
234 | uint32_t *index; | ||
235 | |||
237 | GNUNET_assert (GNUNET_YES == | 236 | GNUNET_assert (GNUNET_YES == |
238 | GNUNET_CONTAINER_multipeermap_contains (mpm, &array[i])); | 237 | GNUNET_CONTAINER_multipeermap_contains (mpm, &array[i])); |
239 | index = GNUNET_CONTAINER_multipeermap_get (mpm, &array[i]); | 238 | index = GNUNET_CONTAINER_multipeermap_get (mpm, &array[i]); |
@@ -244,6 +243,7 @@ View_clear () | |||
244 | GNUNET_assert (0 == View_size ()); | 243 | GNUNET_assert (0 == View_size ()); |
245 | } | 244 | } |
246 | 245 | ||
246 | |||
247 | /** | 247 | /** |
248 | * Destroy peermap. | 248 | * Destroy peermap. |
249 | * | 249 | * |
diff --git a/src/set/gnunet-service-set.c b/src/set/gnunet-service-set.c index 217b89d6d..75122395d 100644 --- a/src/set/gnunet-service-set.c +++ b/src/set/gnunet-service-set.c | |||
@@ -221,11 +221,7 @@ incoming_destroy (struct Operation *op) | |||
221 | GNUNET_SCHEDULER_cancel (op->timeout_task); | 221 | GNUNET_SCHEDULER_cancel (op->timeout_task); |
222 | op->timeout_task = NULL; | 222 | op->timeout_task = NULL; |
223 | } | 223 | } |
224 | if (NULL != (channel = op->channel)) | 224 | _GSS_operation_destroy2 (op); |
225 | { | ||
226 | op->channel = NULL; | ||
227 | GNUNET_CADET_channel_destroy (channel); | ||
228 | } | ||
229 | } | 225 | } |
230 | 226 | ||
231 | 227 | ||
@@ -1199,9 +1195,30 @@ channel_end_cb (void *channel_ctx, | |||
1199 | { | 1195 | { |
1200 | struct Operation *op = channel_ctx; | 1196 | struct Operation *op = channel_ctx; |
1201 | 1197 | ||
1198 | op->channel = NULL; | ||
1199 | _GSS_operation_destroy2 (op); | ||
1200 | } | ||
1201 | |||
1202 | |||
1203 | /** | ||
1204 | * This function probably should not exist | ||
1205 | * and be replaced by inlining more specific | ||
1206 | * logic in the various places where it is called. | ||
1207 | */ | ||
1208 | void | ||
1209 | _GSS_operation_destroy2 (struct Operation *op) | ||
1210 | { | ||
1211 | struct GNUNET_CADET_Channel *channel; | ||
1212 | |||
1202 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1213 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1203 | "channel_end_cb called\n"); | 1214 | "channel_end_cb called\n"); |
1204 | op->channel = NULL; | 1215 | if (NULL != (channel = op->channel)) |
1216 | { | ||
1217 | /* This will free op; called conditionally as this helper function | ||
1218 | is also called from within the channel disconnect handler. */ | ||
1219 | op->channel = NULL; | ||
1220 | GNUNET_CADET_channel_destroy (channel); | ||
1221 | } | ||
1205 | if (NULL != op->listener) | 1222 | if (NULL != op->listener) |
1206 | incoming_destroy (op); | 1223 | incoming_destroy (op); |
1207 | else if (NULL != op->set) | 1224 | else if (NULL != op->set) |
@@ -1376,7 +1393,7 @@ handle_client_reject (void *cls, | |||
1376 | "Peer request (op %u, app %s) rejected by client\n", | 1393 | "Peer request (op %u, app %s) rejected by client\n", |
1377 | op->listener->operation, | 1394 | op->listener->operation, |
1378 | GNUNET_h2s (&cs->listener->app_id)); | 1395 | GNUNET_h2s (&cs->listener->app_id)); |
1379 | GNUNET_CADET_channel_destroy (op->channel); | 1396 | _GSS_operation_destroy2 (op); |
1380 | GNUNET_SERVICE_client_continue (cs->client); | 1397 | GNUNET_SERVICE_client_continue (cs->client); |
1381 | } | 1398 | } |
1382 | 1399 | ||
diff --git a/src/set/gnunet-service-set.h b/src/set/gnunet-service-set.h index f7c262eac..a58b22995 100644 --- a/src/set/gnunet-service-set.h +++ b/src/set/gnunet-service-set.h | |||
@@ -630,6 +630,15 @@ _GSS_operation_destroy (struct Operation *op, | |||
630 | 630 | ||
631 | 631 | ||
632 | /** | 632 | /** |
633 | * This function probably should not exist | ||
634 | * and be replaced by inlining more specific | ||
635 | * logic in the various places where it is called. | ||
636 | */ | ||
637 | void | ||
638 | _GSS_operation_destroy2 (struct Operation *op); | ||
639 | |||
640 | |||
641 | /** | ||
633 | * Get the table with implementing functions for set union. | 642 | * Get the table with implementing functions for set union. |
634 | * | 643 | * |
635 | * @return the operation specific VTable | 644 | * @return the operation specific VTable |
diff --git a/src/set/gnunet-service-set_union.c b/src/set/gnunet-service-set_union.c index c1268948a..73d3f5c83 100644 --- a/src/set/gnunet-service-set_union.c +++ b/src/set/gnunet-service-set_union.c | |||
@@ -1399,7 +1399,8 @@ send_client_done (void *cls) | |||
1399 | struct GNUNET_MQ_Envelope *ev; | 1399 | struct GNUNET_MQ_Envelope *ev; |
1400 | struct GNUNET_SET_ResultMessage *rm; | 1400 | struct GNUNET_SET_ResultMessage *rm; |
1401 | 1401 | ||
1402 | if (GNUNET_YES == op->state->client_done_sent) { | 1402 | if (GNUNET_YES == op->state->client_done_sent) |
1403 | { | ||
1403 | return; | 1404 | return; |
1404 | } | 1405 | } |
1405 | 1406 | ||
@@ -1476,7 +1477,7 @@ maybe_finish (struct Operation *op) | |||
1476 | { | 1477 | { |
1477 | op->state->phase = PHASE_DONE; | 1478 | op->state->phase = PHASE_DONE; |
1478 | send_client_done (op); | 1479 | send_client_done (op); |
1479 | destroy_channel (op); | 1480 | _GSS_operation_destroy2 (op); |
1480 | } | 1481 | } |
1481 | } | 1482 | } |
1482 | } | 1483 | } |
@@ -1905,7 +1906,7 @@ handle_union_p2p_full_done (void *cls, | |||
1905 | op->state->phase = PHASE_DONE; | 1906 | op->state->phase = PHASE_DONE; |
1906 | GNUNET_CADET_receive_done (op->channel); | 1907 | GNUNET_CADET_receive_done (op->channel); |
1907 | send_client_done (op); | 1908 | send_client_done (op); |
1908 | destroy_channel (op); | 1909 | _GSS_operation_destroy2 (op); |
1909 | return; | 1910 | return; |
1910 | } | 1911 | } |
1911 | break; | 1912 | break; |