diff options
author | Christian Grothoff <christian@grothoff.org> | 2014-12-24 01:10:47 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2014-12-24 01:10:47 +0000 |
commit | f1f603c7d0b3f03dca46a4f313472288eb080eb1 (patch) | |
tree | 3a29966b02dfb83e0a8a8d5c42b3116380209fb0 /src/cadet/gnunet-service-cadet_channel.c | |
parent | 53cd5b8eda2fa8db86b0907a62a39598981d008a (diff) | |
download | gnunet-f1f603c7d0b3f03dca46a4f313472288eb080eb1.tar.gz gnunet-f1f603c7d0b3f03dca46a4f313472288eb080eb1.zip |
making GNUNET_SCHEDULER_cancel() perform in O(1) instead of O(n) to help or even fully address #3247
Diffstat (limited to 'src/cadet/gnunet-service-cadet_channel.c')
-rw-r--r-- | src/cadet/gnunet-service-cadet_channel.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/cadet/gnunet-service-cadet_channel.c b/src/cadet/gnunet-service-cadet_channel.c index cc9cc699a..bb9fa6060 100644 --- a/src/cadet/gnunet-service-cadet_channel.c +++ b/src/cadet/gnunet-service-cadet_channel.c | |||
@@ -183,7 +183,7 @@ struct CadetChannelReliability | |||
183 | /** | 183 | /** |
184 | * Task to resend/poll in case no ACK is received. | 184 | * Task to resend/poll in case no ACK is received. |
185 | */ | 185 | */ |
186 | GNUNET_SCHEDULER_TaskIdentifier retry_task; | 186 | struct GNUNET_SCHEDULER_Task * retry_task; |
187 | 187 | ||
188 | /** | 188 | /** |
189 | * Counter for exponential backoff. | 189 | * Counter for exponential backoff. |
@@ -729,7 +729,7 @@ channel_retransmit_message (void *cls, | |||
729 | struct GNUNET_CADET_Data *payload; | 729 | struct GNUNET_CADET_Data *payload; |
730 | int fwd; | 730 | int fwd; |
731 | 731 | ||
732 | rel->retry_task = GNUNET_SCHEDULER_NO_TASK; | 732 | rel->retry_task = NULL; |
733 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | 733 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) |
734 | return; | 734 | return; |
735 | 735 | ||
@@ -763,7 +763,7 @@ channel_recreate (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
763 | { | 763 | { |
764 | struct CadetChannelReliability *rel = cls; | 764 | struct CadetChannelReliability *rel = cls; |
765 | 765 | ||
766 | rel->retry_task = GNUNET_SCHEDULER_NO_TASK; | 766 | rel->retry_task = NULL; |
767 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | 767 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) |
768 | return; | 768 | return; |
769 | 769 | ||
@@ -815,7 +815,7 @@ ch_message_sent (void *cls, | |||
815 | GNUNET_assert (chq == copy->chq); | 815 | GNUNET_assert (chq == copy->chq); |
816 | copy->timestamp = GNUNET_TIME_absolute_get (); | 816 | copy->timestamp = GNUNET_TIME_absolute_get (); |
817 | rel = copy->rel; | 817 | rel = copy->rel; |
818 | if (GNUNET_SCHEDULER_NO_TASK == rel->retry_task) | 818 | if (NULL == rel->retry_task) |
819 | { | 819 | { |
820 | LOG (GNUNET_ERROR_TYPE_DEBUG, "!! scheduling retry in 4 * %s\n", | 820 | LOG (GNUNET_ERROR_TYPE_DEBUG, "!! scheduling retry in 4 * %s\n", |
821 | GNUNET_STRINGS_relative_time_to_string (rel->expected_delay, | 821 | GNUNET_STRINGS_relative_time_to_string (rel->expected_delay, |
@@ -859,7 +859,7 @@ ch_message_sent (void *cls, | |||
859 | && GNUNET_MESSAGE_TYPE_CADET_DATA_ACK != type | 859 | && GNUNET_MESSAGE_TYPE_CADET_DATA_ACK != type |
860 | && GNUNET_NO == rel->ch->destroy) | 860 | && GNUNET_NO == rel->ch->destroy) |
861 | { | 861 | { |
862 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == rel->retry_task); | 862 | GNUNET_assert (NULL == rel->retry_task); |
863 | LOG (GNUNET_ERROR_TYPE_DEBUG, "!!! STD BACKOFF %s\n", | 863 | LOG (GNUNET_ERROR_TYPE_DEBUG, "!!! STD BACKOFF %s\n", |
864 | GNUNET_STRINGS_relative_time_to_string (rel->retry_timer, | 864 | GNUNET_STRINGS_relative_time_to_string (rel->retry_timer, |
865 | GNUNET_NO)); | 865 | GNUNET_NO)); |
@@ -1006,10 +1006,10 @@ channel_rel_free_all (struct CadetChannelReliability *rel) | |||
1006 | GCT_cancel (rel->uniq->tq); | 1006 | GCT_cancel (rel->uniq->tq); |
1007 | /* ch_message_sent is called freeing uniq */ | 1007 | /* ch_message_sent is called freeing uniq */ |
1008 | } | 1008 | } |
1009 | if (GNUNET_SCHEDULER_NO_TASK != rel->retry_task) | 1009 | if (NULL != rel->retry_task) |
1010 | { | 1010 | { |
1011 | GNUNET_SCHEDULER_cancel (rel->retry_task); | 1011 | GNUNET_SCHEDULER_cancel (rel->retry_task); |
1012 | rel->retry_task = GNUNET_SCHEDULER_NO_TASK; | 1012 | rel->retry_task = NULL; |
1013 | } | 1013 | } |
1014 | GNUNET_free (rel); | 1014 | GNUNET_free (rel); |
1015 | } | 1015 | } |
@@ -1174,10 +1174,10 @@ channel_confirm (struct CadetChannel *ch, int fwd) | |||
1174 | if (GCT_get_connections_buffer (ch->t) > 0 || GCT_is_loopback (ch->t)) | 1174 | if (GCT_get_connections_buffer (ch->t) > 0 || GCT_is_loopback (ch->t)) |
1175 | send_client_ack (ch, fwd); | 1175 | send_client_ack (ch, fwd); |
1176 | 1176 | ||
1177 | if (GNUNET_SCHEDULER_NO_TASK != rel->retry_task) | 1177 | if (NULL != rel->retry_task) |
1178 | { | 1178 | { |
1179 | GNUNET_SCHEDULER_cancel (rel->retry_task); | 1179 | GNUNET_SCHEDULER_cancel (rel->retry_task); |
1180 | rel->retry_task = GNUNET_SCHEDULER_NO_TASK; | 1180 | rel->retry_task = NULL; |
1181 | } | 1181 | } |
1182 | else if (NULL != rel->uniq) | 1182 | else if (NULL != rel->uniq) |
1183 | { | 1183 | { |
@@ -2079,10 +2079,10 @@ GCCH_handle_data_ack (struct CadetChannel *ch, | |||
2079 | /* If some message was free'd, update the retransmission delay */ | 2079 | /* If some message was free'd, update the retransmission delay */ |
2080 | if (GNUNET_YES == work) | 2080 | if (GNUNET_YES == work) |
2081 | { | 2081 | { |
2082 | if (GNUNET_SCHEDULER_NO_TASK != rel->retry_task) | 2082 | if (NULL != rel->retry_task) |
2083 | { | 2083 | { |
2084 | GNUNET_SCHEDULER_cancel (rel->retry_task); | 2084 | GNUNET_SCHEDULER_cancel (rel->retry_task); |
2085 | rel->retry_task = GNUNET_SCHEDULER_NO_TASK; | 2085 | rel->retry_task = NULL; |
2086 | if (NULL != rel->head_sent && NULL == rel->head_sent->chq) | 2086 | if (NULL != rel->head_sent && NULL == rel->head_sent->chq) |
2087 | { | 2087 | { |
2088 | struct GNUNET_TIME_Absolute new_target; | 2088 | struct GNUNET_TIME_Absolute new_target; |
@@ -2179,12 +2179,12 @@ GCCH_handle_create (struct CadetTunnel *t, | |||
2179 | else | 2179 | else |
2180 | { | 2180 | { |
2181 | LOG (GNUNET_ERROR_TYPE_DEBUG, " duplicate create channel\n"); | 2181 | LOG (GNUNET_ERROR_TYPE_DEBUG, " duplicate create channel\n"); |
2182 | if (GNUNET_SCHEDULER_NO_TASK != ch->dest_rel->retry_task) | 2182 | if (NULL != ch->dest_rel->retry_task) |
2183 | { | 2183 | { |
2184 | LOG (GNUNET_ERROR_TYPE_DEBUG, " clearing retry task\n"); | 2184 | LOG (GNUNET_ERROR_TYPE_DEBUG, " clearing retry task\n"); |
2185 | /* we were waiting to re-send our 'SYNACK', wait no more! */ | 2185 | /* we were waiting to re-send our 'SYNACK', wait no more! */ |
2186 | GNUNET_SCHEDULER_cancel (ch->dest_rel->retry_task); | 2186 | GNUNET_SCHEDULER_cancel (ch->dest_rel->retry_task); |
2187 | ch->dest_rel->retry_task = GNUNET_SCHEDULER_NO_TASK; | 2187 | ch->dest_rel->retry_task = NULL; |
2188 | } | 2188 | } |
2189 | else if (NULL != ch->dest_rel->uniq) | 2189 | else if (NULL != ch->dest_rel->uniq) |
2190 | { | 2190 | { |