CLEANUP: lists/tree-wide: rename some list operations to avoid some confusion
The current "ADD" vs "ADDQ" is confusing because when thinking in terms
of appending at the end of a list, "ADD" naturally comes to mind, but
here it does the opposite, it inserts. Several times already it's been
incorrectly used where ADDQ was expected, the latest of which was a
fortunate accident explained in 6fa922562 ("CLEANUP: stream: explain
why we queue the stream at the head of the server list").
Let's use more explicit (but slightly longer) names now:
LIST_ADD -> LIST_INSERT
LIST_ADDQ -> LIST_APPEND
LIST_ADDED -> LIST_INLIST
LIST_DEL -> LIST_DELETE
The same is true for MT_LISTs, including their "TRY" variant.
LIST_DEL_INIT keeps its short name to encourage to use it instead of the
lazier LIST_DELETE which is often less safe.
The change is large (~674 non-comment entries) but is mechanical enough
to remain safe. No permutation was performed, so any out-of-tree code
can easily map older names to new ones.
The list doc was updated.
diff --git a/src/check.c b/src/check.c
index e3778ea..ee225a2 100644
--- a/src/check.c
+++ b/src/check.c
@@ -1273,11 +1273,11 @@
{
struct buffer *buf = NULL;
- if (likely(!LIST_ADDED(&check->buf_wait.list)) &&
+ if (likely(!LIST_INLIST(&check->buf_wait.list)) &&
unlikely((buf = b_alloc(bptr)) == NULL)) {
check->buf_wait.target = check;
check->buf_wait.wakeup_cb = check_buf_available;
- LIST_ADDQ(&ti->buffer_wq, &check->buf_wait.list);
+ LIST_APPEND(&ti->buffer_wq, &check->buf_wait.list);
}
return buf;
}
@@ -1701,7 +1701,7 @@
}
chk->action = TCPCHK_ACT_CONNECT;
chk->connect.options = (TCPCHK_OPT_DEFAULT_CONNECT|TCPCHK_OPT_IMPLICIT);
- LIST_ADD(srv->agent.tcpcheck_rules->list, &chk->list);
+ LIST_INSERT(srv->agent.tcpcheck_rules->list, &chk->list);
}
@@ -1874,7 +1874,7 @@
goto error;
}
chk->index = 0;
- LIST_ADDQ(&rs->rules, &chk->list);
+ LIST_APPEND(&rs->rules, &chk->list);
chk = parse_tcpcheck_expect((char *[]){"tcp-check", "expect", "custom", ""},
1, curpx, &rs->rules, TCPCHK_RULES_AGENT_CHK,
@@ -1885,7 +1885,7 @@
}
chk->expect.custom = tcpcheck_agent_expect_reply;
chk->index = 1;
- LIST_ADDQ(&rs->rules, &chk->list);
+ LIST_APPEND(&rs->rules, &chk->list);
ruleset_found:
rules->list = &rs->rules;
@@ -1986,7 +1986,7 @@
var->data.u.str.area = str;
var->data.u.str.data = strlen(str);
LIST_INIT(&var->list);
- LIST_ADDQ(&rules->preset_vars, &var->list);
+ LIST_APPEND(&rules->preset_vars, &var->list);
return 1;