Nginx data structure set (Updated at any time)

Source: Internet
Author: User
: This article mainly introduces the nginx data structure set (Updated at any time). If you are interested in the PHP Tutorial, please refer to it. When learning nginx, because of its slightly more data structures, I usually forget it after reading it. So you can learn and record it here for later viewing.
Ngx_buf_t: Buffer node

1: typedefstruct ngx_buf_s ngx_buf_t; 2: typedefvoid * ngx_buf_tag_t; 3: struct ngx_buf_s {4:/* 5: * pos is usually used to tell the user to process data in the memory from the position of pos. this setting is because the same 6: * ngx_buf_t may be processed multiple times. Of course, the meaning of pos is defined by the 7: */8: u_char * pos; 9: 10:/* last usually indicates valid content until now, note that the memory between pos and last is the content to be processed by nginx */11: u_char * last; 12: 13:/* 14: * when processing files, the meanings of file_pos and file_last are the same as those of last when processing memory. 15: * file_pos indicates the location of the file to be processed, and file_last indicates the location of the file to be processed. 16: */17: off_t file_pos; 18: off_t file_last; 19: 20:/* If the ngx_buf_t buffer is used for memory, start points to the starting address of the memory segment */21: u_char * start; 22: 23:/* corresponds to the start member, pointing to the end of the buffer memory */24: u_char * end; 25: 26:/* indicates the current buffer type, for example, if a module is used, it directs to the address of the ngx_module_t variable of this module */27: ngx_buf_tag_t tag; 28: 29:/* referenced file */30: ngx_file_t * file; 31: 32:/* 33: * The Shadow buffer of the current buffer, which is rarely used by this member. The shadow member is used only when the buffer is forwarded to the upstream server. 34: * This is because nginx saves too much memory. after allocating a piece of memory and using ngx_buf_t to indicate the received upstream server response, 35: * when forwarding data to downstream clients, this memory may be stored in the file or directly sent to downstream clients. nginx will never 36 at this time: * re-copy a copy of the memory for the new purpose. Instead, create a ngx_buf_t struct to point to the original memory. in this way, multiple ngx_buf_t 37: * struct points to the same memory, the relationship between them is referenced by the shadow member. it is generally not recommended. 38: */39: ngx_buf_t * shadow; 40: 41:/* indicates the temporary memory flag. if it is set to 1, the data is in the memory and the memory length can be modified */42: unsigned temporay: 1; 43: 44:/* indicates that the data is in the memory and cannot be modified during this period */45: unsigned memory: 1; 46: 47:/* indicates that when the flag is 1, the memory is mapped using the nmap system call and cannot be modified */48: unsigned mmap: 1; 49: 50: /* flag bit. if it is 1, it indicates it can be recycled */51: unsigned recycled: 1; 52: 53, if the value is 1, the buffer zone processes files instead of memory */54: unsigned in_file: 1; 55: 56:/* flag, if the value is 1, the flush operation */57: unsigned flush: 1; 58: 59:/* 60: * indicates whether to use the synchronous mode when operating this buffer zone. This may block the nginx process. all 61: * almost all operations are asynchronous, which is the key to supporting high concurrency. Some framework code may block the I/O 62: * operation when sync is 1. its meaning depends on the nginx module. 63: */64: unsigned sync: 1; 65: 66:/* 67: * indicates whether the flag is the last buffer, because ngx_buf_t can be linked by the ngx_chain_t linked list, therefore, when the value is 1, 68: * indicates the last buffer to be processed. 69: */70: unsigned last_buf: 1; 71: 72:/* indicates whether it is the last buffer in ngx_chain_t */73: unsigned last_in_chain: 1; 74: 75: /* indicates whether it is the last shadow buffer, which is used with the shadow field. It is generally not recommended to use it */76: unsigned last_shadow: 1; 77: 78:/* flag, indicating whether the current buffer is a temporary file */79: unsigned temp_file: 1; 80 :}

Ngx_chain_t: Buffer linked list

Typedefstruct into ngx_chain_t; struct ngx_chain_s {ngx_buf_t * buf; // The buf points to the current ngx_buf_t buffer ngx_chain_t * next; // next points to the next shard. if this is the last shard, set next to NULL. };

Ngx_http_upstream_t: sets the restrictive parameters of upstream.

Typedef struct {... // timeout time for connecting to the upstream server, in milliseconds ngx_msec_t connect_timeout; // timeout time for sending TCP packets to the upstream server, in milliseconds ngx_msec_t connect_timeout; // timeout time for receiving TCP packets to the upstream server, in milliseconds ngx_msec_t connect_timeout ;...} ngx_http_upstream_conf_t;

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

The above introduces the nginx data structure set (Updated at any time), including some content, hope to be helpful to friends who are interested in PHP tutorials.

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.