nginx----ngx_buf

本文详细介绍了nginx中ngx_buf_t和ngx_chain_t的数据结构及其作用。ngx_buf_t用于指示数据位置和设置标志位,ngx_chain_t则通过next指针连接多个buf形成数据包链。当最后一个chain的next为NULL时,数据开始发送。
摘要由CSDN通过智能技术生成

在ngx_buf.h文件中,定义了ngx_chain_t和ngx_buf_t两个结构体。其中chain起到一个链的作用,将待发送的数据包串联起来,而buf则是chain中的每一个节点。

ngx_buf_t的数据结构如下:

struct ngx_buf_s {
    u_char          *pos;
    u_char          *last;
    off_t            file_pos;
    off_t            file_last;

    u_char          *start;         /* start of buffer */
    u_char          *end;           /* end of buffer */
    ngx_buf_tag_t    tag;
    ngx_file_t      *file;
    ngx_buf_t       *shadow;


    /* the buf's content could be changed */
    unsigned         temporary:1;

    /*
     * the buf's content is in a memory cache or in a read only memory
     * and must not be changed
     */
    unsigned         memory:1;

    /* the buf's content is mmap()ed and must not be changed */
    unsigned         mmap:1;

    unsigned         recycled:1;
    unsigned         in_file:1;
    unsigned         flush:1;
    unsigned         sync:1;
    unsigne
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值