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/mailers.c b/src/mailers.c
index e614cf0..80dc7d6 100644
--- a/src/mailers.c
+++ b/src/mailers.c
@@ -46,7 +46,7 @@
if (alert->rules.list) {
list_for_each_entry_safe(rule, back, alert->rules.list, list) {
- LIST_DEL(&rule->list);
+ LIST_DELETE(&rule->list);
free_tcpcheck(rule, 1);
}
free_tcpcheck_vars(&alert->rules.preset_vars);
@@ -74,7 +74,7 @@
}
alert = LIST_NEXT(&q->email_alerts, typeof(alert), list);
- LIST_DEL(&alert->list);
+ LIST_DELETE(&alert->list);
t->expire = now_ms;
check->tcpcheck_rules = &alert->rules;
check->status = HCHK_STATUS_INI;
@@ -189,7 +189,7 @@
tcpcheck->action = TCPCHK_ACT_CONNECT;
tcpcheck->comment = NULL;
- LIST_ADDQ(alert->rules.list, &tcpcheck->list);
+ LIST_APPEND(alert->rules.list, &tcpcheck->list);
if (!add_tcpcheck_expect_str(&alert->rules, "220 "))
goto error;
@@ -269,7 +269,7 @@
HA_SPIN_LOCK(EMAIL_ALERTS_LOCK, &q->lock);
task_wakeup(check->task, TASK_WOKEN_MSG);
- LIST_ADDQ(&q->email_alerts, &alert->list);
+ LIST_APPEND(&q->email_alerts, &alert->list);
HA_SPIN_UNLOCK(EMAIL_ALERTS_LOCK, &q->lock);
return 1;