mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-10 00:57:02 +02:00
MEDIUM: spoe: Use the new _HA_ATOMIC_* macros.
Use the new _HA_ATOMIC_* macros and add barriers where needed.
This commit is contained in:
parent
43da3430f1
commit
9e7ae28a16
@ -1250,7 +1250,7 @@ spoe_release_appctx(struct appctx *appctx)
|
||||
__FUNCTION__, appctx);
|
||||
|
||||
/* Remove applet from the list of running applets */
|
||||
HA_ATOMIC_SUB(&agent->counters.applets, 1);
|
||||
_HA_ATOMIC_SUB(&agent->counters.applets, 1);
|
||||
HA_SPIN_LOCK(SPOE_APPLET_LOCK, &agent->rt[tid].lock);
|
||||
if (!LIST_ISEMPTY(&spoe_appctx->list)) {
|
||||
LIST_DEL(&spoe_appctx->list);
|
||||
@ -1262,7 +1262,7 @@ spoe_release_appctx(struct appctx *appctx)
|
||||
if (appctx->st0 != SPOE_APPCTX_ST_END) {
|
||||
if (appctx->st0 == SPOE_APPCTX_ST_IDLE) {
|
||||
eb32_delete(&spoe_appctx->node);
|
||||
HA_ATOMIC_SUB(&agent->counters.idles, 1);
|
||||
_HA_ATOMIC_SUB(&agent->counters.idles, 1);
|
||||
}
|
||||
|
||||
appctx->st0 = SPOE_APPCTX_ST_END;
|
||||
@ -1284,7 +1284,7 @@ spoe_release_appctx(struct appctx *appctx)
|
||||
list_for_each_entry_safe(ctx, back, &spoe_appctx->waiting_queue, list) {
|
||||
LIST_DEL(&ctx->list);
|
||||
LIST_INIT(&ctx->list);
|
||||
HA_ATOMIC_SUB(&agent->counters.nb_waiting, 1);
|
||||
_HA_ATOMIC_SUB(&agent->counters.nb_waiting, 1);
|
||||
spoe_update_stat_time(&ctx->stats.tv_wait, &ctx->stats.t_waiting);
|
||||
ctx->state = SPOE_CTX_ST_ERROR;
|
||||
ctx->status_code = (spoe_appctx->status_code + 0x100);
|
||||
@ -1313,7 +1313,7 @@ spoe_release_appctx(struct appctx *appctx)
|
||||
list_for_each_entry_safe(ctx, back, &agent->rt[tid].sending_queue, list) {
|
||||
LIST_DEL(&ctx->list);
|
||||
LIST_INIT(&ctx->list);
|
||||
HA_ATOMIC_SUB(&agent->counters.nb_sending, 1);
|
||||
_HA_ATOMIC_SUB(&agent->counters.nb_sending, 1);
|
||||
spoe_update_stat_time(&ctx->stats.tv_queue, &ctx->stats.t_queue);
|
||||
ctx->state = SPOE_CTX_ST_ERROR;
|
||||
ctx->status_code = (spoe_appctx->status_code + 0x100);
|
||||
@ -1322,7 +1322,7 @@ spoe_release_appctx(struct appctx *appctx)
|
||||
list_for_each_entry_safe(ctx, back, &agent->rt[tid].waiting_queue, list) {
|
||||
LIST_DEL(&ctx->list);
|
||||
LIST_INIT(&ctx->list);
|
||||
HA_ATOMIC_SUB(&agent->counters.nb_waiting, 1);
|
||||
_HA_ATOMIC_SUB(&agent->counters.nb_waiting, 1);
|
||||
spoe_update_stat_time(&ctx->stats.tv_wait, &ctx->stats.t_waiting);
|
||||
ctx->state = SPOE_CTX_ST_ERROR;
|
||||
ctx->status_code = (spoe_appctx->status_code + 0x100);
|
||||
@ -1446,7 +1446,7 @@ spoe_handle_connecting_appctx(struct appctx *appctx)
|
||||
default:
|
||||
/* HELLO handshake is finished, set the idle timeout and
|
||||
* add the applet in the list of running applets. */
|
||||
HA_ATOMIC_ADD(&agent->counters.idles, 1);
|
||||
_HA_ATOMIC_ADD(&agent->counters.idles, 1);
|
||||
appctx->st0 = SPOE_APPCTX_ST_IDLE;
|
||||
SPOE_APPCTX(appctx)->node.key = 0;
|
||||
eb32_insert(&agent->rt[tid].idle_applets, &SPOE_APPCTX(appctx)->node);
|
||||
@ -1516,7 +1516,7 @@ spoe_handle_sending_frame_appctx(struct appctx *appctx, int *skip)
|
||||
spoe_release_buffer(&ctx->buffer, &ctx->buffer_wait);
|
||||
LIST_DEL(&ctx->list);
|
||||
LIST_INIT(&ctx->list);
|
||||
HA_ATOMIC_SUB(&agent->counters.nb_sending, 1);
|
||||
_HA_ATOMIC_SUB(&agent->counters.nb_sending, 1);
|
||||
spoe_update_stat_time(&ctx->stats.tv_queue, &ctx->stats.t_queue);
|
||||
ctx->spoe_appctx = NULL;
|
||||
ctx->state = SPOE_CTX_ST_ERROR;
|
||||
@ -1536,7 +1536,7 @@ spoe_handle_sending_frame_appctx(struct appctx *appctx, int *skip)
|
||||
spoe_release_buffer(&ctx->buffer, &ctx->buffer_wait);
|
||||
LIST_DEL(&ctx->list);
|
||||
LIST_INIT(&ctx->list);
|
||||
HA_ATOMIC_SUB(&agent->counters.nb_sending, 1);
|
||||
_HA_ATOMIC_SUB(&agent->counters.nb_sending, 1);
|
||||
spoe_update_stat_time(&ctx->stats.tv_queue, &ctx->stats.t_queue);
|
||||
ctx->spoe_appctx = SPOE_APPCTX(appctx);
|
||||
if (!(ctx->flags & SPOE_CTX_FL_FRAGMENTED) ||
|
||||
@ -1571,7 +1571,7 @@ spoe_handle_sending_frame_appctx(struct appctx *appctx, int *skip)
|
||||
*skip = 1;
|
||||
LIST_ADDQ(&SPOE_APPCTX(appctx)->waiting_queue, &ctx->list);
|
||||
}
|
||||
HA_ATOMIC_ADD(&agent->counters.nb_waiting, 1);
|
||||
_HA_ATOMIC_ADD(&agent->counters.nb_waiting, 1);
|
||||
ctx->stats.tv_wait = now;
|
||||
SPOE_APPCTX(appctx)->frag_ctx.ctx = NULL;
|
||||
SPOE_APPCTX(appctx)->frag_ctx.cursid = 0;
|
||||
@ -1627,7 +1627,7 @@ spoe_handle_receiving_frame_appctx(struct appctx *appctx, int *skip)
|
||||
default:
|
||||
LIST_DEL(&ctx->list);
|
||||
LIST_INIT(&ctx->list);
|
||||
HA_ATOMIC_SUB(&agent->counters.nb_waiting, 1);
|
||||
_HA_ATOMIC_SUB(&agent->counters.nb_waiting, 1);
|
||||
spoe_update_stat_time(&ctx->stats.tv_wait, &ctx->stats.t_waiting);
|
||||
ctx->stats.tv_response = now;
|
||||
if (ctx->spoe_appctx) {
|
||||
@ -1733,7 +1733,7 @@ spoe_handle_processing_appctx(struct appctx *appctx)
|
||||
}
|
||||
|
||||
if (appctx->st0 == SPOE_APPCTX_ST_PROCESSING && SPOE_APPCTX(appctx)->cur_fpa < agent->max_fpa) {
|
||||
HA_ATOMIC_ADD(&agent->counters.idles, 1);
|
||||
_HA_ATOMIC_ADD(&agent->counters.idles, 1);
|
||||
appctx->st0 = SPOE_APPCTX_ST_IDLE;
|
||||
eb32_insert(&agent->rt[tid].idle_applets, &SPOE_APPCTX(appctx)->node);
|
||||
}
|
||||
@ -1896,7 +1896,7 @@ spoe_handle_appctx(struct appctx *appctx)
|
||||
goto switchstate;
|
||||
|
||||
case SPOE_APPCTX_ST_IDLE:
|
||||
HA_ATOMIC_SUB(&agent->counters.idles, 1);
|
||||
_HA_ATOMIC_SUB(&agent->counters.idles, 1);
|
||||
eb32_delete(&SPOE_APPCTX(appctx)->node);
|
||||
if (stopping &&
|
||||
LIST_ISEMPTY(&agent->rt[tid].sending_queue) &&
|
||||
@ -2013,7 +2013,7 @@ spoe_create_appctx(struct spoe_config *conf)
|
||||
HA_SPIN_LOCK(SPOE_APPLET_LOCK, &conf->agent->rt[tid].lock);
|
||||
LIST_ADDQ(&conf->agent->rt[tid].applets, &SPOE_APPCTX(appctx)->list);
|
||||
HA_SPIN_UNLOCK(SPOE_APPLET_LOCK, &conf->agent->rt[tid].lock);
|
||||
HA_ATOMIC_ADD(&conf->agent->counters.applets, 1);
|
||||
_HA_ATOMIC_ADD(&conf->agent->counters.applets, 1);
|
||||
|
||||
task_wakeup(SPOE_APPCTX(appctx)->task, TASK_WOKEN_INIT);
|
||||
task_wakeup(strm->task, TASK_WOKEN_INIT);
|
||||
@ -2098,7 +2098,7 @@ spoe_queue_context(struct spoe_context *ctx)
|
||||
|
||||
/* Add the SPOE context in the sending queue */
|
||||
LIST_ADDQ(&agent->rt[tid].sending_queue, &ctx->list);
|
||||
HA_ATOMIC_ADD(&agent->counters.nb_sending, 1);
|
||||
_HA_ATOMIC_ADD(&agent->counters.nb_sending, 1);
|
||||
spoe_update_stat_time(&ctx->stats.tv_request, &ctx->stats.t_request);
|
||||
ctx->stats.tv_queue = now;
|
||||
|
||||
@ -2582,7 +2582,7 @@ spoe_stop_processing(struct spoe_agent *agent, struct spoe_context *ctx)
|
||||
|
||||
if (!(ctx->flags & SPOE_CTX_FL_PROCESS))
|
||||
return;
|
||||
HA_ATOMIC_ADD(&agent->counters.nb_processed, 1);
|
||||
_HA_ATOMIC_ADD(&agent->counters.nb_processed, 1);
|
||||
if (sa) {
|
||||
if (sa->frag_ctx.ctx == ctx) {
|
||||
sa->frag_ctx.ctx = NULL;
|
||||
@ -2609,9 +2609,9 @@ spoe_stop_processing(struct spoe_agent *agent, struct spoe_context *ctx)
|
||||
|
||||
if (!LIST_ISEMPTY(&ctx->list)) {
|
||||
if (ctx->state == SPOE_CTX_ST_SENDING_MSGS)
|
||||
HA_ATOMIC_SUB(&agent->counters.nb_sending, 1);
|
||||
_HA_ATOMIC_SUB(&agent->counters.nb_sending, 1);
|
||||
else
|
||||
HA_ATOMIC_SUB(&agent->counters.nb_waiting, 1);
|
||||
_HA_ATOMIC_SUB(&agent->counters.nb_waiting, 1);
|
||||
|
||||
LIST_DEL(&ctx->list);
|
||||
LIST_INIT(&ctx->list);
|
||||
@ -2716,7 +2716,7 @@ spoe_process_messages(struct stream *s, struct spoe_context *ctx,
|
||||
spoe_update_stats(s, agent, ctx, dir);
|
||||
spoe_stop_processing(agent, ctx);
|
||||
if (ctx->status_code) {
|
||||
HA_ATOMIC_ADD(&agent->counters.nb_errors, 1);
|
||||
_HA_ATOMIC_ADD(&agent->counters.nb_errors, 1);
|
||||
spoe_handle_processing_error(s, agent, ctx, dir);
|
||||
ret = 1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user