This patch replaces 28 occurrences of COUNT_IF(1, msg) with COUNT(msg).
This makes the counters output more readable, the code as well, and even
saves a few bytes (148) in the executable.
int _ret = 0; \
if (unlikely((http_hdng_chk.rules | ~http_hdng_chk.found) & _flag)) { \
http_hdng_chk.found |= _flag; \
- (void)COUNT_IF(1, "hardening " #flag " condition met"); \
+ COUNT("hardening " #flag " condition met"); \
if (http_hdng_chk.rules & _flag) { \
- (void)COUNT_IF(1, "hardening " #flag " enforced"); \
+ COUNT("hardening " #flag " enforced"); \
http_hdng_chk.fixed |= _flag; \
_ret = 1; \
} \
* events for statistics purposes.
*/
if (e & (EPOLLRDHUP|EPOLLHUP|EPOLLERR))
- COUNT_IF(1, "epoll report of HUP/ERR on a stale fd reopened on another thread (harmless)");
+ COUNT("epoll report of HUP/ERR on a stale fd reopened on another thread (harmless)");
} else {
/* same thread but different generation, this smells bad,
* maybe that could be caused by crossed takeovers with a
* once we've read all pending data.
*/
if (e & EPOLLERR)
- COUNT_IF(1, "epoll report of ERR on a stale fd reopened on the same thread (suspicious)");
+ COUNT("epoll report of ERR on a stale fd reopened on the same thread (suspicious)");
else if (e & (EPOLLRDHUP|EPOLLHUP))
- COUNT_IF(1, "epoll report of HUP on a stale fd reopened on the same thread (suspicious)");
+ COUNT("epoll report of HUP on a stale fd reopened on the same thread (suspicious)");
else
- COUNT_IF(1, "epoll report of a harmless event on a stale fd reopened on the same thread (suspicious)");
+ COUNT("epoll report of a harmless event on a stale fd reopened on the same thread (suspicious)");
}
} else if (ev_gen + 1 != fd_gen) {
- COUNT_IF(1, "epoll report of event on a closed recycled fd (rare)");
+ COUNT("epoll report of event on a closed recycled fd (rare)");
} else {
- COUNT_IF(1, "epoll report of event on a just closed fd (harmless)");
+ COUNT("epoll report of event on a just closed fd (harmless)");
}
continue;
} else if (fd_tgid(fd) != tgid) {
if (h1m->flags & H1_MF_CLEN) {
if (count > h1m->curr_len) {
- COUNT_IF(1, "more payload than announced (0-copy)");
+ COUNT("more payload than announced (0-copy)");
TRACE_ERROR("more payload than announced",
H1_EV_TX_DATA|H1_EV_STRM_ERR|H1_EV_H1C_ERR|H1_EV_H1S_ERR, h1c->conn, h1s);
goto error;
/* If is a new chunk, prepend the chunk size */
if (h1m->state == H1_MSG_CHUNK_CRLF || h1m->state == H1_MSG_CHUNK_SIZE) {
if (h1m->curr_len) {
- COUNT_IF(1, "chunk bigger than announced (0-copy)");
+ COUNT("chunk bigger than announced (0-copy)");
TRACE_ERROR("chunk bigger than announced",
H1_EV_TX_DATA|H1_EV_STRM_ERR|H1_EV_H1C_ERR|H1_EV_H1S_ERR, h1c->conn, h1s);
goto error;
/* It is the end of the message, add the last chunk with the extra CRLF */
if (eom) {
if (h1m->curr_len) {
- COUNT_IF(1, "chunk smaller than announced (0-copy)");
+ COUNT("chunk smaller than announced (0-copy)");
TRACE_ERROR("chunk smaller than announced",
H1_EV_TX_DATA|H1_EV_STRM_ERR|H1_EV_H1C_ERR|H1_EV_H1S_ERR, h1c->conn, h1s);
goto error;
/* Handle now case of CRLF at the end of a chun. */
if ((h1m->flags & H1_MF_CHNK) && h1m->state == H1_MSG_CHUNK_CRLF) {
if (h1m->curr_len) {
- COUNT_IF(1, "chunk bigger than announced");
+ COUNT("chunk bigger than announced");
TRACE_ERROR("chunk bigger than announced",
H1_EV_TX_DATA|H1_EV_STRM_ERR|H1_EV_H1C_ERR|H1_EV_H1S_ERR, h1c->conn, h1s);
goto error;
if (h1m->flags & H1_MF_CLEN) {
if (vlen > h1m->curr_len) {
- COUNT_IF(1, "more payload than announced");
+ COUNT("more payload than announced");
TRACE_ERROR("more payload than announced",
H1_EV_TX_DATA|H1_EV_STRM_ERR|H1_EV_H1C_ERR|H1_EV_H1S_ERR, h1c->conn, h1s);
goto error;
}
if (last_data) {
if (h1m->curr_len) {
- COUNT_IF(1, "chunk smaller than announced");
+ COUNT("chunk smaller than announced");
TRACE_ERROR("chunk smaller than announced",
H1_EV_TX_DATA|H1_EV_STRM_ERR|H1_EV_H1C_ERR|H1_EV_H1S_ERR, h1c->conn, h1s);
goto error;
}
else if (h1m->flags & H1_MF_CHNK) {
if (h1m->curr_len) {
- COUNT_IF(1, "chunk smaller than announced");
+ COUNT("chunk smaller than announced");
TRACE_ERROR("chunk smaller than announced",
H1_EV_TX_DATA|H1_EV_STRM_ERR|H1_EV_H1C_ERR|H1_EV_H1S_ERR, h1c->conn, h1s);
goto error;
h1c->state = H1_CS_DRAINING;
h1c->flags &= ~H1C_F_WANT_FASTFWD;
h1c_report_term_evt(h1c, muxc_tevt_type_graceful_shut);
- COUNT_IF(1, "Deferring H1S destroy to drain message");
+ COUNT("Deferring H1S destroy to drain message");
TRACE_DEVEL("Deferring H1S destroy to drain message", H1_EV_STRM_END, h1s->h1c->conn, h1s);
/* If we have a pending data, process it immediately or
* subscribe for reads waiting for new data
if ((uint64_t)total > h1m->curr_len) {
h1s->flags |= H1S_F_PARSING_ERROR;
se_fl_set(h1s->sd, SE_FL_ERROR);
- COUNT_IF(1, "more payload than announced");
+ COUNT("more payload than announced");
TRACE_ERROR("too much payload, more than announced",
H1_EV_STRM_RECV|H1_EV_STRM_ERR|H1_EV_H1C_ERR|H1_EV_H1S_ERR, h1c->conn, h1s);
goto end;
* the connection flow control consistency
*/
if (!qcs_is_close_remote(qcs) && qcs->rx.offset_max > qcs->rx.offset) {
- COUNT_IF(1, "QCS is released while not remotely closed. "
+ COUNT("QCS is released while not remotely closed. "
"This may cause miscalculation in conn flow control.");
qcc_account_for_conn_fctl(qcc, qcs->rx.offset_max - qcs->rx.offset);
}
*/
if (ncbmb_head(ncbuf) + data >= ncbmb_wrap(ncbuf)) {
TRACE_ERROR("unsupported wrapping CRYPTO frames", QUIC_EV_CONN_PRSHPKT, qc);
- COUNT_IF(1, "connection closed on unsupported wrapping CRYPTO content");
+ COUNT("connection closed on unsupported wrapping CRYPTO content");
quic_set_connection_close(qc, quic_err_transport(QC_ERR_CRYPTO_BUFFER_EXCEEDED));
quic_free_ncbuf(ncbuf);
goto err;
* - https://www.spinics.net/lists/netdev/msg876470.html
*/
if (unlikely((fdtab[fd].state & (FD_POLL_HUP|FD_POLL_ERR)) == FD_POLL_HUP)) {
- COUNT_IF(1, "Removing FD_POLL_HUP if no FD_POLL_ERR to let connect() decide");
+ COUNT("Removing FD_POLL_HUP if no FD_POLL_ERR to let connect() decide");
fdtab[fd].state &= ~FD_POLL_HUP;
}
sc_abort(scf);
sc_shutdown(scf);
if (!(req->analysers) && !(res->analysers)) {
- COUNT_IF(1, "Report a client abort (no analysers)");
+ COUNT("Report a client abort (no analysers)");
if (s->be_tgcounters)
_HA_ATOMIC_INC(&s->be_tgcounters->cli_aborts);
if (sess->fe_tgcounters)
if (s->sv_tgcounters)
_HA_ATOMIC_INC(&s->sv_tgcounters->failed_resp);
if (!(req->analysers) && !(res->analysers)) {
- COUNT_IF(1, "Report a client abort (no analysers)");
+ COUNT("Report a client abort (no analysers)");
if (s->be_tgcounters)
_HA_ATOMIC_INC(&s->be_tgcounters->srv_aborts);
if (sess->fe_tgcounters)
if (s->sv_tgcounters)
_HA_ATOMIC_INC(&s->sv_tgcounters->cli_aborts);
s->flags |= SF_ERR_CLICL;
- COUNT_IF(1, "Report unhandled client error");
+ COUNT("Report unhandled client error");
}
else if (req->flags & CF_READ_TIMEOUT) {
if (s->be_tgcounters)
if (s->sv_tgcounters)
_HA_ATOMIC_INC(&s->sv_tgcounters->cli_aborts);
s->flags |= SF_ERR_CLITO;
- COUNT_IF(1, "Report unhandled client timeout (RD)");
+ COUNT("Report unhandled client timeout (RD)");
}
else {
if (s->be_tgcounters)
if (s->sv_tgcounters)
_HA_ATOMIC_INC(&s->sv_tgcounters->srv_aborts);
s->flags |= SF_ERR_SRVTO;
- COUNT_IF(1, "Report unhandled server timeout (WR)");
+ COUNT("Report unhandled server timeout (WR)");
}
sess_set_term_flags(s);
if (s->sv_tgcounters)
_HA_ATOMIC_INC(&s->sv_tgcounters->srv_aborts);
s->flags |= SF_ERR_SRVCL;
- COUNT_IF(1, "Report unhandled server error");
+ COUNT("Report unhandled server error");
}
else if (res->flags & CF_READ_TIMEOUT) {
if (s->be_tgcounters)
if (s->sv_tgcounters)
_HA_ATOMIC_INC(&s->sv_tgcounters->srv_aborts);
s->flags |= SF_ERR_SRVTO;
- COUNT_IF(1, "Report unhandled server timeout (RD)");
+ COUNT("Report unhandled server timeout (RD)");
}
else {
if (s->be_tgcounters)
if (s->sv_tgcounters)
_HA_ATOMIC_INC(&s->sv_tgcounters->cli_aborts);
s->flags |= SF_ERR_CLITO;
- COUNT_IF(1, "Report unhandled client timeout (WR)");
+ COUNT("Report unhandled client timeout (WR)");
}
sess_set_term_flags(s);
}