Emptying the queue and using it again... didn't work :-(
Fortunately, no use case in kresd so far could trigger this, I believe:
- struct session::waiting is a list of tasks waiting
while connection is being established
- the temporary queue in session_tasklist_finalize_expired() is also
only once filled and emptied
assert(h && h->end > h->begin);
if (h->end - h->begin == 1) {
/* removing the last element in the chunk */
+ assert((q->len == 1) == (q->head == q->tail));
+ if (q->len == 1) {
+ q->tail = NULL;
+ assert(!h->next);
+ } else {
+ assert(h->next);
+ }
q->head = h->next;
free(h);
} else {
queue_int_t q;
queue_init(q);
+ /* Case of emptying the queue (and using again) has been broken for a long time. */
+ queue_push(q, 2);
+ queue_pop(q);
+ queue_push(q, 4);
+ queue_pop(q);
+
queue_push_head(q, 2);
queue_push_head(q, 1);
queue_push_head(q, 0);