aboutsummaryrefslogtreecommitdiff
path: root/src/rps/gnunet-service-rps.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/rps/gnunet-service-rps.c')
-rw-r--r--src/rps/gnunet-service-rps.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c
index e0301af6b..41769ca24 100644
--- a/src/rps/gnunet-service-rps.c
+++ b/src/rps/gnunet-service-rps.c
@@ -701,7 +701,7 @@ get_channel (const struct GNUNET_PeerIdentity *peer)
701 &port, 701 &port,
702 GNUNET_CADET_OPTION_RELIABLE, 702 GNUNET_CADET_OPTION_RELIABLE,
703 NULL, /* WindowSize handler */ 703 NULL, /* WindowSize handler */
704 cleanup_destroyed_channel, /* Disconnect handler */ 704 &cleanup_destroyed_channel, /* Disconnect handler */
705 cadet_handlers); 705 cadet_handlers);
706 } 706 }
707 GNUNET_assert (NULL != peer_ctx->send_channel_ctx); 707 GNUNET_assert (NULL != peer_ctx->send_channel_ctx);
@@ -860,6 +860,7 @@ check_operation_scheduled (const struct GNUNET_PeerIdentity *peer,
860 return GNUNET_NO; 860 return GNUNET_NO;
861} 861}
862 862
863
863/** 864/**
864 * @brief Callback for scheduler to destroy a channel 865 * @brief Callback for scheduler to destroy a channel
865 * 866 *
@@ -869,17 +870,20 @@ static void
869destroy_channel (struct ChannelCtx *channel_ctx) 870destroy_channel (struct ChannelCtx *channel_ctx)
870{ 871{
871 struct PeerContext *peer_ctx = channel_ctx->peer_ctx; 872 struct PeerContext *peer_ctx = channel_ctx->peer_ctx;
872 873 struct GNUNET_CADET_Channel *channel;
874
873 if (NULL != channel_ctx->destruction_task) 875 if (NULL != channel_ctx->destruction_task)
874 { 876 {
875 GNUNET_SCHEDULER_cancel (channel_ctx->destruction_task); 877 GNUNET_SCHEDULER_cancel (channel_ctx->destruction_task);
876 channel_ctx->destruction_task = NULL; 878 channel_ctx->destruction_task = NULL;
877 } 879 }
878 GNUNET_CADET_channel_destroy (channel_ctx->channel); 880 channel = channel_ctx->channel;
879 channel_ctx->channel = NULL; 881 channel_ctx->channel = NULL;
882 GNUNET_CADET_channel_destroy (channel);
880 remove_channel_ctx (channel_ctx); 883 remove_channel_ctx (channel_ctx);
881} 884}
882 885
886
883/** 887/**
884 * @brief Destroy a cadet channel. 888 * @brief Destroy a cadet channel.
885 * 889 *
@@ -891,10 +895,12 @@ static void
891destroy_channel_cb (void *cls) 895destroy_channel_cb (void *cls)
892{ 896{
893 struct ChannelCtx *channel_ctx = cls; 897 struct ChannelCtx *channel_ctx = cls;
898
894 channel_ctx->destruction_task = NULL; 899 channel_ctx->destruction_task = NULL;
895 destroy_channel (channel_ctx); 900 destroy_channel (channel_ctx);
896} 901}
897 902
903
898/** 904/**
899 * @brief Schedule the destruction of a channel for immediately afterwards. 905 * @brief Schedule the destruction of a channel for immediately afterwards.
900 * 906 *
@@ -908,10 +914,16 @@ destroy_channel_cb (void *cls)
908static void 914static void
909schedule_channel_destruction (struct ChannelCtx *channel_ctx) 915schedule_channel_destruction (struct ChannelCtx *channel_ctx)
910{ 916{
917 GNUNET_assert (NULL ==
918 channel_ctx->destruction_task);
919 GNUNET_assert (NULL !=
920 channel_ctx->channel);
911 channel_ctx->destruction_task = 921 channel_ctx->destruction_task =
912 GNUNET_SCHEDULER_add_now (destroy_channel_cb, channel_ctx); 922 GNUNET_SCHEDULER_add_now (&destroy_channel_cb,
923 channel_ctx);
913} 924}
914 925
926
915/** 927/**
916 * @brief Remove peer 928 * @brief Remove peer
917 * 929 *
@@ -2530,7 +2542,7 @@ cleanup_destroyed_channel (void *cls,
2530 // * cleanup everything related to the channel 2542 // * cleanup everything related to the channel
2531 // * memory 2543 // * memory
2532 // * remove peer if necessary 2544 // * remove peer if necessary
2533 2545 channel_ctx->channel = NULL;
2534 if (peer_ctx->recv_channel_ctx == channel_ctx) 2546 if (peer_ctx->recv_channel_ctx == channel_ctx)
2535 { 2547 {
2536 remove_channel_ctx (channel_ctx); 2548 remove_channel_ctx (channel_ctx);