Welcome! Log In Create A New Profile

Advanced

http request count is zero

August 10, 2021 06:36PM
Hi,
I am seeing an alert in the nginx error.log with the message "http request
count is zero". It seems to be from this code in
src/http/ngx_http_request.c:

if (r->count == 0) {
ngx_log_error(NGX_LOG_ALERT, c->log, 0, "http request count is zero");
}

These alerts are showing up for requests that receive a NGX_HTTP_FORBIDDEN
from my module. What does it mean when "r->count" is zero? Is there some
additional stuff I must do in my module to avoid seeing this message? Any
help in understanding the issue is appreciated. I've included my code for
sending the response. Thanks.

Regards,
Dk.


ngx_buf_t *buf = ngx_create_temp_buf(r->pool, buf_size);
....
ngx_int_t
send_response(ngx_http_request_t *r, ngx_uint_t http_status, ngx_buf_t *buf)
{
ngx_int_t rc;
ngx_log_t *log = r->connection->log;

if (NULL == buf) {
ngx_log_error(NGX_LOG_ERR, log, 0, "%s: Invalid input buffer",
__FUNCTION__);
return NGX_ERROR;
}

rc = ngx_http_discard_request_body(r);
if (rc != NGX_OK) {
ngx_log_error(NGX_LOG_ERR, log, 0, "%s: Discard req. body failed.
rc=%i", __FUNCTION__, rc);
return rc;
}

r->err_status = http_status;
r->headers_out.status = http_status;
r->headers_out.content_length_n = buf->last - buf->pos;
ngx_str_set(&r->headers_out.content_type, "text/plain");

rc = ngx_http_send_header(r);

if (rc == NGX_ERROR || rc > NGX_OK || r->header_only) {
ngx_log_error(NGX_LOG_ERR, log, 0, "%s: Send header failed. rc=%i",
__FUNCTION__, rc);
return rc;
}

ngx_chain_t *out_chain = ngx_alloc_chain_link(r->pool);
if (NULL == out_chain) {
ngx_log_error(NGX_LOG_ERR, log, 0, "%s: Buffer chain alloc failed",
__FUNCTION__);
return NGX_ERROR;
}

out_chain->buf = buf;
out_chain->next = NULL;
buf->last_buf = 1;
buf->last_in_chain = 1;

rc = ngx_http_output_filter(r, out_chain);
if ((rc != NGX_OK) && (rc != NGX_AGAIN)) {
ngx_log_error(NGX_LOG_ERR, log, 0, "%s: Output filter call failed.
rc=%i", __FUNCTION__, rc);
return NGX_ERROR;
}

return NGX_OK;
}
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

http request count is zero

dnj0496 720 August 10, 2021 06:36PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 171
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready