diff options
author | Martin Schanzenbach <mschanzenbach@posteo.de> | 2012-10-30 11:00:13 +0000 |
---|---|---|
committer | Martin Schanzenbach <mschanzenbach@posteo.de> | 2012-10-30 11:00:13 +0000 |
commit | 61601fa8f6b8b11ad32708357fa525736cb00273 (patch) | |
tree | 57258c413a6b7625d914579f2658eaa47369a473 /src/gns | |
parent | 312426a2efd842c060c13581988c7faa4d1600c8 (diff) | |
download | gnunet-61601fa8f6b8b11ad32708357fa525736cb00273.tar.gz gnunet-61601fa8f6b8b11ad32708357fa525736cb00273.zip |
-cleanup
Diffstat (limited to 'src/gns')
-rw-r--r-- | src/gns/gns_api.c | 94 |
1 files changed, 47 insertions, 47 deletions
diff --git a/src/gns/gns_api.c b/src/gns/gns_api.c index b3173a554..a1d734df2 100644 --- a/src/gns/gns_api.c +++ b/src/gns/gns_api.c | |||
@@ -279,17 +279,17 @@ process_pending_messages (struct GNUNET_GNS_Handle *handle); | |||
279 | /** | 279 | /** |
280 | * Reconnect to GNS service. | 280 | * Reconnect to GNS service. |
281 | * | 281 | * |
282 | * @param h the handle to the GNS service | 282 | * @param handle the handle to the GNS service |
283 | */ | 283 | */ |
284 | static void | 284 | static void |
285 | reconnect (struct GNUNET_GNS_Handle *h) | 285 | reconnect (struct GNUNET_GNS_Handle *handle) |
286 | { | 286 | { |
287 | GNUNET_assert (NULL == h->client); | 287 | GNUNET_assert (NULL == handle->client); |
288 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 288 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
289 | "Trying to connect to GNS\n"); | 289 | "Trying to connect to GNS\n"); |
290 | h->client = GNUNET_CLIENT_connect ("gns", h->cfg); | 290 | handle->client = GNUNET_CLIENT_connect ("gns", handle->cfg); |
291 | GNUNET_assert (NULL != h->client); | 291 | GNUNET_assert (NULL != handle->client); |
292 | process_pending_messages (h); | 292 | process_pending_messages (handle); |
293 | } | 293 | } |
294 | 294 | ||
295 | 295 | ||
@@ -302,10 +302,10 @@ reconnect (struct GNUNET_GNS_Handle *h) | |||
302 | static void | 302 | static void |
303 | reconnect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 303 | reconnect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
304 | { | 304 | { |
305 | struct GNUNET_GNS_Handle *h = cls; | 305 | struct GNUNET_GNS_Handle *handle = cls; |
306 | 306 | ||
307 | h->reconnect_task = GNUNET_SCHEDULER_NO_TASK; | 307 | handle->reconnect_task = GNUNET_SCHEDULER_NO_TASK; |
308 | reconnect (h); | 308 | reconnect (handle); |
309 | } | 309 | } |
310 | 310 | ||
311 | 311 | ||
@@ -315,50 +315,50 @@ reconnect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
315 | * @param h our handle | 315 | * @param h our handle |
316 | */ | 316 | */ |
317 | static void | 317 | static void |
318 | force_reconnect (struct GNUNET_GNS_Handle *h) | 318 | force_reconnect (struct GNUNET_GNS_Handle *handle) |
319 | { | 319 | { |
320 | struct GNUNET_GNS_ShortenRequest *st; | 320 | struct GNUNET_GNS_ShortenRequest *st; |
321 | struct GNUNET_GNS_LookupRequest *lh; | 321 | struct GNUNET_GNS_LookupRequest *lh; |
322 | struct GNUNET_GNS_GetAuthRequest *ga; | 322 | struct GNUNET_GNS_GetAuthRequest *ga; |
323 | struct PendingMessage *p; | 323 | struct PendingMessage *p; |
324 | 324 | ||
325 | GNUNET_CLIENT_disconnect (h->client); | 325 | GNUNET_CLIENT_disconnect (handle->client); |
326 | h->client = NULL; | 326 | handle->client = NULL; |
327 | h->in_receive = GNUNET_NO; | 327 | handle->in_receive = GNUNET_NO; |
328 | for (st = h->shorten_head; NULL != st; st = st->next) | 328 | for (st = handle->shorten_head; NULL != st; st = st->next) |
329 | { | 329 | { |
330 | p = (struct PendingMessage *) &st[1]; | 330 | p = (struct PendingMessage *) &st[1]; |
331 | if (GNUNET_NO == p->transmitted) | 331 | if (GNUNET_NO == p->transmitted) |
332 | continue; | 332 | continue; |
333 | p->transmitted = GNUNET_NO; | 333 | p->transmitted = GNUNET_NO; |
334 | GNUNET_CONTAINER_DLL_insert (h->pending_head, | 334 | GNUNET_CONTAINER_DLL_insert (handle->pending_head, |
335 | h->pending_tail, | 335 | handle->pending_tail, |
336 | p); | 336 | p); |
337 | } | 337 | } |
338 | for (lh = h->lookup_head; NULL != lh; lh = lh->next) | 338 | for (lh = handle->lookup_head; NULL != lh; lh = lh->next) |
339 | { | 339 | { |
340 | p = (struct PendingMessage *) &lh[1]; | 340 | p = (struct PendingMessage *) &lh[1]; |
341 | if (GNUNET_NO == p->transmitted) | 341 | if (GNUNET_NO == p->transmitted) |
342 | continue; | 342 | continue; |
343 | p->transmitted = GNUNET_NO; | 343 | p->transmitted = GNUNET_NO; |
344 | GNUNET_CONTAINER_DLL_insert (h->pending_head, | 344 | GNUNET_CONTAINER_DLL_insert (handle->pending_head, |
345 | h->pending_tail, | 345 | handle->pending_tail, |
346 | p); | 346 | p); |
347 | } | 347 | } |
348 | for (ga = h->get_auth_head; NULL != ga; ga = ga->next) | 348 | for (ga = handle->get_auth_head; NULL != ga; ga = ga->next) |
349 | { | 349 | { |
350 | p = (struct PendingMessage *) &ga[1]; | 350 | p = (struct PendingMessage *) &ga[1]; |
351 | if (GNUNET_NO == p->transmitted) | 351 | if (GNUNET_NO == p->transmitted) |
352 | continue; | 352 | continue; |
353 | p->transmitted = GNUNET_NO; | 353 | p->transmitted = GNUNET_NO; |
354 | GNUNET_CONTAINER_DLL_insert (h->pending_head, | 354 | GNUNET_CONTAINER_DLL_insert (handle->pending_head, |
355 | h->pending_tail, | 355 | handle->pending_tail, |
356 | p); | 356 | p); |
357 | } | 357 | } |
358 | h->reconnect_backoff = GNUNET_TIME_STD_BACKOFF (h->reconnect_backoff); | 358 | handle->reconnect_backoff = GNUNET_TIME_STD_BACKOFF (handle->reconnect_backoff); |
359 | h->reconnect_task = GNUNET_SCHEDULER_add_delayed (h->reconnect_backoff, | 359 | handle->reconnect_task = GNUNET_SCHEDULER_add_delayed (handle->reconnect_backoff, |
360 | &reconnect_task, | 360 | &reconnect_task, |
361 | h); | 361 | handle); |
362 | } | 362 | } |
363 | 363 | ||
364 | 364 | ||
@@ -428,43 +428,43 @@ process_pending_messages (struct GNUNET_GNS_Handle *handle) | |||
428 | static size_t | 428 | static size_t |
429 | transmit_pending (void *cls, size_t size, void *buf) | 429 | transmit_pending (void *cls, size_t size, void *buf) |
430 | { | 430 | { |
431 | struct GNUNET_GNS_Handle *h = cls; | 431 | struct GNUNET_GNS_Handle *handle = cls; |
432 | char *cbuf = buf; | 432 | char *cbuf = buf; |
433 | struct PendingMessage *p; | 433 | struct PendingMessage *p; |
434 | size_t tsize; | 434 | size_t tsize; |
435 | 435 | ||
436 | h->th = NULL; | 436 | handle->th = NULL; |
437 | if ((0 == size) || (NULL == buf)) | 437 | if ((0 == size) || (NULL == buf)) |
438 | { | 438 | { |
439 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 439 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
440 | "Transmission to GNS service failed!\n"); | 440 | "Transmission to GNS service failed!\n"); |
441 | force_reconnect (h); | 441 | force_reconnect (handle); |
442 | return 0; | 442 | return 0; |
443 | } | 443 | } |
444 | if (NULL == (p = h->pending_head)) | 444 | if (NULL == (p = handle->pending_head)) |
445 | return 0; | 445 | return 0; |
446 | 446 | ||
447 | tsize = 0; | 447 | tsize = 0; |
448 | while ((NULL != (p = h->pending_head)) && (p->size <= size)) | 448 | while ((NULL != (p = handle->pending_head)) && (p->size <= size)) |
449 | { | 449 | { |
450 | memcpy (&cbuf[tsize], &p[1], p->size); | 450 | memcpy (&cbuf[tsize], &p[1], p->size); |
451 | tsize += p->size; | 451 | tsize += p->size; |
452 | size -= p->size; | 452 | size -= p->size; |
453 | p->transmitted = GNUNET_YES; | 453 | p->transmitted = GNUNET_YES; |
454 | GNUNET_CONTAINER_DLL_remove (h->pending_head, | 454 | GNUNET_CONTAINER_DLL_remove (handle->pending_head, |
455 | h->pending_tail, | 455 | handle->pending_tail, |
456 | p); | 456 | p); |
457 | if (GNUNET_YES != h->in_receive) | 457 | if (GNUNET_YES != handle->in_receive) |
458 | { | 458 | { |
459 | GNUNET_CLIENT_receive (h->client, &process_message, h, | 459 | GNUNET_CLIENT_receive (handle->client, &process_message, handle, |
460 | GNUNET_TIME_UNIT_FOREVER_REL); | 460 | GNUNET_TIME_UNIT_FOREVER_REL); |
461 | h->in_receive = GNUNET_YES; | 461 | handle->in_receive = GNUNET_YES; |
462 | } | 462 | } |
463 | } | 463 | } |
464 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 464 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
465 | "Sending %u bytes\n", | 465 | "Sending %u bytes\n", |
466 | (unsigned int) tsize); | 466 | (unsigned int) tsize); |
467 | process_pending_messages (h); | 467 | process_pending_messages (handle); |
468 | return tsize; | 468 | return tsize; |
469 | } | 469 | } |
470 | 470 | ||
@@ -480,7 +480,7 @@ static void | |||
480 | process_shorten_reply (struct GNUNET_GNS_ShortenRequest *qe, | 480 | process_shorten_reply (struct GNUNET_GNS_ShortenRequest *qe, |
481 | const struct GNUNET_GNS_ClientShortenResultMessage *msg) | 481 | const struct GNUNET_GNS_ClientShortenResultMessage *msg) |
482 | { | 482 | { |
483 | struct GNUNET_GNS_Handle *h = qe->gns_handle; | 483 | struct GNUNET_GNS_Handle *handle = qe->gns_handle; |
484 | struct PendingMessage *p = (struct PendingMessage *)&qe[1]; | 484 | struct PendingMessage *p = (struct PendingMessage *)&qe[1]; |
485 | const char *short_name; | 485 | const char *short_name; |
486 | size_t mlen; | 486 | size_t mlen; |
@@ -489,7 +489,7 @@ process_shorten_reply (struct GNUNET_GNS_ShortenRequest *qe, | |||
489 | { | 489 | { |
490 | /* service send reply to query we never managed to send!? */ | 490 | /* service send reply to query we never managed to send!? */ |
491 | GNUNET_break (0); | 491 | GNUNET_break (0); |
492 | force_reconnect (h); | 492 | force_reconnect (handle); |
493 | return; | 493 | return; |
494 | } | 494 | } |
495 | mlen = ntohs (msg->header.size); | 495 | mlen = ntohs (msg->header.size); |
@@ -504,11 +504,11 @@ process_shorten_reply (struct GNUNET_GNS_ShortenRequest *qe, | |||
504 | if ('\0' != short_name[mlen - sizeof (struct GNUNET_GNS_ClientShortenResultMessage) - 1]) | 504 | if ('\0' != short_name[mlen - sizeof (struct GNUNET_GNS_ClientShortenResultMessage) - 1]) |
505 | { | 505 | { |
506 | GNUNET_break (0); | 506 | GNUNET_break (0); |
507 | force_reconnect (h); | 507 | force_reconnect (handle); |
508 | return; | 508 | return; |
509 | } | 509 | } |
510 | } | 510 | } |
511 | GNUNET_CONTAINER_DLL_remove (h->shorten_head, h->shorten_tail, qe); | 511 | GNUNET_CONTAINER_DLL_remove (handle->shorten_head, handle->shorten_tail, qe); |
512 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 512 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
513 | "Received shortened reply `%s' from GNS service\n", | 513 | "Received shortened reply `%s' from GNS service\n", |
514 | short_name); | 514 | short_name); |
@@ -528,7 +528,7 @@ static void | |||
528 | process_get_auth_reply (struct GNUNET_GNS_GetAuthRequest *qe, | 528 | process_get_auth_reply (struct GNUNET_GNS_GetAuthRequest *qe, |
529 | const struct GNUNET_GNS_ClientGetAuthResultMessage *msg) | 529 | const struct GNUNET_GNS_ClientGetAuthResultMessage *msg) |
530 | { | 530 | { |
531 | struct GNUNET_GNS_Handle *h = qe->gns_handle; | 531 | struct GNUNET_GNS_Handle *handle = qe->gns_handle; |
532 | struct PendingMessage *p = (struct PendingMessage *)&qe[1]; | 532 | struct PendingMessage *p = (struct PendingMessage *)&qe[1]; |
533 | const char *auth_name; | 533 | const char *auth_name; |
534 | size_t mlen; | 534 | size_t mlen; |
@@ -537,7 +537,7 @@ process_get_auth_reply (struct GNUNET_GNS_GetAuthRequest *qe, | |||
537 | { | 537 | { |
538 | /* service send reply to query we never managed to send!? */ | 538 | /* service send reply to query we never managed to send!? */ |
539 | GNUNET_break (0); | 539 | GNUNET_break (0); |
540 | force_reconnect (h); | 540 | force_reconnect (handle); |
541 | return; | 541 | return; |
542 | } | 542 | } |
543 | mlen = ntohs (msg->header.size); | 543 | mlen = ntohs (msg->header.size); |
@@ -551,11 +551,11 @@ process_get_auth_reply (struct GNUNET_GNS_GetAuthRequest *qe, | |||
551 | if ('\0' != auth_name[mlen - sizeof (struct GNUNET_GNS_ClientGetAuthResultMessage) - 1]) | 551 | if ('\0' != auth_name[mlen - sizeof (struct GNUNET_GNS_ClientGetAuthResultMessage) - 1]) |
552 | { | 552 | { |
553 | GNUNET_break (0); | 553 | GNUNET_break (0); |
554 | force_reconnect (h); | 554 | force_reconnect (handle); |
555 | return; | 555 | return; |
556 | } | 556 | } |
557 | } | 557 | } |
558 | GNUNET_CONTAINER_DLL_remove (h->get_auth_head, h->get_auth_tail, qe); | 558 | GNUNET_CONTAINER_DLL_remove (handle->get_auth_head, handle->get_auth_tail, qe); |
559 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 559 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
560 | "Received GET_AUTH reply `%s' from GNS service\n", | 560 | "Received GET_AUTH reply `%s' from GNS service\n", |
561 | auth_name); | 561 | auth_name); |
@@ -574,7 +574,7 @@ static void | |||
574 | process_lookup_reply (struct GNUNET_GNS_LookupRequest *qe, | 574 | process_lookup_reply (struct GNUNET_GNS_LookupRequest *qe, |
575 | const struct GNUNET_GNS_ClientLookupResultMessage *msg) | 575 | const struct GNUNET_GNS_ClientLookupResultMessage *msg) |
576 | { | 576 | { |
577 | struct GNUNET_GNS_Handle *h = qe->gns_handle; | 577 | struct GNUNET_GNS_Handle *handle = qe->gns_handle; |
578 | struct PendingMessage *p = (struct PendingMessage *) &qe[1]; | 578 | struct PendingMessage *p = (struct PendingMessage *) &qe[1]; |
579 | uint32_t rd_count = ntohl (msg->rd_count); | 579 | uint32_t rd_count = ntohl (msg->rd_count); |
580 | struct GNUNET_NAMESTORE_RecordData rd[rd_count]; | 580 | struct GNUNET_NAMESTORE_RecordData rd[rd_count]; |
@@ -584,7 +584,7 @@ process_lookup_reply (struct GNUNET_GNS_LookupRequest *qe, | |||
584 | { | 584 | { |
585 | /* service send reply to query we never managed to send!? */ | 585 | /* service send reply to query we never managed to send!? */ |
586 | GNUNET_break (0); | 586 | GNUNET_break (0); |
587 | force_reconnect (h); | 587 | force_reconnect (handle); |
588 | return; | 588 | return; |
589 | } | 589 | } |
590 | mlen = ntohs (msg->header.size); | 590 | mlen = ntohs (msg->header.size); |
@@ -605,7 +605,7 @@ process_lookup_reply (struct GNUNET_GNS_LookupRequest *qe, | |||
605 | (unsigned int) rd_count); | 605 | (unsigned int) rd_count); |
606 | qe->lookup_proc (qe->proc_cls, rd_count, rd); | 606 | qe->lookup_proc (qe->proc_cls, rd_count, rd); |
607 | } | 607 | } |
608 | GNUNET_CONTAINER_DLL_remove (h->lookup_head, h->lookup_tail, qe); | 608 | GNUNET_CONTAINER_DLL_remove (handle->lookup_head, handle->lookup_tail, qe); |
609 | GNUNET_free (qe); | 609 | GNUNET_free (qe); |
610 | } | 610 | } |
611 | 611 | ||