mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-07 07:37:02 +02:00
MEDIUM: compression: Use the new _HA_ATOMIC_* macros.
Use the new _HA_ATOMIC_* macros and add barriers where needed.
This commit is contained in:
parent
cb6c9274ae
commit
43da3430f1
@ -168,7 +168,8 @@ static inline int init_comp_ctx(struct comp_ctx **comp_ctx)
|
||||
(*comp_ctx)->direct_len = 0;
|
||||
(*comp_ctx)->queued = BUF_NULL;
|
||||
#elif defined(USE_ZLIB)
|
||||
HA_ATOMIC_ADD(&zlib_used_memory, sizeof(struct comp_ctx));
|
||||
_HA_ATOMIC_ADD(&zlib_used_memory, sizeof(struct comp_ctx));
|
||||
__ha_barrier_atomic_store();
|
||||
|
||||
strm = &(*comp_ctx)->strm;
|
||||
strm->zalloc = alloc_zlib;
|
||||
@ -190,7 +191,8 @@ static inline int deinit_comp_ctx(struct comp_ctx **comp_ctx)
|
||||
*comp_ctx = NULL;
|
||||
|
||||
#ifdef USE_ZLIB
|
||||
HA_ATOMIC_SUB(&zlib_used_memory, sizeof(struct comp_ctx));
|
||||
_HA_ATOMIC_SUB(&zlib_used_memory, sizeof(struct comp_ctx));
|
||||
__ha_barrier_atomic_store();
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
@ -459,8 +461,10 @@ static void *alloc_zlib(void *opaque, unsigned int items, unsigned int size)
|
||||
ctx->zlib_pending_buf = buf = pool_alloc(pool);
|
||||
break;
|
||||
}
|
||||
if (buf != NULL)
|
||||
HA_ATOMIC_ADD(&zlib_used_memory, pool->size);
|
||||
if (buf != NULL) {
|
||||
_HA_ATOMIC_ADD(&zlib_used_memory, pool->size);
|
||||
__ha_barrier_atomic_store();
|
||||
}
|
||||
|
||||
end:
|
||||
|
||||
@ -491,7 +495,8 @@ static void free_zlib(void *opaque, void *ptr)
|
||||
pool = zlib_pool_pending_buf;
|
||||
|
||||
pool_free(pool, ptr);
|
||||
HA_ATOMIC_SUB(&zlib_used_memory, pool->size);
|
||||
_HA_ATOMIC_SUB(&zlib_used_memory, pool->size);
|
||||
__ha_barrier_atomic_store();
|
||||
}
|
||||
|
||||
/**************************
|
||||
|
@ -286,14 +286,14 @@ comp_http_payload(struct stream *s, struct filter *filter, struct http_msg *msg,
|
||||
|
||||
if (st->comp_ctx && st->comp_ctx->cur_lvl > 0) {
|
||||
update_freq_ctr(&global.comp_bps_in, consumed);
|
||||
HA_ATOMIC_ADD(&strm_fe(s)->fe_counters.comp_in, consumed);
|
||||
HA_ATOMIC_ADD(&s->be->be_counters.comp_in, consumed);
|
||||
_HA_ATOMIC_ADD(&strm_fe(s)->fe_counters.comp_in, consumed);
|
||||
_HA_ATOMIC_ADD(&s->be->be_counters.comp_in, consumed);
|
||||
update_freq_ctr(&global.comp_bps_out, to_forward);
|
||||
HA_ATOMIC_ADD(&strm_fe(s)->fe_counters.comp_out, to_forward);
|
||||
HA_ATOMIC_ADD(&s->be->be_counters.comp_out, to_forward);
|
||||
_HA_ATOMIC_ADD(&strm_fe(s)->fe_counters.comp_out, to_forward);
|
||||
_HA_ATOMIC_ADD(&s->be->be_counters.comp_out, to_forward);
|
||||
} else {
|
||||
HA_ATOMIC_ADD(&strm_fe(s)->fe_counters.comp_byp, consumed);
|
||||
HA_ATOMIC_ADD(&s->be->be_counters.comp_byp, consumed);
|
||||
_HA_ATOMIC_ADD(&strm_fe(s)->fe_counters.comp_byp, consumed);
|
||||
_HA_ATOMIC_ADD(&s->be->be_counters.comp_byp, consumed);
|
||||
}
|
||||
return to_forward;
|
||||
|
||||
@ -461,9 +461,9 @@ comp_http_end(struct stream *s, struct filter *filter,
|
||||
goto end;
|
||||
|
||||
if (strm_fe(s)->mode == PR_MODE_HTTP)
|
||||
HA_ATOMIC_ADD(&strm_fe(s)->fe_counters.p.http.comp_rsp, 1);
|
||||
_HA_ATOMIC_ADD(&strm_fe(s)->fe_counters.p.http.comp_rsp, 1);
|
||||
if ((s->flags & SF_BE_ASSIGNED) && (s->be->mode == PR_MODE_HTTP))
|
||||
HA_ATOMIC_ADD(&s->be->be_counters.p.http.comp_rsp, 1);
|
||||
_HA_ATOMIC_ADD(&s->be->be_counters.p.http.comp_rsp, 1);
|
||||
end:
|
||||
return 1;
|
||||
}
|
||||
@ -1265,11 +1265,11 @@ http_compression_buffer_end(struct comp_state *st, struct stream *s,
|
||||
/* update input rate */
|
||||
if (st->comp_ctx && st->comp_ctx->cur_lvl > 0) {
|
||||
update_freq_ctr(&global.comp_bps_in, st->consumed);
|
||||
HA_ATOMIC_ADD(&strm_fe(s)->fe_counters.comp_in, st->consumed);
|
||||
HA_ATOMIC_ADD(&s->be->be_counters.comp_in, st->consumed);
|
||||
_HA_ATOMIC_ADD(&strm_fe(s)->fe_counters.comp_in, st->consumed);
|
||||
_HA_ATOMIC_ADD(&s->be->be_counters.comp_in, st->consumed);
|
||||
} else {
|
||||
HA_ATOMIC_ADD(&strm_fe(s)->fe_counters.comp_byp, st->consumed);
|
||||
HA_ATOMIC_ADD(&s->be->be_counters.comp_byp, st->consumed);
|
||||
_HA_ATOMIC_ADD(&strm_fe(s)->fe_counters.comp_byp, st->consumed);
|
||||
_HA_ATOMIC_ADD(&s->be->be_counters.comp_byp, st->consumed);
|
||||
}
|
||||
|
||||
/* copy the remaining data in the tmp buffer. */
|
||||
@ -1292,8 +1292,8 @@ http_compression_buffer_end(struct comp_state *st, struct stream *s,
|
||||
|
||||
if (st->comp_ctx && st->comp_ctx->cur_lvl > 0) {
|
||||
update_freq_ctr(&global.comp_bps_out, to_forward);
|
||||
HA_ATOMIC_ADD(&strm_fe(s)->fe_counters.comp_out, to_forward);
|
||||
HA_ATOMIC_ADD(&s->be->be_counters.comp_out, to_forward);
|
||||
_HA_ATOMIC_ADD(&strm_fe(s)->fe_counters.comp_out, to_forward);
|
||||
_HA_ATOMIC_ADD(&s->be->be_counters.comp_out, to_forward);
|
||||
}
|
||||
|
||||
return to_forward;
|
||||
|
Loading…
Reference in New Issue
Block a user