nginx 1.6.2源码分析2 499问题之upstream
2015-07-15 22:25
856 查看
upstream作为handler中一位,有重要的作用,和filter等不同的地方是,它不自己产生内容,处于处理链的上游,特殊之处也在于,他需要暂时保留一些数据,等数据回来的时候进行回复?这具体是怎么操作的?
1 upstream是如何接收请求的,接收请求的时候必然要创建一个数据结构出来,存一下啦
#0 ngx_http_upstream_init_request (r=r@entry=0x84be80) at src/http/ngx_http_upstream.c:532
#1 0x000000000043e551 in ngx_http_upstream_init (r=r@entry=0x84be80) at src/http/ngx_http_upstream.c:473
#2 0x0000000000434268 in ngx_http_read_client_request_body (r=r@entry=0x84be80, post_handler=0x43e4e6 <ngx_http_upstream_init>) at src/http/ngx_http_request_body.c:84
#3 0x000000000045ce45 in ngx_http_fastcgi_handler (r=0x84be80) at src/http/modules/ngx_http_fastcgi_module.c:649
#4 0x0000000000428529 in ngx_http_core_content_phase (r=0x84be80, ph=<optimized out>) at src/http/ngx_http_core_module.c:1410
#5 0x00000000004238e3 in ngx_http_core_run_phases (r=r@entry=0x84be80) at src/http/ngx_http_core_module.c:888
#6 0x00000000004239f2 in ngx_http_handler (r=r@entry=0x84be80) at src/http/ngx_http_core_module.c:871
#7 0x000000000042b2cb in ngx_http_process_request (r=r@entry=0x84be80) at src/http/ngx_http_request.c:1902
#8 0x000000000042d2e8 in ngx_http_process_request_headers (rev=rev@entry=0x2b716f051350) at src/http/ngx_http_request.c:1333
#9 0x000000000042d5aa in ngx_http_process_request_line (rev=rev@entry=0x2b716f051350) at src/http/ngx_http_request.c:1012
#10 0x000000000042dc93 in ngx_http_wait_request_handler (rev=0x2b716f051350) at src/http/ngx_http_request.c:499
#11 0x0000000000419416 in ngx_event_process_posted (cycle=cycle@entry=0x8400f0, posted=0x691b98 <ngx_posted_events>) at src/event/ngx_event_posted.c:40
#12 0x000000000041904b in ngx_process_events_and_timers (cycle=cycle@entry=0x8400f0) at src/event/ngx_event.c:275
#13 0x000000000041ee5f in ngx_worker_process_cycle (cycle=0x8400f0, data=<optimized out>) at src/os/unix/ngx_process_cycle.c:816
#14 0x000000000041d6d6 in ngx_spawn_process (cycle=cycle@entry=0x8400f0, proc=proc@entry=0x41ed93 <ngx_worker_process_cycle>, data=data@entry=0x1a,
name=name@entry=0x467e54 "worker process", respawn=respawn@entry=-3) at src/os/unix/ngx_process.c:198
#15 0x000000000041e195 in ngx_start_worker_processes (cycle=cycle@entry=0x8400f0, n=32, type=type@entry=-3) at src/os/unix/ngx_process_cycle.c:364
#16 0x000000000041f54b in ngx_master_process_cycle (cycle=cycle@entry=0x8400f0) at src/os/unix/ngx_process_cycle.c:136
#17 0x00000000004041b0 in main (argc=<optimized out>, argv=<optimized out>) at src/core/nginx.c:407
搜索源码发现 r->content_handler的赋值是在ngx_http_update_location_config中发生的:
Breakpoint 2, ngx_http_update_location_config (r=r@entry=0x84be80) at src/http/ngx_http_core_module.c:1530
1530 r->content_handler = clcf->handler;
clcf是什么呢?
ngx_http_core_loc_conf_t *clcf;
clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
其中
#define ngx_http_get_module_loc_conf(r, module) (r)->loc_conf[module.ctx_index]
clcf是r的一部分
1 upstream是如何接收请求的,接收请求的时候必然要创建一个数据结构出来,存一下啦
#0 ngx_http_upstream_init_request (r=r@entry=0x84be80) at src/http/ngx_http_upstream.c:532
#1 0x000000000043e551 in ngx_http_upstream_init (r=r@entry=0x84be80) at src/http/ngx_http_upstream.c:473
#2 0x0000000000434268 in ngx_http_read_client_request_body (r=r@entry=0x84be80, post_handler=0x43e4e6 <ngx_http_upstream_init>) at src/http/ngx_http_request_body.c:84
#3 0x000000000045ce45 in ngx_http_fastcgi_handler (r=0x84be80) at src/http/modules/ngx_http_fastcgi_module.c:649
#4 0x0000000000428529 in ngx_http_core_content_phase (r=0x84be80, ph=<optimized out>) at src/http/ngx_http_core_module.c:1410
#5 0x00000000004238e3 in ngx_http_core_run_phases (r=r@entry=0x84be80) at src/http/ngx_http_core_module.c:888
#6 0x00000000004239f2 in ngx_http_handler (r=r@entry=0x84be80) at src/http/ngx_http_core_module.c:871
#7 0x000000000042b2cb in ngx_http_process_request (r=r@entry=0x84be80) at src/http/ngx_http_request.c:1902
#8 0x000000000042d2e8 in ngx_http_process_request_headers (rev=rev@entry=0x2b716f051350) at src/http/ngx_http_request.c:1333
#9 0x000000000042d5aa in ngx_http_process_request_line (rev=rev@entry=0x2b716f051350) at src/http/ngx_http_request.c:1012
#10 0x000000000042dc93 in ngx_http_wait_request_handler (rev=0x2b716f051350) at src/http/ngx_http_request.c:499
#11 0x0000000000419416 in ngx_event_process_posted (cycle=cycle@entry=0x8400f0, posted=0x691b98 <ngx_posted_events>) at src/event/ngx_event_posted.c:40
#12 0x000000000041904b in ngx_process_events_and_timers (cycle=cycle@entry=0x8400f0) at src/event/ngx_event.c:275
#13 0x000000000041ee5f in ngx_worker_process_cycle (cycle=0x8400f0, data=<optimized out>) at src/os/unix/ngx_process_cycle.c:816
#14 0x000000000041d6d6 in ngx_spawn_process (cycle=cycle@entry=0x8400f0, proc=proc@entry=0x41ed93 <ngx_worker_process_cycle>, data=data@entry=0x1a,
name=name@entry=0x467e54 "worker process", respawn=respawn@entry=-3) at src/os/unix/ngx_process.c:198
#15 0x000000000041e195 in ngx_start_worker_processes (cycle=cycle@entry=0x8400f0, n=32, type=type@entry=-3) at src/os/unix/ngx_process_cycle.c:364
#16 0x000000000041f54b in ngx_master_process_cycle (cycle=cycle@entry=0x8400f0) at src/os/unix/ngx_process_cycle.c:136
#17 0x00000000004041b0 in main (argc=<optimized out>, argv=<optimized out>) at src/core/nginx.c:407
搜索源码发现 r->content_handler的赋值是在ngx_http_update_location_config中发生的:
Breakpoint 2, ngx_http_update_location_config (r=r@entry=0x84be80) at src/http/ngx_http_core_module.c:1530
1530 r->content_handler = clcf->handler;
clcf是什么呢?
ngx_http_core_loc_conf_t *clcf;
clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
其中
#define ngx_http_get_module_loc_conf(r, module) (r)->loc_conf[module.ctx_index]
clcf是r的一部分
相关文章推荐
- 初探nginx架构
- 让nginx支持PATH_INFO
- Nginx负载均衡和LVS负载均衡的比较分析
- nginx通配符
- nginx.conf配置说明
- nginx
- Nginx配置文件nginx.conf中文详解(总结)
- windows下安装nginx
- Nginx与jetty结合
- nginx模块
- virtualenv 环境下 Nginx + Flask + Gunicorn+ Supervisor 搭建 Python Web
- Ubuntn下Nginx安装流程
- virtualenv 环境下 Flask + Nginx + Gunicorn+ Supervisor 搭建 Python Web
- Nginx站点搭建和自定义日志文件
- windows下nginx的启动关闭
- 基于NodeJS的前后端分离的思考与实践(六)Nginx + Node.js + Java 的软件栈部署实践
- nginx日志文件切割
- Windows下nginx+php配置
- [nginx+linux] centos上安装nginx
- Nginx基本配置和性能优化