diff options
author | Christian Grothoff <christian@grothoff.org> | 2022-04-25 09:14:32 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2022-04-25 09:15:32 +0200 |
commit | 9ec614c2a79e429d0ac95e54e1abd860dd29e92b (patch) | |
tree | 257ec989ee31e30d6ac8da55fd6cb35c7c7aaf18 /src/util | |
parent | 01a4c78d4bd00e45de6f22eba7102947ac11786a (diff) | |
download | gnunet-9ec614c2a79e429d0ac95e54e1abd860dd29e92b.tar.gz gnunet-9ec614c2a79e429d0ac95e54e1abd860dd29e92b.zip |
-simplify mq
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/mq.c | 34 |
1 files changed, 11 insertions, 23 deletions
diff --git a/src/util/mq.c b/src/util/mq.c index 40ac97bbe..0d0ac3fc3 100644 --- a/src/util/mq.c +++ b/src/util/mq.c | |||
@@ -176,15 +176,9 @@ struct GNUNET_MQ_Handle | |||
176 | unsigned int queue_length; | 176 | unsigned int queue_length; |
177 | 177 | ||
178 | /** | 178 | /** |
179 | * #GNUNET_YES if GNUNET_MQ_impl_evacuate was called. | 179 | * True if GNUNET_MQ_impl_send_in_flight() was called. |
180 | * FIXME: is this dead? | ||
181 | */ | 180 | */ |
182 | int evacuate_called; | 181 | bool in_flight; |
183 | |||
184 | /** | ||
185 | * #GNUNET_YES if GNUNET_MQ_impl_send_in_flight() was called. | ||
186 | */ | ||
187 | int in_flight; | ||
188 | }; | 182 | }; |
189 | 183 | ||
190 | 184 | ||
@@ -273,7 +267,7 @@ GNUNET_MQ_handle_message (const struct GNUNET_MQ_MessageHandler *handlers, | |||
273 | break; | 267 | break; |
274 | } | 268 | } |
275 | } | 269 | } |
276 | done: | 270 | done: |
277 | if (GNUNET_NO == handled) | 271 | if (GNUNET_NO == handled) |
278 | { | 272 | { |
279 | LOG (GNUNET_ERROR_TYPE_INFO, | 273 | LOG (GNUNET_ERROR_TYPE_INFO, |
@@ -336,7 +330,7 @@ GNUNET_MQ_discard (struct GNUNET_MQ_Envelope *ev) | |||
336 | unsigned int | 330 | unsigned int |
337 | GNUNET_MQ_get_length (struct GNUNET_MQ_Handle *mq) | 331 | GNUNET_MQ_get_length (struct GNUNET_MQ_Handle *mq) |
338 | { | 332 | { |
339 | if (GNUNET_YES != mq->in_flight) | 333 | if (! mq->in_flight) |
340 | { | 334 | { |
341 | return mq->queue_length; | 335 | return mq->queue_length; |
342 | } | 336 | } |
@@ -506,7 +500,7 @@ GNUNET_MQ_impl_send_continue (struct GNUNET_MQ_Handle *mq) | |||
506 | 500 | ||
507 | GNUNET_assert (0 < mq->queue_length); | 501 | GNUNET_assert (0 < mq->queue_length); |
508 | mq->queue_length--; | 502 | mq->queue_length--; |
509 | mq->in_flight = GNUNET_NO; | 503 | mq->in_flight = false; |
510 | current_envelope = mq->current_envelope; | 504 | current_envelope = mq->current_envelope; |
511 | current_envelope->parent_queue = NULL; | 505 | current_envelope->parent_queue = NULL; |
512 | mq->current_envelope = NULL; | 506 | mq->current_envelope = NULL; |
@@ -537,7 +531,7 @@ GNUNET_MQ_impl_send_in_flight (struct GNUNET_MQ_Handle *mq) | |||
537 | struct GNUNET_MQ_Envelope *current_envelope; | 531 | struct GNUNET_MQ_Envelope *current_envelope; |
538 | GNUNET_SCHEDULER_TaskCallback cb; | 532 | GNUNET_SCHEDULER_TaskCallback cb; |
539 | 533 | ||
540 | mq->in_flight = GNUNET_YES; | 534 | mq->in_flight = true; |
541 | /* call is only valid if we're actually currently sending | 535 | /* call is only valid if we're actually currently sending |
542 | * a message */ | 536 | * a message */ |
543 | current_envelope = mq->current_envelope; | 537 | current_envelope = mq->current_envelope; |
@@ -938,13 +932,11 @@ GNUNET_MQ_send_cancel (struct GNUNET_MQ_Envelope *ev) | |||
938 | GNUNET_assert (NULL != mq); | 932 | GNUNET_assert (NULL != mq); |
939 | GNUNET_assert (NULL != mq->cancel_impl); | 933 | GNUNET_assert (NULL != mq->cancel_impl); |
940 | 934 | ||
941 | mq->evacuate_called = GNUNET_NO; | ||
942 | |||
943 | if (mq->current_envelope == ev) | 935 | if (mq->current_envelope == ev) |
944 | { | 936 | { |
945 | /* complex case, we already started with transmitting | 937 | /* complex case, we already started with transmitting |
946 | the message using the callbacks. */ | 938 | the message using the callbacks. */ |
947 | GNUNET_assert (GNUNET_NO == mq->in_flight); | 939 | GNUNET_assert (! mq->in_flight); |
948 | GNUNET_assert (0 < mq->queue_length); | 940 | GNUNET_assert (0 < mq->queue_length); |
949 | mq->queue_length--; | 941 | mq->queue_length--; |
950 | mq->cancel_impl (mq, | 942 | mq->cancel_impl (mq, |
@@ -974,14 +966,10 @@ GNUNET_MQ_send_cancel (struct GNUNET_MQ_Envelope *ev) | |||
974 | GNUNET_assert (0 < mq->queue_length); | 966 | GNUNET_assert (0 < mq->queue_length); |
975 | mq->queue_length--; | 967 | mq->queue_length--; |
976 | } | 968 | } |
977 | 969 | ev->parent_queue = NULL; | |
978 | if (GNUNET_YES != mq->evacuate_called) | 970 | ev->mh = NULL; |
979 | { | 971 | /* also frees ev */ |
980 | ev->parent_queue = NULL; | 972 | GNUNET_free (ev); |
981 | ev->mh = NULL; | ||
982 | /* also frees ev */ | ||
983 | GNUNET_free (ev); | ||
984 | } | ||
985 | } | 973 | } |
986 | 974 | ||
987 | 975 | ||