Php-fpm Execution Process source code analysis, php-fpm source code analysis

Source: Internet
Author: User

Php-fpm Execution Process source code analysis, php-fpm source code analysis

Author: zhanhailiang Date:

Sapi \ fpm \ fpm_main.c: @ main;

  1. Fcgi_init ()-> fcgi_setup_signals (); set the signal processing method;

    Sigaction (SIGUSR1, & new_sa, NULL );
    Sigaction (SIGTERM, & new_sa, NULL );
    Sigaction (SIGPIPE, NULL, & old_sa );

  2. Sapi_startup (& cgi_sapi_module );
    -> Sapi_globals_ctor (& sapi_globals); initialize the global variable;
    -> Reentrancy_startup ();

  3. Fcgi_fd = fpm_run (& max_requests); process initialization, call fork () to create a process

  4. Fcgi_init_request (& request, fcgi_fd); request initialization;

  5. While (fcgi_accept_request (& request)> = 0 ){
    5.1. init_request_info; Request initialization; SG (request_info), SG (sapi_headers)
    5.2. fpm_request_info ();
    5.3. php_request_startup (TSRMLS_C );
    -> Php_start_sapi (); Request global variable initialization;
    -> Sapi_activate (TSRMLS_C); Request HTTP header information initialization;
    -> Php_hash_environment (TSRMLS_C); initial listener to request environment variables; for example, $ _ GET, $ _ POST, $ _ ENV, $ _ SERVER, $ _ COOKIE, $ _ FILES is implemented in this step. $ _ REQUEST determines whether real-time Initialization is required based on jit_initialization;
    5.4. fpm_status_handle_request (TSRMLS_C );
    5.5. php_fopen_primary_script (& file_handle TSRMLS_CC); open the script;
    5.5. fpm_request_executing ();
    5.7. php_execute_script (& file_handle TSRMLS_CC); execute the script;
    5.8. fpm_request_end (TSRMLS_C );
    5.9. php_request_shutdown (void *) 0); The request ends and the resources applied in the request lifecycle are released;

  6. Fcgi_shutdown (); release the applied persistent Resource

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.