Skip to content

Commit

Permalink
Status: fixed error in connection statistics.
Browse files Browse the repository at this point in the history
When proxy is used, the number of accepted connections is not counted,
This also results in the wrong number of active connections.
  • Loading branch information
hongzhidao committed Sep 21, 2022
1 parent 76df62a commit 0711101
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
6 changes: 6 additions & 0 deletions docs/changes.xml
Expand Up @@ -37,6 +37,12 @@ fix HTTP cookie parsing when the value contains an equals sign.
</para>
</change>

<change type="bugfix">
<para>
fix error in connection statistics when using proxy.
</para>
</change>

</changes>


Expand Down
3 changes: 1 addition & 2 deletions src/nxt_conn.h
Expand Up @@ -312,8 +312,7 @@ NXT_EXPORT void nxt_event_conn_job_sendfile(nxt_task_t *task,
\
nxt_queue_remove(&c->link); \
\
c->idle = 0; \
e->idle_conns_cnt--; \
e->idle_conns_cnt -= c->idle; \
} while (0)


Expand Down
8 changes: 6 additions & 2 deletions src/nxt_conn_close.c
Expand Up @@ -119,7 +119,9 @@ nxt_conn_close_handler(nxt_task_t *task, void *obj, void *data)
nxt_socket_close(task, c->socket.fd);
c->socket.fd = -1;

engine->closed_conns_cnt++;
if (c->idle) {
engine->closed_conns_cnt++;
}

if (timers_pending == 0) {
nxt_work_queue_add(&engine->fast_work_queue,
Expand Down Expand Up @@ -155,7 +157,9 @@ nxt_conn_close_timer_handler(nxt_task_t *task, void *obj, void *data)
nxt_socket_close(task, c->socket.fd);
c->socket.fd = -1;

engine->closed_conns_cnt++;
if (c->idle) {
engine->closed_conns_cnt++;
}
}

nxt_work_queue_add(&engine->fast_work_queue, c->write_state->ready_handler,
Expand Down

0 comments on commit 0711101

Please sign in to comment.