从Proxy接收到数据
ngx_http_upstream_handler主要是处理服务器返回的http结果,然后把headers_in的部分内容拷贝到headers_out上
一:ngx_http_upstream_process_header at src/http/ngx_http_upstream.c:1518
#0 ngx_http_proxy_process_status_line (r=0x988d220)
at src/http/modules/ngx_http_proxy_module.c:1215
此函数主要是分析200OK的状态并写入相关结构体
#1 0x0807b784 in ngx_http_upstream_process_header (r=0x988d220,
u=0x9893958) at src/http/ngx_http_upstream.c:1518
此处的u是r中的一员,包含于被包含,Nginx的风格;因为都是在同一个pool中申请的内存,所以指针乱指都没问题,最后统一释放pool就可以
#2 0x08079ed1 in ngx_http_upstream_handler (ev=0x988d220)
at src/http/ngx_http_upstream.c:876
#3 0x08064a85 in ngx_epoll_process_events (cycle=0x988dc18, timer=3081,
flags=<value optimized out>)
at src/event/modules/ngx_epoll_module.c:642
#4 0x0805d742 in ngx_process_events_and_timers (cycle=0x988dc18)
at src/event/ngx_event.c:245
#5 0x080636d4 in ngx_worker_process_cycle (cycle=0x988dc18, data=0x0)
at src/os/unix/ngx_process_cycle.c:795
#6 0x08061e2d in ngx_spawn_process (cycle=0x988dc18,
proc=0x8063619 <ngx_worker_process_cycle>, data=0x0,
name=0x809aa9d "worker process", respawn=-3)
at src/os/unix/ngx_process.c:196
#7 0x08062ca7 in ngx_start_worker_processes (cycle=0x988dc18, n=1,
type=-3) at src/os/unix/ngx_process_cycle.c:355
#8 0x08063c40 in ngx_master_process_cycle (cycle=0x988dc18)
二:ngx_http_upstream_process_header at src/http/ngx_http_upstream.c:1565
#0 ngx_http_upstream_process_headers (r=0x9895898, u=0x98d2224)
at src/http/ngx_http_upstream.c:1768
处理
#1 0x0807b9f4 in ngx_http_upstream_process_header (r=0x9895898,
u=0x98d2224) at src/http/ngx_http_upstream.c:1565
#2 0x08079ed1 in ngx_http_upstream_handler (ev=0x98d2224)
at src/http/ngx_http_upstream.c:876
#3 0x08064a85 in ngx_epoll_process_events (cycle=0x988dc18, timer=4533,
flags=<value optimized out>)
at src/event/modules/ngx_epoll_module.c:642
#4 0x0805d742 in ngx_process_events_and_timers (cycle=0x988dc18)
at src/event/ngx_event.c:245
#5 0x080636d4 in ngx_worker_process_cycle (cycle=0x988dc18, data=0x0)
at src/os/unix/ngx_process_cycle.c:795
#6 0x08061e2d in ngx_spawn_process (cycle=0x988dc18,
proc=0x8063619 <ngx_worker_process_cycle>, data=0x0,
name=0x809aa9d "worker process", respawn=-3)
at src/os/unix/ngx_process.c:196
#7 0x08062ca7 in ngx_start_worker_processes (cycle=0x988dc18, n=1,
type=-3) at src/os/unix/ngx_process_cycle.c:355
#8 0x08063c40 in ngx_master_process_cycle (cycle=0x988dc18)
发送数据到UE:
#0 ngx_linux_sendfile_chain (c=0x98a0218, in=0x98d6aec, limit=2147479551)
at src/os/unix/ngx_linux_sendfile_chain.c:293
#1 0x08072801 in ngx_http_write_filter (r=0x98cfcb0, in=0x98d6b30)
at src/http/ngx_http_write_filter_module.c:238
#2 0x0807f400 in ngx_http_chunked_body_filter (r=0x98cfcb0, in=0x2)
at src/http/modules/ngx_http_chunked_filter_module.c:92
#3 0x08083c51 in ngx_http_postpone_filter (r=0x98cfcb0, in=0x2)
at src/http/ngx_http_postpone_filter_module.c:82
#4 0x08085a9b in ngx_http_ssi_body_filter (r=0x98cfcb0, in=0xbfcd3c14)
at src/http/modules/ngx_http_ssi_filter_module.c:390
#5 0x08087f59 in ngx_http_charset_body_filter (r=0x98cfcb0, in=0x98d6b30)
at src/http/modules/ngx_http_charset_filter_module.c:552
#6 0x0804db3a in ngx_output_chain (ctx=0x98d6b38, in=0x98d6b30)
at src/core/ngx_output_chain.c:65
#7 0x08072b2b in ngx_http_copy_filter (r=0x98cfcb0, in=0x98d6b30)
at src/http/ngx_http_copy_filter_module.c:139
#8 0x0807f689 in ngx_http_range_body_filter (r=0x98cfcb0, in=0x98d6b30)
at src/http/modules/ngx_http_range_filter_module.c:551
#9 0x08067ae4 in ngx_http_output_filter (r=0x98cfcb0, in=0x98d6b30)
at src/http/ngx_http_core_module.c:1730
---Type <return> to continue, or q <return> to quit---
#10 0x0805f369 in ngx_event_pipe (p=0x98d62d8, do_write=0)
at src/event/ngx_event_pipe.c:482
#11 0x08079dc9 in ngx_http_upstream_process_upstream (r=0x98cfcb0,
u=0x98d60a0) at src/http/ngx_http_upstream.c:2526
#12 0x0807bfea in ngx_http_upstream_process_header (r=0x98cfcb0,
u=0x98d60a0) at src/http/ngx_http_upstream.c:2221
#13 0x08079ed1 in ngx_http_upstream_handler (ev=0x2)
at src/http/ngx_http_upstream.c:876
#14 0x08064a85 in ngx_epoll_process_events (cycle=0x988dc18, timer=4772,
flags=<value optimized out>)
at src/event/modules/ngx_epoll_module.c:642
#15 0x0805d742 in ngx_process_events_and_timers (cycle=0x988dc18)
at src/event/ngx_event.c:245
#16 0x080636d4 in ngx_worker_process_cycle (cycle=0x988dc18, data=0x0)
at src/os/unix/ngx_process_cycle.c:795
#17 0x08061e2d in ngx_spawn_process (cycle=0x988dc18,
proc=0x8063619 <ngx_worker_process_cycle>, data=0x0,
name=0x809aa9d "worker process", respawn=-3)
at src/os/unix/ngx_process.c:196
#18 0x08062ca7 in ngx_start_worker_processes (cycle=0x988dc18, n=1,
---Type <return> to continue, or q <return> to quit---
type=-3) at src/os/unix/ngx_process_cycle.c:355
#19 0x08063c40 in ngx_master_process_cycle (cycle=0x988dc18)
at src/os/unix/ngx_process_cycle.c:136
#20 0x0804b43d in main (argc=1, argv=0xbfcd46e4) at src/core/nginx.c:396
ngx_linux_sendfile_chain函数中:
发送数据的函数 rc = writev(c->fd, header.elts, header.nelts);
其中的header数组数据时来源于(类型:struct iovec headers[NGX_HEADERS];)
iov->iov_base = (void *) cl->buf->pos;
iov->iov_len = (size_t) size;
而cl = in(类型:ngx_chain_t *in-----ngx_chain_t *cl;)
所以
可以打印(数组多了打印就困难了):
(gdb) p header.nelts
$79 = 2
(gdb) p in->buf->pos
$80 = (
u_char *) 0x98d69b0 "HTTP/1.1 200 OK/r/nServer: nginx/0.8.37/r/nDate: Sat, 14 Aug 2010 12:18:40 GMT/r/nContent-Type: application/javascript/r/nConnection: keep-alive/r/nLast-Modified: Tue, 20 Jul 2010 11:18:00 GMT/r/nETag: /"2701-48bc"...
(gdb) p in->next->buf->last
$81 = (
u_char *) 0x9895394 "Control: max-age=315360000/r/nExpires: Tue, 11 Aug 2020 12:30:16 GMT/r/n/r/n?{hR/211/t"
(gdb)