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/flt_spoe.c b/src/flt_spoe.c
index ce55483..7749cc9 100644
--- a/src/flt_spoe.c
+++ b/src/flt_spoe.c
@@ -128,11 +128,11 @@
list_for_each_entry_safe(arg, argback, &msg->args, list) {
release_sample_expr(arg->expr);
free(arg->name);
- LIST_DEL(&arg->list);
+ LIST_DELETE(&arg->list);
free(arg);
}
list_for_each_entry_safe(acl, aclback, &msg->acls, list) {
- LIST_DEL(&acl->list);
+ LIST_DELETE(&acl->list);
prune_acl(acl);
free(acl);
}
@@ -169,11 +169,11 @@
free(agent->var_t_process);
free(agent->var_t_total);
list_for_each_entry_safe(msg, msgback, &agent->messages, list) {
- LIST_DEL(&msg->list);
+ LIST_DELETE(&msg->list);
spoe_release_message(msg);
}
list_for_each_entry_safe(grp, grpback, &agent->groups, list) {
- LIST_DEL(&grp->list);
+ LIST_DELETE(&grp->list);
spoe_release_group(grp);
}
if (agent->rt) {
@@ -1233,7 +1233,7 @@
_HA_ATOMIC_DEC(&agent->counters.applets);
HA_SPIN_LOCK(SPOE_APPLET_LOCK, &agent->rt[tid].lock);
if (!LIST_ISEMPTY(&spoe_appctx->list)) {
- LIST_DEL(&spoe_appctx->list);
+ LIST_DELETE(&spoe_appctx->list);
LIST_INIT(&spoe_appctx->list);
}
HA_SPIN_UNLOCK(SPOE_APPLET_LOCK, &agent->rt[tid].lock);
@@ -1259,7 +1259,7 @@
/* Notify all waiting streams */
list_for_each_entry_safe(ctx, back, &spoe_appctx->waiting_queue, list) {
- LIST_DEL(&ctx->list);
+ LIST_DELETE(&ctx->list);
LIST_INIT(&ctx->list);
_HA_ATOMIC_DEC(&agent->counters.nb_waiting);
spoe_update_stat_time(&ctx->stats.tv_wait, &ctx->stats.t_waiting);
@@ -1289,7 +1289,7 @@
/* If this was the last running applet, notify all waiting streams */
list_for_each_entry_safe(ctx, back, &agent->rt[tid].sending_queue, list) {
- LIST_DEL(&ctx->list);
+ LIST_DELETE(&ctx->list);
LIST_INIT(&ctx->list);
_HA_ATOMIC_DEC(&agent->counters.nb_sending);
spoe_update_stat_time(&ctx->stats.tv_queue, &ctx->stats.t_queue);
@@ -1299,7 +1299,7 @@
task_wakeup(ctx->strm->task, TASK_WOKEN_MSG);
}
list_for_each_entry_safe(ctx, back, &agent->rt[tid].waiting_queue, list) {
- LIST_DEL(&ctx->list);
+ LIST_DELETE(&ctx->list);
LIST_INIT(&ctx->list);
_HA_ATOMIC_DEC(&agent->counters.nb_waiting);
spoe_update_stat_time(&ctx->stats.tv_wait, &ctx->stats.t_waiting);
@@ -1500,7 +1500,7 @@
goto abort_frag_frame;
spoe_release_buffer(&ctx->buffer, &ctx->buffer_wait);
- LIST_DEL(&ctx->list);
+ LIST_DELETE(&ctx->list);
LIST_INIT(&ctx->list);
_HA_ATOMIC_DEC(&agent->counters.nb_sending);
spoe_update_stat_time(&ctx->stats.tv_queue, &ctx->stats.t_queue);
@@ -1520,7 +1520,7 @@
goto abort_frag_frame;
spoe_release_buffer(&ctx->buffer, &ctx->buffer_wait);
- LIST_DEL(&ctx->list);
+ LIST_DELETE(&ctx->list);
LIST_INIT(&ctx->list);
_HA_ATOMIC_DEC(&agent->counters.nb_sending);
spoe_update_stat_time(&ctx->stats.tv_queue, &ctx->stats.t_queue);
@@ -1546,16 +1546,16 @@
no_frag_frame_sent:
if (SPOE_APPCTX(appctx)->flags & SPOE_APPCTX_FL_ASYNC) {
appctx->st0 = SPOE_APPCTX_ST_PROCESSING;
- LIST_ADDQ(&agent->rt[tid].waiting_queue, &ctx->list);
+ LIST_APPEND(&agent->rt[tid].waiting_queue, &ctx->list);
}
else if (SPOE_APPCTX(appctx)->flags & SPOE_APPCTX_FL_PIPELINING) {
appctx->st0 = SPOE_APPCTX_ST_PROCESSING;
- LIST_ADDQ(&SPOE_APPCTX(appctx)->waiting_queue, &ctx->list);
+ LIST_APPEND(&SPOE_APPCTX(appctx)->waiting_queue, &ctx->list);
}
else {
appctx->st0 = SPOE_APPCTX_ST_WAITING_SYNC_ACK;
*skip = 1;
- LIST_ADDQ(&SPOE_APPCTX(appctx)->waiting_queue, &ctx->list);
+ LIST_APPEND(&SPOE_APPCTX(appctx)->waiting_queue, &ctx->list);
}
_HA_ATOMIC_INC(&agent->counters.nb_waiting);
ctx->stats.tv_wait = now;
@@ -1611,7 +1611,7 @@
break;
default:
- LIST_DEL(&ctx->list);
+ LIST_DELETE(&ctx->list);
LIST_INIT(&ctx->list);
_HA_ATOMIC_DEC(&agent->counters.nb_waiting);
spoe_update_stat_time(&ctx->stats.tv_wait, &ctx->stats.t_waiting);
@@ -2008,7 +2008,7 @@
strm->res.flags |= CF_READ_DONTWAIT;
HA_SPIN_LOCK(SPOE_APPLET_LOCK, &conf->agent->rt[tid].lock);
- LIST_ADDQ(&conf->agent->rt[tid].applets, &SPOE_APPCTX(appctx)->list);
+ LIST_APPEND(&conf->agent->rt[tid].applets, &SPOE_APPCTX(appctx)->list);
HA_SPIN_UNLOCK(SPOE_APPLET_LOCK, &conf->agent->rt[tid].lock);
_HA_ATOMIC_INC(&conf->agent->counters.applets);
@@ -2101,7 +2101,7 @@
ctx->stats.tv_queue = now;
if (ctx->spoe_appctx)
return 1;
- LIST_ADDQ(&agent->rt[tid].sending_queue, &ctx->list);
+ LIST_APPEND(&agent->rt[tid].sending_queue, &ctx->list);
SPOE_PRINTF(stderr, "%d.%06d [SPOE/%-15s] %s: stream=%p"
" - Add stream in sending queue"
@@ -2624,7 +2624,7 @@
else
_HA_ATOMIC_DEC(&agent->counters.nb_waiting);
- LIST_DEL(&ctx->list);
+ LIST_DELETE(&ctx->list);
LIST_INIT(&ctx->list);
}
}
@@ -2833,20 +2833,20 @@
if (buf->size)
return 1;
- if (LIST_ADDED(&buffer_wait->list))
+ if (LIST_INLIST(&buffer_wait->list))
LIST_DEL_INIT(&buffer_wait->list);
if (b_alloc(buf))
return 1;
- LIST_ADDQ(&ti->buffer_wq, &buffer_wait->list);
+ LIST_APPEND(&ti->buffer_wq, &buffer_wait->list);
return 0;
}
static void
spoe_release_buffer(struct buffer *buf, struct buffer_wait *buffer_wait)
{
- if (LIST_ADDED(&buffer_wait->list))
+ if (LIST_INLIST(&buffer_wait->list))
LIST_DEL_INIT(&buffer_wait->list);
/* Release the buffer if needed */
@@ -3439,7 +3439,7 @@
goto out;
}
ph->id = strdup(args[cur_arg]);
- LIST_ADDQ(&curmphs, &ph->list);
+ LIST_APPEND(&curmphs, &ph->list);
cur_arg++;
}
}
@@ -3463,7 +3463,7 @@
goto out;
}
ph->id = strdup(args[cur_arg]);
- LIST_ADDQ(&curgphs, &ph->list);
+ LIST_APPEND(&curgphs, &ph->list);
cur_arg++;
}
}
@@ -3766,7 +3766,7 @@
err_code |= ERR_ALERT | ERR_ABORT;
goto out;
}
- LIST_ADDQ(&curvars, &vph->list);
+ LIST_APPEND(&curvars, &vph->list);
cur_arg++;
}
}
@@ -3841,7 +3841,7 @@
curgrp->conf.line = linenum;
LIST_INIT(&curgrp->phs);
LIST_INIT(&curgrp->messages);
- LIST_ADDQ(&curgrps, &curgrp->list);
+ LIST_APPEND(&curgrps, &curgrp->list);
}
else if (strcmp(args[0], "messages") == 0) {
int cur_arg = 1;
@@ -3863,7 +3863,7 @@
goto out;
}
ph->id = strdup(args[cur_arg]);
- LIST_ADDQ(&curgrp->phs, &ph->list);
+ LIST_APPEND(&curgrp->phs, &ph->list);
cur_arg++;
}
}
@@ -3937,7 +3937,7 @@
LIST_INIT(&curmsg->acls);
LIST_INIT(&curmsg->by_evt);
LIST_INIT(&curmsg->by_grp);
- LIST_ADDQ(&curmsgs, &curmsg->list);
+ LIST_APPEND(&curmsgs, &curmsg->list);
}
else if (strcmp(args[0], "args") == 0) {
int cur_arg = 1;
@@ -3976,7 +3976,7 @@
goto out;
}
curmsg->nargs++;
- LIST_ADDQ(&curmsg->args, &arg->list);
+ LIST_APPEND(&curmsg->args, &arg->list);
cur_arg++;
}
curproxy->conf.args.file = NULL;
@@ -4342,7 +4342,7 @@
}
msg->agent = curagent;
- LIST_ADDQ(&curagent->events[msg->event], &msg->by_evt);
+ LIST_APPEND(&curagent->events[msg->event], &msg->by_evt);
goto next_mph;
}
}
@@ -4359,8 +4359,8 @@
list_for_each_entry_safe(grp, grpback, &curgrps, list) {
if (strcmp(grp->id, ph->id) == 0) {
grp->agent = curagent;
- LIST_DEL(&grp->list);
- LIST_ADDQ(&curagent->groups, &grp->list);
+ LIST_DELETE(&grp->list);
+ LIST_APPEND(&curagent->groups, &grp->list);
goto next_aph;
}
}
@@ -4390,8 +4390,8 @@
* them only if a rule use the corresponding SPOE group. */
msg->agent = curagent;
msg->group = grp;
- LIST_DEL(&ph->list);
- LIST_ADDQ(&grp->messages, &msg->by_grp);
+ LIST_DELETE(&ph->list);
+ LIST_APPEND(&grp->messages, &msg->by_grp);
goto next_mph_grp;
}
}
@@ -4423,16 +4423,16 @@
conf->agent_fe.options2 |= curpxopts2;
list_for_each_entry_safe(logsrv, logsrvback, &curlogsrvs, list) {
- LIST_DEL(&logsrv->list);
- LIST_ADDQ(&conf->agent_fe.logsrvs, &logsrv->list);
+ LIST_DELETE(&logsrv->list);
+ LIST_APPEND(&conf->agent_fe.logsrvs, &logsrv->list);
}
list_for_each_entry_safe(ph, phback, &curmphs, list) {
- LIST_DEL(&ph->list);
+ LIST_DELETE(&ph->list);
spoe_release_placeholder(ph);
}
list_for_each_entry_safe(ph, phback, &curgphs, list) {
- LIST_DEL(&ph->list);
+ LIST_DELETE(&ph->list);
spoe_release_placeholder(ph);
}
list_for_each_entry_safe(vph, vphback, &curvars, list) {
@@ -4451,12 +4451,12 @@
goto error;
}
- LIST_DEL(&vph->list);
+ LIST_DELETE(&vph->list);
free(vph->name);
free(vph);
}
list_for_each_entry_safe(grp, grpback, &curgrps, list) {
- LIST_DEL(&grp->list);
+ LIST_DELETE(&grp->list);
spoe_release_group(grp);
}
*cur_arg = pos;
@@ -4468,28 +4468,28 @@
error:
spoe_release_agent(curagent);
list_for_each_entry_safe(ph, phback, &curmphs, list) {
- LIST_DEL(&ph->list);
+ LIST_DELETE(&ph->list);
spoe_release_placeholder(ph);
}
list_for_each_entry_safe(ph, phback, &curgphs, list) {
- LIST_DEL(&ph->list);
+ LIST_DELETE(&ph->list);
spoe_release_placeholder(ph);
}
list_for_each_entry_safe(vph, vphback, &curvars, list) {
- LIST_DEL(&vph->list);
+ LIST_DELETE(&vph->list);
free(vph->name);
free(vph);
}
list_for_each_entry_safe(grp, grpback, &curgrps, list) {
- LIST_DEL(&grp->list);
+ LIST_DELETE(&grp->list);
spoe_release_group(grp);
}
list_for_each_entry_safe(msg, msgback, &curmsgs, list) {
- LIST_DEL(&msg->list);
+ LIST_DELETE(&msg->list);
spoe_release_message(msg);
}
list_for_each_entry_safe(logsrv, logsrvback, &curlogsrvs, list) {
- LIST_DEL(&logsrv->list);
+ LIST_DELETE(&logsrv->list);
free(logsrv);
}
free(conf);