nginx 1.6.2源码分析2 499问题之upstream

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的一部分

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值