Ngx_http_wait_request_handler function parsing

Source: Internet
Author: User

In the normal HTTP request process, the Ngx_event_accept function is Ls->handler (c); The Ngx_http_init_connection function is called, Ngx_http_init_ The connection function calls Ngx_http_wait_request_handler. The main code and parsing are as follows.     See if the event has expired, and if it has expired, disconnect if  directly (rev->timedout)  {    ngx_log_error (ngx_log_info, c->log, ngx_etimedout,  "Client timed out");     Ngx_http_close_connection (c);     return;} Call the RECV function to receive the data. function prototypes are defined in NGX_RECV.C, and there are two function definitions depending on whether kqueue (an I/O multiplexing technique) is used. N = C->RECV (c, b->last, size);if  (n == ngx_again)  {      There is no data channel, due to nginx event-driven mechanism, the program will not block, register read events and return.     if  (Ngx_handle_read_event (rev, 0)  != NGX_OK)       {        ngx_http_close_connection (c);         return;    }     connection There may be no substantive work done, so release memory for the moment.     if  (Ngx_pfree (C->pool, b->start)  == NGX_OK)      {         b->start = NULL;    }     return;} The RECV function returned an error, disconnected directly and returned. if  (N == ngx_error)  {    ngx_http_close_connection (c);     return;} The client has actively disconnected the connection. if  (n == 0)  {    ngx_log_error (ngx_log_info, c->log, 0,                    " Client closed connection ");     ngx_http_close_connection (c);     return;} If there is something similar to "listen 80 proxy_protocol;" Configuration, has not been carefully studied if  (Hc->proxy_protocol)  {        ...     }ngx_reusable_connection (c, 0); invokes the Ngx_http_create_request function to initialize a ngx_http_request_t struct. C-&gT;data = ngx_http_create_request (c);if  (C->data == null)  {     ngx_http_close_connection (c);     return;} Sets the Read event callback function for the destination connection to process the processing request line rev->handler = ngx_http_process_request_line; first executes the processing request line function, in ngx_http_process _request_line in Ngx_http_process_request_line (rev.);


This article is from the "11480450" blog, please be sure to keep this source http://11490450.blog.51cto.com/11480450/1765681

Ngx_http_wait_request_handler function parsing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.