diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-06-20 08:48:01 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-06-20 08:48:01 +0000 |
commit | fe55c2ae5957027fbc7c333889a5f05772e4afea (patch) | |
tree | 84c6e55e2ee3addf8e059246184c2083cbe7afdb /src/core | |
parent | 3150eda34aeb93029691241540047380e9337009 (diff) | |
download | gnunet-fe55c2ae5957027fbc7c333889a5f05772e4afea.tar.gz gnunet-fe55c2ae5957027fbc7c333889a5f05772e4afea.zip |
-fixing #2434, plus some code cleanup
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/core_api.c | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/src/core/core_api.c b/src/core/core_api.c index c377aedc1..6600728eb 100644 --- a/src/core/core_api.c +++ b/src/core/core_api.c | |||
@@ -364,19 +364,19 @@ disconnect_and_free_peer_entry (void *cls, const struct GNUNET_HashCode * key, | |||
364 | struct GNUNET_CORE_TransmitHandle *th; | 364 | struct GNUNET_CORE_TransmitHandle *th; |
365 | struct PeerRecord *pr = value; | 365 | struct PeerRecord *pr = value; |
366 | 366 | ||
367 | if (pr->timeout_task != GNUNET_SCHEDULER_NO_TASK) | 367 | if (GNUNET_SCHEDULER_NO_TASK != pr->timeout_task) |
368 | { | 368 | { |
369 | GNUNET_SCHEDULER_cancel (pr->timeout_task); | 369 | GNUNET_SCHEDULER_cancel (pr->timeout_task); |
370 | pr->timeout_task = GNUNET_SCHEDULER_NO_TASK; | 370 | pr->timeout_task = GNUNET_SCHEDULER_NO_TASK; |
371 | } | 371 | } |
372 | if (pr->ntr_task != GNUNET_SCHEDULER_NO_TASK) | 372 | if (GNUNET_SCHEDULER_NO_TASK != pr->ntr_task) |
373 | { | 373 | { |
374 | GNUNET_SCHEDULER_cancel (pr->ntr_task); | 374 | GNUNET_SCHEDULER_cancel (pr->ntr_task); |
375 | pr->ntr_task = GNUNET_SCHEDULER_NO_TASK; | 375 | pr->ntr_task = GNUNET_SCHEDULER_NO_TASK; |
376 | } | 376 | } |
377 | if ((pr->prev != NULL) || (pr->next != NULL) || (h->ready_peer_head == pr)) | 377 | if ((NULL != pr->prev) || (NULL != pr->next) || (h->ready_peer_head == pr)) |
378 | GNUNET_CONTAINER_DLL_remove (h->ready_peer_head, h->ready_peer_tail, pr); | 378 | GNUNET_CONTAINER_DLL_remove (h->ready_peer_head, h->ready_peer_tail, pr); |
379 | if (h->disconnects != NULL) | 379 | if (NULL != h->disconnects) |
380 | h->disconnects (h->cls, &pr->peer); | 380 | h->disconnects (h->cls, &pr->peer); |
381 | /* all requests should have been cancelled, clean up anyway, just in case */ | 381 | /* all requests should have been cancelled, clean up anyway, just in case */ |
382 | th = &pr->th; | 382 | th = &pr->th; |
@@ -384,15 +384,15 @@ disconnect_and_free_peer_entry (void *cls, const struct GNUNET_HashCode * key, | |||
384 | { | 384 | { |
385 | GNUNET_break (0); | 385 | GNUNET_break (0); |
386 | th->peer = NULL; | 386 | th->peer = NULL; |
387 | if (th->cm != NULL) | 387 | if (NULL != th->cm) |
388 | th->cm->th = NULL; | 388 | th->cm->th = NULL; |
389 | } | 389 | } |
390 | /* done with 'voluntary' cleanups, now on to normal freeing */ | 390 | /* done with 'voluntary' cleanups, now on to normal freeing */ |
391 | GNUNET_assert (GNUNET_YES == | 391 | GNUNET_assert (GNUNET_YES == |
392 | GNUNET_CONTAINER_multihashmap_remove (h->peers, key, pr)); | 392 | GNUNET_CONTAINER_multihashmap_remove (h->peers, key, pr)); |
393 | GNUNET_assert (pr->ch == h); | 393 | GNUNET_assert (pr->ch == h); |
394 | GNUNET_assert (pr->timeout_task == GNUNET_SCHEDULER_NO_TASK); | 394 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == pr->timeout_taks); |
395 | GNUNET_assert (pr->ntr_task == GNUNET_SCHEDULER_NO_TASK); | 395 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == pr->ntr_task); |
396 | GNUNET_free (pr); | 396 | GNUNET_free (pr); |
397 | return GNUNET_YES; | 397 | return GNUNET_YES; |
398 | } | 398 | } |
@@ -410,13 +410,13 @@ reconnect_later (struct GNUNET_CORE_Handle *h) | |||
410 | struct ControlMessage *cm; | 410 | struct ControlMessage *cm; |
411 | struct PeerRecord *pr; | 411 | struct PeerRecord *pr; |
412 | 412 | ||
413 | GNUNET_assert (h->reconnect_task == GNUNET_SCHEDULER_NO_TASK); | 413 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == h->reconnect_task); |
414 | if (NULL != h->cth) | 414 | if (NULL != h->cth) |
415 | { | 415 | { |
416 | GNUNET_CLIENT_notify_transmit_ready_cancel (h->cth); | 416 | GNUNET_CLIENT_notify_transmit_ready_cancel (h->cth); |
417 | h->cth = NULL; | 417 | h->cth = NULL; |
418 | } | 418 | } |
419 | if (h->client != NULL) | 419 | if (NULL != h->client) |
420 | { | 420 | { |
421 | GNUNET_CLIENT_disconnect (h->client); | 421 | GNUNET_CLIENT_disconnect (h->client); |
422 | h->client = NULL; | 422 | h->client = NULL; |
@@ -429,9 +429,9 @@ reconnect_later (struct GNUNET_CORE_Handle *h) | |||
429 | { | 429 | { |
430 | GNUNET_CONTAINER_DLL_remove (h->control_pending_head, | 430 | GNUNET_CONTAINER_DLL_remove (h->control_pending_head, |
431 | h->control_pending_tail, cm); | 431 | h->control_pending_tail, cm); |
432 | if (cm->th != NULL) | 432 | if (NULL != cm->th) |
433 | cm->th->cm = NULL; | 433 | cm->th->cm = NULL; |
434 | if (cm->cont != NULL) | 434 | if (NULL != cm->cont) |
435 | cm->cont (cm->cont_cls, GNUNET_NO); | 435 | cm->cont (cm->cont_cls, GNUNET_NO); |
436 | GNUNET_free (cm); | 436 | GNUNET_free (cm); |
437 | } | 437 | } |
@@ -537,9 +537,14 @@ transmission_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
537 | struct GNUNET_CORE_TransmitHandle *th; | 537 | struct GNUNET_CORE_TransmitHandle *th; |
538 | 538 | ||
539 | pr->timeout_task = GNUNET_SCHEDULER_NO_TASK; | 539 | pr->timeout_task = GNUNET_SCHEDULER_NO_TASK; |
540 | if (GNUNET_SCHEDULER_NO_TASK != pr->ntr_task) | ||
541 | { | ||
542 | GNUNET_SCHEDULER_cancel (pr->ntr_task); | ||
543 | pr->ntr_task = GNUNET_SCHEDULER_NO_TASK; | ||
544 | } | ||
540 | th = &pr->th; | 545 | th = &pr->th; |
541 | th->peer = NULL; | 546 | th->peer = NULL; |
542 | if ((pr->prev != NULL) || (pr->next != NULL) || (pr == h->ready_peer_head)) | 547 | if ((NULL != pr->prev) || (NULL != pr->next) || (pr == h->ready_peer_head)) |
543 | { | 548 | { |
544 | /* the request that was 'approved' by core was | 549 | /* the request that was 'approved' by core was |
545 | * canceled before it could be transmitted; remove | 550 | * canceled before it could be transmitted; remove |
@@ -584,7 +589,7 @@ transmit_message (void *cls, size_t size, void *buf) | |||
584 | 589 | ||
585 | GNUNET_assert (h->reconnect_task == GNUNET_SCHEDULER_NO_TASK); | 590 | GNUNET_assert (h->reconnect_task == GNUNET_SCHEDULER_NO_TASK); |
586 | h->cth = NULL; | 591 | h->cth = NULL; |
587 | if (buf == NULL) | 592 | if (NULL == buf) |
588 | { | 593 | { |
589 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 594 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
590 | "Transmission failed, initiating reconnect\n"); | 595 | "Transmission failed, initiating reconnect\n"); |
@@ -607,7 +612,7 @@ transmit_message (void *cls, size_t size, void *buf) | |||
607 | memcpy (buf, hdr, msize); | 612 | memcpy (buf, hdr, msize); |
608 | GNUNET_CONTAINER_DLL_remove (h->control_pending_head, | 613 | GNUNET_CONTAINER_DLL_remove (h->control_pending_head, |
609 | h->control_pending_tail, cm); | 614 | h->control_pending_tail, cm); |
610 | if (cm->th != NULL) | 615 | if (NULL != cm->th) |
611 | cm->th->cm = NULL; | 616 | cm->th->cm = NULL; |
612 | if (NULL != cm->cont) | 617 | if (NULL != cm->cont) |
613 | cm->cont (cm->cont_cls, GNUNET_OK); | 618 | cm->cont (cm->cont_cls, GNUNET_OK); |
@@ -627,7 +632,7 @@ transmit_message (void *cls, size_t size, void *buf) | |||
627 | } | 632 | } |
628 | GNUNET_CONTAINER_DLL_remove (h->ready_peer_head, h->ready_peer_tail, pr); | 633 | GNUNET_CONTAINER_DLL_remove (h->ready_peer_head, h->ready_peer_tail, pr); |
629 | th->peer = NULL; | 634 | th->peer = NULL; |
630 | if (pr->timeout_task != GNUNET_SCHEDULER_NO_TASK) | 635 | if (GNUNET_SCHEDULER_NO_TASK != pr->timeout_task) |
631 | { | 636 | { |
632 | GNUNET_SCHEDULER_cancel (pr->timeout_task); | 637 | GNUNET_SCHEDULER_cancel (pr->timeout_task); |
633 | pr->timeout_task = GNUNET_SCHEDULER_NO_TASK; | 638 | pr->timeout_task = GNUNET_SCHEDULER_NO_TASK; |
@@ -699,7 +704,7 @@ trigger_next_request (struct GNUNET_CORE_Handle *h, int ignore_currently_down) | |||
699 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Request pending, not processing queue\n"); | 704 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Request pending, not processing queue\n"); |
700 | return; | 705 | return; |
701 | } | 706 | } |
702 | if (h->control_pending_head != NULL) | 707 | if (NULL != h->control_pending_head) |
703 | msize = | 708 | msize = |
704 | ntohs (((struct GNUNET_MessageHeader *) &h-> | 709 | ntohs (((struct GNUNET_MessageHeader *) &h-> |
705 | control_pending_head[1])->size); | 710 | control_pending_head[1])->size); |