Skip to content

Conversation

@hongxiaolong
Copy link
Collaborator

Directive

Syntax: debug_conn

Default: none

Context: server, location

The information of nginx connection usage will be accessible from the surrounding location.

@hongxiaolong
Copy link
Collaborator Author

  • Tested-by: HONGXIAOLONG
  • Date: Fri Nov 16 17:28:34 CST 2018
  • hostname: hongxiaolong
  • pwd: /Users/hongxiaolong/Projects/GitHub/tengine
  • cases: /Users/hongxiaolong/Projects/GitHub/hongxiaolong/ngx_debug_conn/t/test.t
  • git log:
add ngx_debug_conn to show connection usage.
  • case result:
$ MOD_DYCONF_PATH=/Users/hongxiaolong/Projects/GitHub/tengine TEST_NGINX_BINARY=/Users/hongxiaolong/Projects/GitHub/tengine/objs/nginx prove -v -I /Users/hongxiaolong/Projects/GitHub/tengine/tests/nginx-tests/nginx-tests/lib /Users/hongxiaolong/Projects/GitHub/hongxiaolong/ngx_debug_conn/t/test.t
/Users/hongxiaolong/Projects/GitHub/hongxiaolong/ngx_debug_conn/t/test.t ..
1..2
ok 1 - debug_conn returns information of ngx_cycle->connections[]
--- debug for verbose mode ---
HTTP/1.1 200 OK
Server: Tengine/2.2.2
Date: Fri, 16 Nov 2018 09:28:35 GMT
Content-Length: 520
Connection: close

pid:38353
connections:2
--------- [1] --------
conns[i]: 0
      fd: 6
    addr: 127.0.0.1:8080
    sent: 0
  action: (null: listening)
 handler: r:000000010B470EC0 w:0000000000000000
requests: 0
poolsize: 0
--------- [2] --------
conns[i]: 1
      fd: 7
    addr: 127.0.0.1
    sent: 0
  action: (null)
 handler: r:000000010B4ADCA0 w:000000010B4ADCA0
requests: 1
poolsize: 0
********* request ******
     uri: http://localhost/debug_conn
 handler: r:000000010B4AB820 w:000000010B4AE770
startsec: 1542360515
poolsize: 0
------------------------------
ok 2 - no alerts
ok
All tests successful.
Files=1, Tests=2,  0 wallclock secs ( 0.03 usr  0.02 sys +  0.07 cusr  0.05 csys =  0.17 CPU)
Result: PASS

@chobits chobits requested a review from wangfakang March 4, 2019 12:39
/* c->data: http request */

if (c->data != NULL) {
r = (ngx_http_request_t *) c->data;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that the c->data could be ngx_http_request_t, ngx_http_v2_connection_t, ngx_stream_session_t or other stuff filled by the Nginx module. We could not safely assume it must be ngx_http_request_t.

I comment here because I am looking up a way to get the ngx_http_request_t via a given ngx_connection_t. If you find one, please let me know.

Copy link
Member

@chobits chobits Apr 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's known issue.

I comment here because I am looking up a way to get the ngx_http_request_t via a given ngx_connection_t. If you find one, please let me know.

It seems that there is no good way to determine c->data type.
Maybe we add ngx_connection_t:data_type field, which is not a very good way.

@chobits chobits merged commit 4cbb0cf into alibaba:master Aug 4, 2023
@chobits
Copy link
Member

chobits commented Aug 4, 2023

TODO: Note that we still need 2 fixes for this module.

  1. updated github action to run t/test.t for testing this module: https://github.com/alibaba/tengine/blob/master/.github/workflows/ci.yml
  2. updated documentation to remind users of the risk in this comment: add ngx_debug_conn to show connection usage. #1127 (comment)

Copy link
Member

@chobits chobits left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack

chobits added a commit to chobits/tengine that referenced this pull request Aug 4, 2023
add ngx_debug_conn to show connection usage.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants