(Personal open Source) Nginx Source code Comment

Source: Internet
Author: User
Address

Https://github.com/langsim/nginx-1.6.2-comment

Brief introduction

Hope to complete a high readability of the Nginx source code comments.

Content that will not be commented

    1. Spdy related code, because Spdy has been replaced by HTTP2.
    2. Thread-related code, because at least 1.6.2 Nginx threads are still in the experimental phase.
    3. Code for other platforms other than Linux.
    4. Code for other event models other than Epoll
    5. Code for other compilers other than GCC.
    6. Mail-related code.

Degree of Completion

    1. Core Catalog 60%
    2. Event Directory 20%
    3. HTTP Directory 10%
    4. OS directory 80%

function Chain List

    1. Between the HTTP filter modules, Ngx_http_top_header_filter and Ngx_http_top_body_filter will form two function lists, and the order of the functions in the list will be called with the corresponding modules in Ngx_ The modules array is in the reverse order.
    2. Many of the 11 phases of HTTP request processing can have multiple callback functions, and the order of calls between callback functions in the same phase and the corresponding modules in the Ngx_modules array are the same.

Log

Nginx has two log files by default:

    1. Access.log: Each HTTP request generates a row of records in it.
    2. Error.log:nginx some general, error, or debug logs at run time.

Process Model

Four process states may occur after Nginx starts:

    1. Single-process foreground run
    2. Single-Process daemon mode
    3. One master process, one (or more) worker processes, one (or 0) CacheManager processes and one (or 0) Cacheloader processes working together in the foreground
    4. A master process, one (or more) worker processes, one (or 0) CacheManager processes, and one (or 0) Cacheloader processes running in daemon state.
      • The master process starts when it is used to start other processes, and is used to manage other processes when the boot is complete.
      • The Woker process, which is used to actually process link requests.
      • The CacheManager process is used to clean up the cache file as required.
      • The Cacheloader process starts by indexing the eligible cache files in the cache directory in memory, does not meet the required cache file cleanup, and then exits.
    5. After startup, signal the main process of the running Nginx and exit.

Switching of process running state

    1. Overloaded configuration files (reload)
    2. Hot Upgrade executable file

Compile

Nginx compilation and Linux platform common open source software compiles the same way, is run./configure && make && make install, and add your own custom options after the./configure.

Nginx Use signal

    1. term, INT quick close
    2. QUIT calmly close
    3. HUP smooth Restart, reload configuration file
    4. USR1 reopen log file for larger use when cutting logs
    5. USR2 Smooth Upgrade Executable program
    6. WINCH gracefully close the work process

Nginx Memory Pool

Nginx has two pools of memory

    1. allocating memory pools on shared memory
    2. Memory pool for memory on normal memory for efficient use of memory

A computational hash algorithm used by nginx

    1. Crc32
    2. Crc16
    3. Sha1
    4. MurmurHash
    5. Md5

NIGNX Process Communication and synchronization

    1. Use of shared memory
    2. Signal
    3. UNIX sockets

'). addclass (' pre-numbering '). Hide (); $ (this). addclass (' has-numbering '). Parent (). append ($numbering); for (i = 1; i <= lines; i++) {$numbering. Append ($ ('
  • '). Text (i)); }; $numbering. FadeIn (1700); }); });

    The above describes the (personal open source) Nginx source code comments, including the content, I hope the PHP tutorial interested in a friend helpful.

  • 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.