aboutsummaryrefslogtreecommitdiff
path: root/src/cadet/gnunet-service-cadet_tunnel.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cadet/gnunet-service-cadet_tunnel.c')
-rw-r--r--src/cadet/gnunet-service-cadet_tunnel.c70
1 files changed, 22 insertions, 48 deletions
diff --git a/src/cadet/gnunet-service-cadet_tunnel.c b/src/cadet/gnunet-service-cadet_tunnel.c
index 73bd28643..b9f0e1fa2 100644
--- a/src/cadet/gnunet-service-cadet_tunnel.c
+++ b/src/cadet/gnunet-service-cadet_tunnel.c
@@ -1735,16 +1735,8 @@ static void
1735finish_kx (void *cls) 1735finish_kx (void *cls)
1736{ 1736{
1737 struct CadetTunnel *t = cls; 1737 struct CadetTunnel *t = cls;
1738 const struct GNUNET_SCHEDULER_TaskContext *tc;
1739 1738
1740 LOG (GNUNET_ERROR_TYPE_INFO, "finish KX for %s\n", GCT_2s (t)); 1739 LOG (GNUNET_ERROR_TYPE_INFO, "finish KX for %s\n", GCT_2s (t));
1741 tc = GNUNET_SCHEDULER_get_task_context ();
1742 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
1743 {
1744 LOG (GNUNET_ERROR_TYPE_INFO, " shutdown\n");
1745 return;
1746 }
1747
1748 GNUNET_free (t->kx_ctx); 1740 GNUNET_free (t->kx_ctx);
1749 t->kx_ctx = NULL; 1741 t->kx_ctx = NULL;
1750} 1742}
@@ -1767,14 +1759,15 @@ destroy_kx_ctx (struct CadetTunnel *t)
1767 1759
1768 if (is_key_null (&t->kx_ctx->e_key_old)) 1760 if (is_key_null (&t->kx_ctx->e_key_old))
1769 { 1761 {
1770 t->kx_ctx->finish_task = GNUNET_SCHEDULER_add_now (finish_kx, t); 1762 t->kx_ctx->finish_task = GNUNET_SCHEDULER_add_now (&finish_kx, t);
1771 return; 1763 return;
1772 } 1764 }
1773 1765
1774 delay = GNUNET_TIME_relative_divide (rekey_period, 4); 1766 delay = GNUNET_TIME_relative_divide (rekey_period, 4);
1775 delay = GNUNET_TIME_relative_min (delay, GNUNET_TIME_UNIT_MINUTES); 1767 delay = GNUNET_TIME_relative_min (delay, GNUNET_TIME_UNIT_MINUTES);
1776 1768
1777 t->kx_ctx->finish_task = GNUNET_SCHEDULER_add_delayed (delay, finish_kx, t); 1769 t->kx_ctx->finish_task = GNUNET_SCHEDULER_add_delayed (delay,
1770 &finish_kx, t);
1778} 1771}
1779 1772
1780 1773
@@ -2103,13 +2096,8 @@ static void
2103ax_kx_resend (void *cls) 2096ax_kx_resend (void *cls)
2104{ 2097{
2105 struct CadetTunnel *t = cls; 2098 struct CadetTunnel *t = cls;
2106 const struct GNUNET_SCHEDULER_TaskContext *tc;
2107 2099
2108 t->rekey_task = NULL; 2100 t->rekey_task = NULL;
2109 tc = GNUNET_SCHEDULER_get_task_context ();
2110 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
2111 return;
2112
2113 if (CADET_TUNNEL_KEY_OK == t->estate) 2101 if (CADET_TUNNEL_KEY_OK == t->estate)
2114 { 2102 {
2115 /* Should have been canceled on estate change */ 2103 /* Should have been canceled on estate change */
@@ -2333,14 +2321,9 @@ static void
2333rekey_tunnel (void *cls) 2321rekey_tunnel (void *cls)
2334{ 2322{
2335 struct CadetTunnel *t = cls; 2323 struct CadetTunnel *t = cls;
2336 const struct GNUNET_SCHEDULER_TaskContext *tc;
2337 2324
2338 t->rekey_task = NULL; 2325 t->rekey_task = NULL;
2339 LOG (GNUNET_ERROR_TYPE_INFO, "Re-key Tunnel %s\n", GCT_2s (t)); 2326 LOG (GNUNET_ERROR_TYPE_INFO, "Re-key Tunnel %s\n", GCT_2s (t));
2340 tc = GNUNET_SCHEDULER_get_task_context ();
2341 if (NULL != tc && 0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason))
2342 return;
2343
2344 GNUNET_assert (NULL != t->kx_ctx); 2327 GNUNET_assert (NULL != t->kx_ctx);
2345 struct GNUNET_TIME_Relative duration; 2328 struct GNUNET_TIME_Relative duration;
2346 2329
@@ -2453,13 +2436,8 @@ global_otr_rekey (void *cls)
2453{ 2436{
2454 struct GNUNET_TIME_Absolute time; 2437 struct GNUNET_TIME_Absolute time;
2455 long n; 2438 long n;
2456 const struct GNUNET_SCHEDULER_TaskContext *tc;
2457 2439
2458 rekey_task = NULL; 2440 rekey_task = NULL;
2459 tc = GNUNET_SCHEDULER_get_task_context ();
2460 if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason))
2461 return;
2462
2463 GNUNET_free_non_null (otr_ephemeral_key); 2441 GNUNET_free_non_null (otr_ephemeral_key);
2464 otr_ephemeral_key = GNUNET_CRYPTO_ecdhe_key_create (); 2442 otr_ephemeral_key = GNUNET_CRYPTO_ecdhe_key_create ();
2465 2443
@@ -2501,7 +2479,8 @@ destroy_iterator (void *cls,
2501{ 2479{
2502 struct CadetTunnel *t = value; 2480 struct CadetTunnel *t = value;
2503 2481
2504 LOG (GNUNET_ERROR_TYPE_DEBUG, "GCT_shutdown destroying tunnel at %p\n", t); 2482 LOG (GNUNET_ERROR_TYPE_DEBUG,
2483 "GCT_shutdown destroying tunnel at %p\n", t);
2505 GCT_destroy (t); 2484 GCT_destroy (t);
2506 return GNUNET_YES; 2485 return GNUNET_YES;
2507} 2486}
@@ -3472,13 +3451,8 @@ static void
3472trim_connections (void *cls) 3451trim_connections (void *cls)
3473{ 3452{
3474 struct CadetTunnel *t = cls; 3453 struct CadetTunnel *t = cls;
3475 const struct GNUNET_SCHEDULER_TaskContext *tc;
3476 3454
3477 t->trim_connections_task = NULL; 3455 t->trim_connections_task = NULL;
3478 tc = GNUNET_SCHEDULER_get_task_context ();
3479 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
3480 return;
3481
3482 if (GCT_count_connections (t) > 2 * CONNECTIONS_PER_TUNNEL) 3456 if (GCT_count_connections (t) > 2 * CONNECTIONS_PER_TUNNEL)
3483 { 3457 {
3484 struct CadetTConnection *iter; 3458 struct CadetTConnection *iter;
@@ -3624,8 +3598,11 @@ GCT_add_channel (struct CadetTunnel *t, struct CadetChannel *ch)
3624 3598
3625 aux = GNUNET_new (struct CadetTChannel); 3599 aux = GNUNET_new (struct CadetTChannel);
3626 aux->ch = ch; 3600 aux->ch = ch;
3627 LOG (GNUNET_ERROR_TYPE_DEBUG, " adding %p to %p\n", aux, t->channel_head); 3601 LOG (GNUNET_ERROR_TYPE_DEBUG,
3628 GNUNET_CONTAINER_DLL_insert_tail (t->channel_head, t->channel_tail, aux); 3602 " adding %p to %p\n", aux, t->channel_head);
3603 GNUNET_CONTAINER_DLL_insert_tail (t->channel_head,
3604 t->channel_tail,
3605 aux);
3629 3606
3630 if (NULL != t->destroy_task) 3607 if (NULL != t->destroy_task)
3631 { 3608 {
@@ -3653,7 +3630,9 @@ GCT_remove_channel (struct CadetTunnel *t, struct CadetChannel *ch)
3653 if (aux->ch == ch) 3630 if (aux->ch == ch)
3654 { 3631 {
3655 LOG (GNUNET_ERROR_TYPE_DEBUG, " found! %s\n", GCCH_2s (ch)); 3632 LOG (GNUNET_ERROR_TYPE_DEBUG, " found! %s\n", GCCH_2s (ch));
3656 GNUNET_CONTAINER_DLL_remove (t->channel_head, t->channel_tail, aux); 3633 GNUNET_CONTAINER_DLL_remove (t->channel_head,
3634 t->channel_tail,
3635 aux);
3657 GNUNET_free (aux); 3636 GNUNET_free (aux);
3658 return; 3637 return;
3659 } 3638 }
@@ -3701,20 +3680,12 @@ delayed_destroy (void *cls)
3701{ 3680{
3702 struct CadetTunnel *t = cls; 3681 struct CadetTunnel *t = cls;
3703 struct CadetTConnection *iter; 3682 struct CadetTConnection *iter;
3704 const struct GNUNET_SCHEDULER_TaskContext *tc;
3705 3683
3706 LOG (GNUNET_ERROR_TYPE_DEBUG, "delayed destroying tunnel %p\n", t);
3707 tc = GNUNET_SCHEDULER_get_task_context ();
3708 if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason))
3709 {
3710 LOG (GNUNET_ERROR_TYPE_WARNING,
3711 "Not destroying tunnel, due to shutdown. "
3712 "Tunnel at %p should have been freed by GCT_shutdown\n", t);
3713 return;
3714 }
3715 t->destroy_task = NULL; 3684 t->destroy_task = NULL;
3685 LOG (GNUNET_ERROR_TYPE_DEBUG,
3686 "delayed destroying tunnel %p\n",
3687 t);
3716 t->cstate = CADET_TUNNEL_SHUTDOWN; 3688 t->cstate = CADET_TUNNEL_SHUTDOWN;
3717
3718 for (iter = t->connection_head; NULL != iter; iter = iter->next) 3689 for (iter = t->connection_head; NULL != iter; iter = iter->next)
3719 { 3690 {
3720 GCC_send_destroy (iter->c); 3691 GCC_send_destroy (iter->c);
@@ -3800,8 +3771,9 @@ GCT_destroy (struct CadetTunnel *t)
3800 if (NULL == t) 3771 if (NULL == t)
3801 return; 3772 return;
3802 3773
3803 LOG (GNUNET_ERROR_TYPE_DEBUG, "destroying tunnel %s\n", GCP_2s (t->peer)); 3774 LOG (GNUNET_ERROR_TYPE_DEBUG,
3804 3775 "destroying tunnel %s\n",
3776 GCP_2s (t->peer));
3805 GNUNET_break (GNUNET_YES == 3777 GNUNET_break (GNUNET_YES ==
3806 GNUNET_CONTAINER_multipeermap_remove (tunnels, 3778 GNUNET_CONTAINER_multipeermap_remove (tunnels,
3807 GCP_get_id (t->peer), t)); 3779 GCP_get_id (t->peer), t));
@@ -3850,7 +3822,9 @@ GCT_destroy (struct CadetTunnel *t)
3850 3822
3851 if (NULL != t->destroy_task) 3823 if (NULL != t->destroy_task)
3852 { 3824 {
3853 LOG (GNUNET_ERROR_TYPE_DEBUG, "cancelling dest: %p\n", t->destroy_task); 3825 LOG (GNUNET_ERROR_TYPE_DEBUG,
3826 "cancelling dest: %p\n",
3827 t->destroy_task);
3854 GNUNET_SCHEDULER_cancel (t->destroy_task); 3828 GNUNET_SCHEDULER_cancel (t->destroy_task);
3855 t->destroy_task = NULL; 3829 t->destroy_task = NULL;
3856 } 3830 }