diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-09-18 13:29:39 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-09-18 13:29:39 +0000 |
commit | a0b1e4ae909d99bacac9ecaa52449d6c940d5947 (patch) | |
tree | bb538c35d95c456f46d8008cbb4ad437ebb57f0b | |
parent | dd663a8d291aa5cd0a1235856ba60b71c4c3d344 (diff) | |
download | gnunet-a0b1e4ae909d99bacac9ecaa52449d6c940d5947.tar.gz gnunet-a0b1e4ae909d99bacac9ecaa52449d6c940d5947.zip |
-code review, breaking build a bit
-rw-r--r-- | src/gns/gns_api.c | 32 | ||||
-rw-r--r-- | src/gns/gnunet-service-gns.c | 204 | ||||
-rw-r--r-- | src/gns/gnunet-service-gns_resolver.c | 27 | ||||
-rw-r--r-- | src/gns/gnunet-service-gns_resolver.h | 6 | ||||
-rw-r--r-- | src/include/gnunet_namestore_service.h | 2 | ||||
-rw-r--r-- | src/namestore/namestore_common.c | 2 |
6 files changed, 111 insertions, 162 deletions
diff --git a/src/gns/gns_api.c b/src/gns/gns_api.c index ddc871409..670b036a5 100644 --- a/src/gns/gns_api.c +++ b/src/gns/gns_api.c | |||
@@ -409,21 +409,27 @@ process_shorten_reply (struct GNUNET_GNS_ShortenRequest *qe, | |||
409 | 409 | ||
410 | GNUNET_CONTAINER_DLL_remove (h->shorten_head, h->shorten_tail, qe); | 410 | GNUNET_CONTAINER_DLL_remove (h->shorten_head, h->shorten_tail, qe); |
411 | mlen = ntohs (msg->header.size); | 411 | mlen = ntohs (msg->header.size); |
412 | short_name = (const char *) &msg[1]; | 412 | if (ntohs (msg->header.size) == sizeof (struct GNUNET_GNS_ClientShortenResultMessage)) |
413 | 413 | { | |
414 | if ( (ntohs (msg->header.size) <= sizeof (struct GNUNET_GNS_ClientShortenResultMessage)) || | 414 | /* service reports resolution failed */ |
415 | ('\0' != short_name[mlen - sizeof (struct GNUNET_GNS_ClientShortenResultMessage) - 1]) ) | 415 | short_name = NULL; |
416 | { | 416 | } |
417 | GNUNET_break (0); | 417 | else |
418 | // FIXME: reconnect and queue management logic is broken... | 418 | { |
419 | qe->shorten_proc (qe->proc_cls, NULL); | 419 | short_name = (const char *) &msg[1]; |
420 | GNUNET_free (qe); | 420 | if ('\0' != short_name[mlen - sizeof (struct GNUNET_GNS_ClientShortenResultMessage) - 1]) |
421 | force_reconnect (h); | 421 | { |
422 | return; | 422 | GNUNET_break (0); |
423 | } | 423 | // FIXME: reconnect and queue management logic is broken... |
424 | qe->shorten_proc (qe->proc_cls, NULL); | ||
425 | GNUNET_free (qe); | ||
426 | force_reconnect (h); | ||
427 | return; | ||
428 | } | ||
429 | } | ||
424 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 430 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
425 | "Received shortened reply `%s' from GNS service\n", | 431 | "Received shortened reply `%s' from GNS service\n", |
426 | short_name); | 432 | short_name); |
427 | qe->shorten_proc (qe->proc_cls, short_name); | 433 | qe->shorten_proc (qe->proc_cls, short_name); |
428 | GNUNET_free (qe); | 434 | GNUNET_free (qe); |
429 | } | 435 | } |
diff --git a/src/gns/gnunet-service-gns.c b/src/gns/gnunet-service-gns.c index 4194a1658..d3f7ffabf 100644 --- a/src/gns/gnunet-service-gns.c +++ b/src/gns/gnunet-service-gns.c | |||
@@ -181,6 +181,9 @@ static unsigned long long num_public_records; | |||
181 | */ | 181 | */ |
182 | static unsigned long long last_num_public_records; | 182 | static unsigned long long last_num_public_records; |
183 | 183 | ||
184 | /** | ||
185 | * FIXME! | ||
186 | */ | ||
184 | static struct GNUNET_TIME_Relative zone_iteration_interval; | 187 | static struct GNUNET_TIME_Relative zone_iteration_interval; |
185 | 188 | ||
186 | /* dht update interval FIXME define? */ | 189 | /* dht update interval FIXME define? */ |
@@ -213,30 +216,6 @@ static struct ClientShortenHandle *csh_tail; | |||
213 | /* Statistics handle */ | 216 | /* Statistics handle */ |
214 | static struct GNUNET_STATISTICS_Handle *statistics; | 217 | static struct GNUNET_STATISTICS_Handle *statistics; |
215 | 218 | ||
216 | /** | ||
217 | * Send shorten response back to client | ||
218 | * | ||
219 | * @param cls the closure containing a client shorten handle | ||
220 | * @param name the shortened name result or NULL if cannot be shortened | ||
221 | */ | ||
222 | static void | ||
223 | send_shorten_response(void* cls, const char* name); | ||
224 | |||
225 | |||
226 | /** | ||
227 | * Continue shutdown | ||
228 | */ | ||
229 | static void | ||
230 | on_resolver_cleanup(void) | ||
231 | { | ||
232 | if (NULL != statistics) | ||
233 | GNUNET_STATISTICS_destroy (statistics, GNUNET_NO); | ||
234 | |||
235 | if (NULL != namestore_iter) | ||
236 | GNUNET_NAMESTORE_zone_iteration_stop (namestore_iter); | ||
237 | GNUNET_NAMESTORE_disconnect(namestore_handle); | ||
238 | GNUNET_DHT_disconnect(dht_handle); | ||
239 | } | ||
240 | 219 | ||
241 | /** | 220 | /** |
242 | * Task run during shutdown. | 221 | * Task run during shutdown. |
@@ -247,30 +226,31 @@ on_resolver_cleanup(void) | |||
247 | static void | 226 | static void |
248 | shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 227 | shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
249 | { | 228 | { |
250 | struct ClientShortenHandle *csh_tmp = csh_head; | 229 | struct ClientShortenHandle *csh_tmp; |
251 | 230 | ||
252 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 231 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
253 | "Shutting down!"); | 232 | "Shutting down!"); |
254 | 233 | while (NULL != (csh_tmp = csh_head)) | |
255 | while (csh_tmp != NULL) | ||
256 | { | 234 | { |
257 | GNUNET_CONTAINER_DLL_remove (csh_head, csh_tail, csh_tmp); | 235 | GNUNET_CONTAINER_DLL_remove (csh_head, csh_tail, csh_tmp); |
258 | send_shorten_response (csh_tmp, csh_tmp->name); | 236 | GNUNET_free(csh_tmp); |
259 | } | 237 | } |
260 | 238 | GNUNET_SERVER_notification_context_destroy (nc); | |
261 | GNUNET_SERVER_notification_context_destroy (nc); | 239 | gns_interceptor_stop (); |
262 | 240 | gns_resolver_cleanup (); | |
263 | gns_interceptor_stop(); | 241 | if (NULL != statistics) |
264 | gns_resolver_cleanup(&on_resolver_cleanup); | 242 | GNUNET_STATISTICS_destroy (statistics, GNUNET_NO); |
265 | /* Kill zone task for it may make the scheduler hang */ | ||
266 | if (zone_update_taskid != GNUNET_SCHEDULER_NO_TASK) | 243 | if (zone_update_taskid != GNUNET_SCHEDULER_NO_TASK) |
267 | GNUNET_SCHEDULER_cancel(zone_update_taskid); | 244 | GNUNET_SCHEDULER_cancel (zone_update_taskid); |
245 | if (NULL != namestore_iter) | ||
246 | GNUNET_NAMESTORE_zone_iteration_stop (namestore_iter); | ||
247 | GNUNET_NAMESTORE_disconnect(namestore_handle); | ||
248 | GNUNET_DHT_disconnect(dht_handle); | ||
268 | } | 249 | } |
269 | 250 | ||
270 | 251 | ||
271 | /** | 252 | /** |
272 | * Method called periodicattluy that triggers | 253 | * Method called periodically that triggers iteration over authoritative records |
273 | * iteration over root zone | ||
274 | * | 254 | * |
275 | * @param cls closure | 255 | * @param cls closure |
276 | * @param tc task context | 256 | * @param tc task context |
@@ -282,6 +262,7 @@ update_zone_dht_next(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
282 | GNUNET_NAMESTORE_zone_iterator_next (namestore_iter); | 262 | GNUNET_NAMESTORE_zone_iterator_next (namestore_iter); |
283 | } | 263 | } |
284 | 264 | ||
265 | |||
285 | /** | 266 | /** |
286 | * Continuation for DHT put | 267 | * Continuation for DHT put |
287 | * | 268 | * |
@@ -295,9 +276,10 @@ update_zone_dht_next(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
295 | static void | 276 | static void |
296 | record_dht_put(void *cls, int success) | 277 | record_dht_put(void *cls, int success) |
297 | { | 278 | { |
298 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "put request transmitted\n"); | 279 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "put request transmitted\n"); |
299 | } | 280 | } |
300 | 281 | ||
282 | |||
301 | /* prototype */ | 283 | /* prototype */ |
302 | static void | 284 | static void |
303 | update_zone_dht_start(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | 285 | update_zone_dht_start(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); |
@@ -321,8 +303,7 @@ put_gns_record(void *cls, | |||
321 | unsigned int rd_count, | 303 | unsigned int rd_count, |
322 | const struct GNUNET_NAMESTORE_RecordData *rd, | 304 | const struct GNUNET_NAMESTORE_RecordData *rd, |
323 | const struct GNUNET_CRYPTO_RsaSignature *signature) | 305 | const struct GNUNET_CRYPTO_RsaSignature *signature) |
324 | { | 306 | { |
325 | |||
326 | struct GNSNameRecordBlock *nrb; | 307 | struct GNSNameRecordBlock *nrb; |
327 | struct GNUNET_CRYPTO_ShortHashCode name_hash; | 308 | struct GNUNET_CRYPTO_ShortHashCode name_hash; |
328 | struct GNUNET_CRYPTO_ShortHashCode zhash; | 309 | struct GNUNET_CRYPTO_ShortHashCode zhash; |
@@ -332,9 +313,7 @@ put_gns_record(void *cls, | |||
332 | uint32_t rd_payload_length; | 313 | uint32_t rd_payload_length; |
333 | char* nrb_data = NULL; | 314 | char* nrb_data = NULL; |
334 | size_t namelen; | 315 | size_t namelen; |
335 | struct GNUNET_TIME_Relative next_put_interval; | 316 | struct GNUNET_TIME_Relative next_put_interval; |
336 | |||
337 | |||
338 | 317 | ||
339 | /* we're done */ | 318 | /* we're done */ |
340 | if (NULL == name) | 319 | if (NULL == name) |
@@ -362,9 +341,9 @@ put_gns_record(void *cls, | |||
362 | zone_iteration_interval = GNUNET_TIME_relative_max (MINIMUM_ZONE_ITERATION_INTERVAL, | 341 | zone_iteration_interval = GNUNET_TIME_relative_max (MINIMUM_ZONE_ITERATION_INTERVAL, |
363 | zone_iteration_interval); | 342 | zone_iteration_interval); |
364 | 343 | ||
365 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 344 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
366 | "Adjusted zone iteration interval to %llus!\n", | 345 | "Adjusted zone iteration interval to %s\n", |
367 | zone_iteration_interval.rel_value); | 346 | GNUNET_STRINGS_relative_time_to_string (zone_iteration_interval, GNUNET_YES)); |
368 | GNUNET_STATISTICS_set (statistics, | 347 | GNUNET_STATISTICS_set (statistics, |
369 | "Current zone iteration interval [msec]", | 348 | "Current zone iteration interval [msec]", |
370 | zone_iteration_interval.rel_value, | 349 | zone_iteration_interval.rel_value, |
@@ -392,98 +371,84 @@ put_gns_record(void *cls, | |||
392 | } | 371 | } |
393 | 372 | ||
394 | namelen = strlen(name) + 1; | 373 | namelen = strlen(name) + 1; |
395 | |||
396 | if (rd_count == 0) | 374 | if (rd_count == 0) |
397 | { | 375 | { |
398 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 376 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
399 | "No records given for name %s! Skipping...\n", | 377 | "No records for name `%s'! Skipping.\n", |
400 | name); | 378 | name); |
401 | zone_update_taskid = GNUNET_SCHEDULER_add_now (&update_zone_dht_next, | 379 | zone_update_taskid = GNUNET_SCHEDULER_add_now (&update_zone_dht_next, |
402 | NULL); | 380 | NULL); |
403 | return; | 381 | return; |
404 | } | 382 | } |
405 | |||
406 | if (signature == NULL) | 383 | if (signature == NULL) |
407 | { | 384 | { |
408 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 385 | GNUNET_break (0); |
409 | "No signature for %s record data provided! Skipping...\n", | ||
410 | name); | ||
411 | zone_update_taskid = GNUNET_SCHEDULER_add_now (&update_zone_dht_next, | 386 | zone_update_taskid = GNUNET_SCHEDULER_add_now (&update_zone_dht_next, |
412 | NULL); | 387 | NULL); |
413 | return; | 388 | return; |
414 | |||
415 | } | 389 | } |
416 | 390 | ||
417 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 391 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
418 | "Putting records for %s into the DHT\n", name); | 392 | "Putting records for `%s' into the DHT\n", name); |
419 | |||
420 | rd_payload_length = GNUNET_NAMESTORE_records_get_size (rd_count, rd); | ||
421 | 393 | ||
394 | rd_payload_length = GNUNET_NAMESTORE_records_get_size (rd_count, rd); | ||
422 | nrb = GNUNET_malloc(rd_payload_length + namelen | 395 | nrb = GNUNET_malloc(rd_payload_length + namelen |
423 | + sizeof(struct GNSNameRecordBlock)); | 396 | + sizeof(struct GNSNameRecordBlock)); |
424 | |||
425 | nrb->signature = *signature; | 397 | nrb->signature = *signature; |
426 | |||
427 | nrb->public_key = *key; | 398 | nrb->public_key = *key; |
428 | |||
429 | nrb->rd_count = htonl(rd_count); | 399 | nrb->rd_count = htonl(rd_count); |
430 | |||
431 | memcpy(&nrb[1], name, namelen); | 400 | memcpy(&nrb[1], name, namelen); |
432 | 401 | nrb_data = (char *) &nrb[1]; | |
433 | nrb_data = (char*)&nrb[1]; | ||
434 | nrb_data += namelen; | 402 | nrb_data += namelen; |
435 | |||
436 | rd_payload_length += sizeof(struct GNSNameRecordBlock) + namelen; | 403 | rd_payload_length += sizeof(struct GNSNameRecordBlock) + namelen; |
437 | 404 | GNUNET_CRYPTO_short_hash (key, | |
405 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), | ||
406 | &zhash); | ||
438 | if (-1 == GNUNET_NAMESTORE_records_serialize (rd_count, | 407 | if (-1 == GNUNET_NAMESTORE_records_serialize (rd_count, |
439 | rd, | 408 | rd, |
440 | rd_payload_length, | 409 | rd_payload_length, |
441 | nrb_data)) | 410 | nrb_data)) |
442 | { | 411 | { |
443 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 412 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
444 | "Record serialization failed! Skipping...\n"); | 413 | _("Records for name `%s' in zone %s too large to fit into DHT"), |
414 | name, | ||
415 | GNUNET_h2s (&zhash) /* FIXME: write converter for short hash... */); | ||
445 | GNUNET_free(nrb); | 416 | GNUNET_free(nrb); |
446 | zone_update_taskid = GNUNET_SCHEDULER_add_now (&update_zone_dht_next, | 417 | zone_update_taskid = GNUNET_SCHEDULER_add_now (&update_zone_dht_next, |
447 | NULL); | 418 | NULL); |
448 | return; | 419 | return; |
449 | } | 420 | } |
450 | 421 | ||
451 | |||
452 | /* | 422 | /* |
453 | * calculate DHT key: H(name) xor H(pubkey) | 423 | * calculate DHT key: H(name) xor H(pubkey) |
454 | */ | 424 | */ |
455 | GNUNET_CRYPTO_short_hash(key, | ||
456 | sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), | ||
457 | &zhash); | ||
458 | GNUNET_CRYPTO_short_hash(name, strlen(name), &name_hash); | 425 | GNUNET_CRYPTO_short_hash(name, strlen(name), &name_hash); |
459 | GNUNET_CRYPTO_short_hash_double (&name_hash, &name_hash_double); | 426 | GNUNET_CRYPTO_short_hash_double (&name_hash, &name_hash_double); |
460 | GNUNET_CRYPTO_short_hash_double (&zhash, &zone_hash_double); | 427 | GNUNET_CRYPTO_short_hash_double (&zhash, &zone_hash_double); |
461 | GNUNET_CRYPTO_hash_xor(&zone_hash_double, &name_hash_double, &xor_hash); | 428 | GNUNET_CRYPTO_hash_xor(&zone_hash_double, &name_hash_double, &xor_hash); |
462 | 429 | ||
463 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 430 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
464 | "zone identity: %s\n", GNUNET_h2s (&zone_hash_double)); | 431 | "putting %u records from zone %s for `%s' under key: %s with size %u and timeout %s\n", |
465 | 432 | rd_count, | |
466 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 433 | GNUNET_h2s (&zone_hash_double) /* FIXME: write converter for short hash... */, |
467 | "putting %d records for %s under key: %s with size %d\n", | 434 | name, |
468 | rd_count, name, GNUNET_h2s (&xor_hash), rd_payload_length); | 435 | GNUNET_h2s (&xor_hash), |
436 | (unsigned int) rd_payload_length, | ||
437 | GNUNET_STRINGS_relative_time_to_string (DHT_OPERATION_TIMEOUT, GNUNET_YES)); | ||
469 | 438 | ||
470 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | ||
471 | "DHT req to %d\n", DHT_OPERATION_TIMEOUT.rel_value); | ||
472 | |||
473 | GNUNET_STATISTICS_update (statistics, | 439 | GNUNET_STATISTICS_update (statistics, |
474 | "Record bytes put into DHT", rd_payload_length, GNUNET_NO); | 440 | "Record bytes put into DHT", rd_payload_length, GNUNET_NO); |
475 | 441 | ||
476 | /* FIXME: keep return value to possibly cancel? */ | 442 | (void) GNUNET_DHT_put (dht_handle, &xor_hash, |
477 | GNUNET_DHT_put (dht_handle, &xor_hash, | 443 | DHT_GNS_REPLICATION_LEVEL, |
478 | DHT_GNS_REPLICATION_LEVEL, | 444 | GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, |
479 | GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, | 445 | GNUNET_BLOCK_TYPE_GNS_NAMERECORD, |
480 | GNUNET_BLOCK_TYPE_GNS_NAMERECORD, | 446 | rd_payload_length, |
481 | rd_payload_length, | 447 | (char*)nrb, |
482 | (char*)nrb, | 448 | expiration, |
483 | expiration, | 449 | DHT_OPERATION_TIMEOUT, |
484 | DHT_OPERATION_TIMEOUT, | 450 | &record_dht_put, |
485 | &record_dht_put, | 451 | NULL); |
486 | NULL); //cls for cont | ||
487 | 452 | ||
488 | num_public_records++; | 453 | num_public_records++; |
489 | 454 | ||
@@ -514,9 +479,9 @@ put_gns_record(void *cls, | |||
514 | NULL); | 479 | NULL); |
515 | 480 | ||
516 | GNUNET_free(nrb); | 481 | GNUNET_free(nrb); |
517 | |||
518 | } | 482 | } |
519 | 483 | ||
484 | |||
520 | /** | 485 | /** |
521 | * Periodically iterate over our zone and store everything in dht | 486 | * Periodically iterate over our zone and store everything in dht |
522 | * | 487 | * |
@@ -551,41 +516,37 @@ update_zone_dht_start(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
551 | static void | 516 | static void |
552 | send_shorten_response(void* cls, const char* name) | 517 | send_shorten_response(void* cls, const char* name) |
553 | { | 518 | { |
554 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message with %s\n", | 519 | struct ClientShortenHandle *csh = cls; |
555 | "SHORTEN_RESULT", name); | ||
556 | struct GNUNET_GNS_ClientShortenResultMessage *rmsg; | 520 | struct GNUNET_GNS_ClientShortenResultMessage *rmsg; |
557 | struct ClientShortenHandle *csh = (struct ClientShortenHandle *)cls; | 521 | size_t name_len; |
558 | 522 | ||
559 | if (name == NULL) | 523 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message with %s\n", |
560 | { | 524 | "SHORTEN_RESULT", name); |
561 | name = ""; | 525 | if (NULL == name) |
562 | } | 526 | name_len = 0; |
563 | 527 | else | |
528 | name_len = strlen (name) + 1; | ||
564 | GNUNET_STATISTICS_update (statistics, | 529 | GNUNET_STATISTICS_update (statistics, |
565 | "Name shorten results", 1, GNUNET_NO); | 530 | "Name shorten results", 1, GNUNET_NO); |
566 | 531 | ||
567 | rmsg = GNUNET_malloc(sizeof(struct GNUNET_GNS_ClientShortenResultMessage) | 532 | rmsg = GNUNET_malloc(sizeof(struct GNUNET_GNS_ClientShortenResultMessage) + |
568 | + strlen(name) + 1); | 533 | name_len); |
569 | 534 | ||
570 | rmsg->id = csh->unique_id; | 535 | rmsg->id = csh->unique_id; |
571 | rmsg->header.type = htons(GNUNET_MESSAGE_TYPE_GNS_SHORTEN_RESULT); | 536 | rmsg->header.type = htons(GNUNET_MESSAGE_TYPE_GNS_SHORTEN_RESULT); |
572 | rmsg->header.size = | 537 | rmsg->header.size = |
573 | htons(sizeof(struct GNUNET_GNS_ClientShortenResultMessage) + | 538 | htons(sizeof(struct GNUNET_GNS_ClientShortenResultMessage) + |
574 | strlen(name) + 1); | 539 | name_len); |
575 | 540 | memcpy (&rmsg[1], name, name_len); | |
576 | strcpy((char*)&rmsg[1], name); | ||
577 | 541 | ||
578 | GNUNET_SERVER_notification_context_unicast (nc, csh->client, | 542 | GNUNET_SERVER_notification_context_unicast (nc, csh->client, |
579 | (const struct GNUNET_MessageHeader *) rmsg, | 543 | &rmsg->header, |
580 | GNUNET_NO); | 544 | GNUNET_NO); |
581 | GNUNET_SERVER_receive_done (csh->client, GNUNET_OK); | 545 | GNUNET_SERVER_receive_done (csh->client, GNUNET_OK); |
582 | |||
583 | if (NULL != csh->namestore_task) | 546 | if (NULL != csh->namestore_task) |
584 | GNUNET_NAMESTORE_cancel (csh->namestore_task); | 547 | GNUNET_NAMESTORE_cancel (csh->namestore_task); |
585 | 548 | GNUNET_free (rmsg); | |
586 | GNUNET_free(rmsg); | 549 | GNUNET_free (csh); |
587 | GNUNET_free(csh); | ||
588 | |||
589 | } | 550 | } |
590 | 551 | ||
591 | 552 | ||
@@ -792,13 +753,14 @@ start_shorten_name (struct ClientShortenHandle *csh) | |||
792 | /** | 753 | /** |
793 | * Handle a shorten message from the api | 754 | * Handle a shorten message from the api |
794 | * | 755 | * |
795 | * @param cls the closure | 756 | * @param cls the closure (unused) |
796 | * @param client the client | 757 | * @param client the client |
797 | * @param message the message | 758 | * @param message the message |
798 | */ | 759 | */ |
799 | static void handle_shorten (void *cls, | 760 | static void |
800 | struct GNUNET_SERVER_Client * client, | 761 | handle_shorten (void *cls, |
801 | const struct GNUNET_MessageHeader * message) | 762 | struct GNUNET_SERVER_Client * client, |
763 | const struct GNUNET_MessageHeader * message) | ||
802 | { | 764 | { |
803 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "SHORTEN"); | 765 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' message\n", "SHORTEN"); |
804 | 766 | ||
@@ -919,8 +881,8 @@ send_get_auth_response(void *cls, const char* name) | |||
919 | strcpy((char*)&rmsg[1], name); | 881 | strcpy((char*)&rmsg[1], name); |
920 | 882 | ||
921 | GNUNET_SERVER_notification_context_unicast (nc, cah->client, | 883 | GNUNET_SERVER_notification_context_unicast (nc, cah->client, |
922 | (const struct GNUNET_MessageHeader *) rmsg, | 884 | &rmsg->header, |
923 | GNUNET_NO); | 885 | GNUNET_NO); |
924 | GNUNET_SERVER_receive_done (cah->client, GNUNET_OK); | 886 | GNUNET_SERVER_receive_done (cah->client, GNUNET_OK); |
925 | 887 | ||
926 | GNUNET_free(rmsg); | 888 | GNUNET_free(rmsg); |
diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c index 1a22e624d..f51b5393e 100644 --- a/src/gns/gnunet-service-gns_resolver.c +++ b/src/gns/gnunet-service-gns_resolver.c | |||
@@ -677,17 +677,12 @@ cleanup_pending_ns_tasks (void* cls, | |||
677 | GNUNET_CONTAINER_HeapCostType cost) | 677 | GNUNET_CONTAINER_HeapCostType cost) |
678 | { | 678 | { |
679 | struct NamestoreBGTask *nbg = element; | 679 | struct NamestoreBGTask *nbg = element; |
680 | ResolverCleanupContinuation cont = cls; | ||
681 | 680 | ||
682 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 681 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
683 | "GNS_CLEANUP: Terminating ns task\n"); | 682 | "GNS_CLEANUP: Terminating ns task\n"); |
684 | GNUNET_NAMESTORE_cancel (nbg->qe); | 683 | GNUNET_NAMESTORE_cancel (nbg->qe); |
685 | 684 | ||
686 | GNUNET_CONTAINER_heap_remove_node (node); | 685 | GNUNET_CONTAINER_heap_remove_node (node); |
687 | |||
688 | if (0 == GNUNET_CONTAINER_heap_get_size (ns_task_heap)) | ||
689 | cont (); | ||
690 | |||
691 | return GNUNET_YES; | 686 | return GNUNET_YES; |
692 | } | 687 | } |
693 | 688 | ||
@@ -724,7 +719,6 @@ cleanup_pending_background_queries (void* cls, | |||
724 | GNUNET_CONTAINER_HeapCostType cost) | 719 | GNUNET_CONTAINER_HeapCostType cost) |
725 | { | 720 | { |
726 | struct ResolverHandle *rh = element; | 721 | struct ResolverHandle *rh = element; |
727 | ResolverCleanupContinuation cont = cls; | ||
728 | 722 | ||
729 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 723 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
730 | "GNS_CLEANUP-%llu: Terminating background lookup for %s\n", | 724 | "GNS_CLEANUP-%llu: Terminating background lookup for %s\n", |
@@ -732,17 +726,10 @@ cleanup_pending_background_queries (void* cls, | |||
732 | GNUNET_CONTAINER_heap_remove_node (node); | 726 | GNUNET_CONTAINER_heap_remove_node (node); |
733 | if (0 == GNUNET_CONTAINER_heap_get_size (dht_lookup_heap)) | 727 | if (0 == GNUNET_CONTAINER_heap_get_size (dht_lookup_heap)) |
734 | { | 728 | { |
735 | if (GNUNET_CONTAINER_heap_get_size (ns_task_heap) == 0) | 729 | GNUNET_CONTAINER_heap_iterate (ns_task_heap, |
736 | cont (); | 730 | &cleanup_pending_ns_tasks, |
737 | else | 731 | NULL); |
738 | { | ||
739 | GNUNET_CONTAINER_heap_iterate (ns_task_heap, | ||
740 | &cleanup_pending_ns_tasks, | ||
741 | cont); | ||
742 | } | ||
743 | } | 732 | } |
744 | |||
745 | |||
746 | return GNUNET_YES; | 733 | return GNUNET_YES; |
747 | } | 734 | } |
748 | 735 | ||
@@ -819,7 +806,7 @@ finish_get_auth (struct ResolverHandle *rh, | |||
819 | * Shutdown resolver | 806 | * Shutdown resolver |
820 | */ | 807 | */ |
821 | void | 808 | void |
822 | gns_resolver_cleanup (ResolverCleanupContinuation cont) | 809 | gns_resolver_cleanup () |
823 | { | 810 | { |
824 | unsigned int s; | 811 | unsigned int s; |
825 | struct GetPseuAuthorityHandle *tmp; | 812 | struct GetPseuAuthorityHandle *tmp; |
@@ -863,15 +850,13 @@ gns_resolver_cleanup (ResolverCleanupContinuation cont) | |||
863 | if (0 != s) | 850 | if (0 != s) |
864 | GNUNET_CONTAINER_heap_iterate (dht_lookup_heap, | 851 | GNUNET_CONTAINER_heap_iterate (dht_lookup_heap, |
865 | &cleanup_pending_background_queries, | 852 | &cleanup_pending_background_queries, |
866 | cont); | 853 | NULL); |
867 | else if (0 != GNUNET_CONTAINER_heap_get_size (ns_task_heap)) | 854 | else if (0 != GNUNET_CONTAINER_heap_get_size (ns_task_heap)) |
868 | { | 855 | { |
869 | GNUNET_CONTAINER_heap_iterate (ns_task_heap, | 856 | GNUNET_CONTAINER_heap_iterate (ns_task_heap, |
870 | &cleanup_pending_ns_tasks, | 857 | &cleanup_pending_ns_tasks, |
871 | cont); | 858 | NULL); |
872 | } | 859 | } |
873 | else | ||
874 | cont (); | ||
875 | } | 860 | } |
876 | 861 | ||
877 | 862 | ||
diff --git a/src/gns/gnunet-service-gns_resolver.h b/src/gns/gnunet-service-gns_resolver.h index 8b0a05e5f..8c144df16 100644 --- a/src/gns/gnunet-service-gns_resolver.h +++ b/src/gns/gnunet-service-gns_resolver.h | |||
@@ -36,10 +36,6 @@ struct AuthorityChain | |||
36 | /* handle to a resolution process */ | 36 | /* handle to a resolution process */ |
37 | struct ResolverHandle; | 37 | struct ResolverHandle; |
38 | 38 | ||
39 | /** | ||
40 | * continuation called when cleanup of resolver finishes | ||
41 | */ | ||
42 | typedef void (*ResolverCleanupContinuation) (void); | ||
43 | 39 | ||
44 | /** | 40 | /** |
45 | * processor for a record lookup result | 41 | * processor for a record lookup result |
@@ -376,7 +372,7 @@ gns_resolver_init(struct GNUNET_NAMESTORE_Handle *nh, | |||
376 | * @param cont continuation to call when finished | 372 | * @param cont continuation to call when finished |
377 | */ | 373 | */ |
378 | void | 374 | void |
379 | gns_resolver_cleanup(ResolverCleanupContinuation cont); | 375 | gns_resolver_cleanup(void); |
380 | 376 | ||
381 | /** | 377 | /** |
382 | * Lookup of a record in a specific zone | 378 | * Lookup of a record in a specific zone |
diff --git a/src/include/gnunet_namestore_service.h b/src/include/gnunet_namestore_service.h index ee8654948..c381cc920 100644 --- a/src/include/gnunet_namestore_service.h +++ b/src/include/gnunet_namestore_service.h | |||
@@ -499,7 +499,7 @@ GNUNET_NAMESTORE_records_get_size (unsigned int rd_count, | |||
499 | * @param dest_size size of the destination array | 499 | * @param dest_size size of the destination array |
500 | * @param dest where to write the result | 500 | * @param dest where to write the result |
501 | * | 501 | * |
502 | * @return the size of serialized records | 502 | * @return the size of serialized records, -1 if records do not fit |
503 | */ | 503 | */ |
504 | ssize_t | 504 | ssize_t |
505 | GNUNET_NAMESTORE_records_serialize (unsigned int rd_count, | 505 | GNUNET_NAMESTORE_records_serialize (unsigned int rd_count, |
diff --git a/src/namestore/namestore_common.c b/src/namestore/namestore_common.c index 74f2d063b..83bc07c39 100644 --- a/src/namestore/namestore_common.c +++ b/src/namestore/namestore_common.c | |||
@@ -125,7 +125,7 @@ GNUNET_NAMESTORE_records_get_size (unsigned int rd_count, | |||
125 | * @param dest_size size of the destination array | 125 | * @param dest_size size of the destination array |
126 | * @param dest where to write the result | 126 | * @param dest where to write the result |
127 | * | 127 | * |
128 | * @return the size of serialized records | 128 | * @return the size of serialized records, -1 if records do not fit |
129 | */ | 129 | */ |
130 | ssize_t | 130 | ssize_t |
131 | GNUNET_NAMESTORE_records_serialize (unsigned int rd_count, | 131 | GNUNET_NAMESTORE_records_serialize (unsigned int rd_count, |