PHP-FPM implementation Process Source analysis

Source: Internet
Author: User

zhanhailiang 日期:2015-03-09

SAPI\FPM\FPM\FPM_MAIN.C: @main;

  1. Fcgi_init ()->fcgi_setup_signals (); Set up 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 global variables;
    ->reentrancy_startup ();

  3. FCGI_FD = Fpm_run (&max_requests); Process initialization, calling 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); Request environment variable initial listening; $_get,$_post,$_env,$_server,$_ Cookie,$_files is the beginning of this step; $_request based on jit_initialization to determine if real-time initialization is required;  
    5.4. Fpm_status_handle_request (Tsrmls_c); 
    5.5. Php_fopen_primary_script (&file_handle tsrmls_cc); open script;  
    5.5. Fpm_request_ Executing ();
    5.7 php_execute_script (&file_handle tsrmls_cc); Execute script;  
    5.8. Fpm_request_end ( Tsrmls_c)  
    5.9. Php_request_shutdown ((void *) 0); Request end, release the requested resource in the request life cycle;

  6. Fcgi_shutdown (); Release a persisted resource for the request

PHP-FPM implementation Process Source analysis

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.